// Text sizer, a utility to determine the length of a text string // By Eric Freeman // 02-06-98 #include "colors.inc" // change the "camera_z" value to zoom in and out on the text // start far away (20 is farther away than 10) so you can see the whole text line // count the number of lines till the end of the text // NOTE: the first line on the left is at position 0 (zero), // the next line is at position 1 (one), etc. // I've put a "0" on the zero line and hash marks every five lines to help you count // then set the "camera_x" value to the end of the text (ie, line count) // then zoom in (lower "camera_z" value) till you can judge the exact end // of the text. The "camera_x" value will be the length of the text. // change this value to zoom in and out on image #declare camera_z = 9 // change this value to move the camera along the x-axis (left-right) #declare camera_x = 5.3 // 5 is a good starting point // put your font path/name here (don't ferget the quotes) #declare font_name = "C:\WINDOWS\FONTS\ARIAL.TTF" // put your text line here (don't ferget the quotes) #declare text_string = "Your Message Here" // put the scale here #declare scaler = 1.2 // that's it. render and count the lines!!!!!!!!!!!!!!!!! // adjust the "camera_x" and "camera_z" values and u will see that the example text line // is 10.62 units long //************************************************************************************* // DON'T MESS WITH THE CODE BELOW THIS LINE * // [ UNLESS YOU REALLY WANT TO :-) ] * //************************************************************************************* background { color Khaki } // the camera camera { location < camera_x, camera_z/4, -camera_z > look_at < camera_x, 0.3, 0 > } // the light source follows the camera light_source { < camera_x, camera_z/4, -camera_z > color White } // the ruler box { < 0, -0.1, -0.1 > < 400, 0, 0.1 > pigment { color White } } // the plum line box { < camera_x-0.0001, -100, -0.101 > < camera_x+0.0001, 100, -0.1 > pigment { color Black } } // the lines on the ruler #declare looper = 0 #while (looper < 401) box { < looper-0.01, 0.0, -0.1 > < looper+0.01, 0.9, 0.1 > pigment { color Blue } finish { ambient 0.5 } } #declare looper = looper+1 #end // the text to measure text { ttf font_name , text_string, 0.01, 0.0 pigment { color Red } scale scaler } // the zero mark #declare ruler_zero = difference { cylinder { < 0.0, -0.1, -0.11 >, < 0.0, -0.1, -0.1 > 0.15 } cylinder { < 0.0, -0.1, -0.11001 >, < 0.0, -0.1, -0.0999 > 0.07 } pigment { color Black } } ruler_zero // the "5" marks #declare looper = 5 #while (looper < 401) box { < looper-0.05, -0.3, -0.11 >, < looper+0.05, 0, -0.1> pigment { color Black } } #declare looper = looper+5 #end