POV-Ray : Newsgroups : povray.newusers : Text dimensions Server Time
25 Nov 2024 01:23:07 EST (-0500)
  Text dimensions (Message 1 to 2 of 2)  
From: David Instone
Subject: Text dimensions
Date: 14 Dec 2006 10:25:47
Message: <45816cfb@news.povray.org>
I am placing a simple text in my scene using the sample from the help like
this.

  text {
    ttf "timrom.ttf" "TEST TEXT" 1, 0
    rotate x*90 scale 5
    translate <-13, 0.5, 0>
    pigment { Black }
  }

My problem is that my reference is the lower left corner which makes it very
difficult to accurately position the text within the scene. I have a fair
bit of it to place :) Is there a way to get the centre or length and height
of the rendered string so as to calculate the centrepoint?

Thanks


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Text dimensions
Date: 14 Dec 2006 12:05:01
Message: <web.45818372a36da7dbc150d4c10@news.povray.org>
"David Instone" <d.i### [at] gmailcom> wrote:
> I am placing a simple text in my scene using the sample from the help like
> this.
>
>   text {
>     ttf "timrom.ttf" "TEST TEXT" 1, 0
>     rotate x*90 scale 5
>     translate <-13, 0.5, 0>
>     pigment { Black }
>   }
>
> My problem is that my reference is the lower left corner which makes it very
> difficult to accurately position the text within the scene. I have a fair
> bit of it to place :) Is there a way to get the centre or length and height
> of the rendered string so as to calculate the centrepoint?
>
> Thanks

A good enough result usually:

#declare TxtObj = text {ttf "timrom.ttf" "TEST TEXT" 1, 0}

#declare Min=min_extent(TxtObj);
#declare Max=max_extent(TxtObj);

#declare Ctr=(Min+Max)/2; //centre
#declare Ht=(Max.y-Min.y); //height
#declare Ln=(Max.x-Min.x); //length

....etc.

-tgq


Post a reply to this message

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