|
![](/i/fill.gif) |
Jessica Bushnaq wrote:
>
> Especially: Is there a method to get the exact width of a given
> character?
I have only the official version, and here's the code I use to get the
width of text:
// START OF SOMETHING OF POSSIBLE USE
#local W=1; // you'll be tweaking this value
text { ttf "cyrvetic.ttf", // or whatever font you're using
"My text.", // change to whatever you're using
0,
0
pigment { rgb <1,0,0> } // to make things obvious
finish { ambient 1 diffuse 0 }
translate -z*.001
}
plane { -z,0
pigment { gradient x color_map { [0 rgb 0][1 rgb 1] } scale W }
finish { ambient 1 diffuse 0 }
}
camera {
orthographic
location <W,.375,-1>
look_at <W,.375,0>
}
// END OF SOMETHING OF POSSIBLE USE
You should see an image that is white on the left side and black on
the right, with red text. Adjust W until the right edge of the text
lies exactly on the border between the black and white areas. When
this happens, W is either the exact width of the text, or is a simple
fraction (1/2, 1/3, 1/4) of that width; starting with a higher value
and working your way down will give better results.
Hope this helps,
John
Post a reply to this message
|
![](/i/fill.gif) |