POV-Ray : Newsgroups : povray.newusers : text manipulation+coordinates : Re: text manipulation+coordinates Server Time
4 Sep 2024 22:15:13 EDT (-0400)
  Re: text manipulation+coordinates  
From: TinCanMan
Date: 26 Jul 2002 07:56:12
Message: <3d4138dc$1@news.povray.org>
Also, if you are using 3.5 you can centre the text better and automatically
using the min_extents/max_extents keyword.

Here's a macro I wrote a while ago to fit text to a certain area (scales the
text as well):

-----8<-----
//p1-p2 define box containing text
//FNam = font name
//Txt = text string
//Spac = letter spacing
#macro TxtFit(p1,p2,FNam,Txt,Spac)
  #local T1=text{ttf FNam, Txt, 1,Spac*x}
  #local TMn = min_extent (T1);
  #local TMx = max_extent (T1);
  #local TScal=(p2-p1)/(TMx-TMn);
  object{T1 translate -TMn scale TScal translate p1}
#end
-----8<-----

used like:

object{TxtFit(<-1,-1,0>,<2,1,1>,"arial","If the text fits...",0)
//extra transformations, materials, etc.
}

this fits the given text between the two points along the x-y plane.  You
can then rotate the text or translate as needed to suit.

-tgq


Post a reply to this message

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