POV-Ray : Newsgroups : povray.beta-test : Circle_Text macro problem : Re: Circle_Text macro problem Server Time
2 Nov 2024 17:17:37 EDT (-0400)
  Re: Circle_Text macro problem  
From: Ron Parker
Date: 24 Oct 2001 10:27:42
Message: <slrn9tdjuv.32q.ron.parker@fwi.com>
On Wed, 24 Oct 2001 14:38:00 +0200, Rune wrote:
> I'm not sure, but I don't really see a reason to preserve the old TextWidth
> macro. What can it be used for? 

It's most useful for finding the width of a string if you plan to append 
it to another string.

The problem with doing it without the extra space is that you then get the
exact width of the text, right to the right edge of the last character.  So
if you do 

#declare T1=text{ttf "arial.ttf", "Normal" .001 0}
#declare T2=text{ttf "arialbd.ttf", "Bold" .001 0}

union {
  object{T1}
  object {T2 translate x*(max_extent(T1)-min_extent(T1))}
  texture {pigment {color rgb 1} finish {ambient .5}}
}

camera {location -10*z look_at 0}

you find that the "B" in "Bold" is butted right up against the "l" in 
"Normal".  (since TextWidth without the bars is just what I've used there.)

A character has an intrinsic property known as "advance width" which is 
not at all related to the width of the actual glyph.  The easy example is
a plain space: the glyph has no width at all, but the advance width is
about the same as the advance width of an 'n'.  Another easy example is
a nonproportional font: the W is a lot wider than the l, but they both have
the same advance width.

min_extent/max_extent can only extract the glyph width, but by adding on 
the vertical bars and taking the width of that, then subtracting the width 
of the vertical bars by themselves, you should get the advance widths of 
all the characters in the string.

The problem you're seeing might be that some characters actually get
kerned against the "|" character, which would screw up the advance width
calculation.  There's no easy way to fix this.  In fact, I picked "|"
because it's one of the least likely characters to be kerned.

-- 
plane{-z,-3normal{crackle scale.2#local a=5;#while(a)warp{repeat x flip x}rotate
z*60#local a=a-1;#end translate-9*x}pigment{rgb 1}}light_source{-9red 1rotate 60
*z}light_source{-9rgb y rotate-z*60}light_source{9-z*18rgb z}text{ttf"arial.ttf"
"RP".01,0translate-<.6,.4,.02>pigment{bozo}}light_source{-z*3rgb-.2}//Ron Parker


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.