POV-Ray : Newsgroups : povray.general : Centring a text object declaring a directive : Re: Centring a text object declaring a directive Server Time
1 Mar 2024 00:10:52 EST (-0500)
  Re: Centring a text object declaring a directive  
From: Kima
Date: 19 Apr 2023 19:15:00
Message: <web.644074f459e0b66565103170d427f3e5@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> not sure about objects in general, but with a text{} you could "cheat" using a
> macro, eg:
>
> #macro textLen(font_,s_)
>   #local t_ = text {ttf font_, s_, 1, 0};
>   (max_extent(t_).x - min_extent(t_).x)
> #end
>
> #declare txt_ = text {
>   ttf "timrom.ttf", "some more text", .1, 0
>   texture {texture_}
>   translate <-(textLen("timrom.ttf","some more text")) / 2,-2,0>
> };
> object {txt_}
>
>
> regards, jr.


Your solution works like a charm. My problem was exactly the text. It is easier
to find the middle point for an object as we design them, but for texts, we rely
on font metrics.

Thanks!


Post a reply to this message

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