POV-Ray : Newsgroups : povray.newusers : Width of character Server Time
5 Sep 2024 16:20:42 EDT (-0400)
  Width of character (Message 7 to 16 of 16)  
<<< Previous 6 Messages Goto Initial 10 Messages
From: John VanSickle
Subject: Re: Width of character
Date: 20 Nov 2000 08:02:11
Message: <3A1920D1.A3972E01@erols.com>
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

From: ingo
Subject: Re: Width of character
Date: 20 Nov 2000 11:14:55
Message: <8FF2A6912seed7@povray.org>
John VanSickle wrote:

>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.

This makes me think, if your intention is to put the letters on the same 
positions as they are in the "full text", you could as well use a 
pigment_map or texture_map with a gradient to give each letter a different 
texture.

text {
  ttf
  "crystal.ttf",
  "POV",
  0.1,
  0
  pigment {
    gradient x
    scale 2
    pigment_map{
      [0.2, wood]
      [0.2, granite]
      [0.5, granite]
      [0.5, wood]
    }
  }
  translate <-0.75,0,0>
}


Ingo

-- 
Photography: http://members.home.nl/ingoogni/
Pov-Ray    : http://members.home.nl/seed7/


Post a reply to this message

From: Dawn McKnight
Subject: Re: Width of character
Date: 21 Nov 2000 23:16:00
Message: <3A1B4882.8ED3D7D1@mac.com>
Chris Huff wrote:
 
> A more flexible(and far simpler) solution would be to use a separate
> text object for every character and use the min_extent() and
> max_extent() functions to get the bounding box for each individual
> character, and use these values to position the characters correctly.

I'm trying to get a text string centered, and I remembered this thread. 
Chris, can I use min_extent() and max_extent() on a string, or is it
only applicable to single characters?  Where can I find documentation on
these functions; it doesn't seem to be with the other text primitive
documentation in the official docs.

For that matter, if the function is not part of POV natively, where can
I find the function?

Thanks in advance.

-- 
Dawn McKnight      | "Who cares what the hipbone's connected to? I'm in Neurology!"
McK### [at] maccom   |					-- Justine Devlin, M.D.


Post a reply to this message

From: Ron Parker
Subject: Re: Width of character
Date: 21 Nov 2000 23:58:35
Message: <slrn91mkjv.e3o.ron.parker@fwi.com>
On Tue, 21 Nov 2000 21:16:03 -0700, Dawn McKnight wrote:
>I'm trying to get a text string centered, and I remembered this thread. 
>Chris, can I use min_extent() and max_extent() on a string, or is it
>only applicable to single characters?  

It will work with almost any finite primitive, which includes a multicharacter
text object.  It fails on some CSGs, though; most notably on intersections and
differences.

>For that matter, if the function is not part of POV natively, where can
>I find the function?

It's part of MegaPOV and other patches like it.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Mike Williams
Subject: Re: Width of character
Date: 23 Nov 2000 13:27:03
Message: <nvKukHA+aUH6Ewup@econym.demon.co.uk>
Wasn't it Dawn McKnight who wrote:
>
>
>Chris Huff wrote:
> 
>> A more flexible(and far simpler) solution would be to use a separate
>> text object for every character and use the min_extent() and
>> max_extent() functions to get the bounding box for each individual
>> character, and use these values to position the characters correctly.
>
>I'm trying to get a text string centered, and I remembered this thread. 
>Chris, can I use min_extent() and max_extent() on a string, or is it
>only applicable to single characters?  Where can I find documentation on
>these functions; it doesn't seem to be with the other text primitive
>documentation in the official docs.
>
>For that matter, if the function is not part of POV natively, where can
>I find the function?

Text centring is directly available in MegaPOV. Just add the
"align_center" modifier to the text object. 

You only need to use MegaPOV's "min_extent()" and "max_extent()" if
you're doing more complicated positioning tasks.


The *_extent functions are described in section 9.1 (Bounds Patch) of
the MegaPOV 0.6 docs, and align_* are in section 6.6 (Text Object
Enhancements).

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Dawn McKnight
Subject: Re: Width of character
Date: 23 Nov 2000 16:42:00
Message: <3A1D8F29.D5F83F46@mac.com>
Mike Williams wrote:
> 
> Wasn't it Dawn McKnight who wrote:

Why yes, it was... thank you for noticing! P)

> Text centring is directly available in MegaPOV. Just add the
> "align_center" modifier to the text object.

Sadly, that requires me to download MegaPOV, install it, figure out
where it's different from standard POV, so that I don't get
unpredictable results in my scene files, read the docs on text, etc., etc.

Of course, I probably will do this, eventually, but it's really rather
more involved than I wanted to get for what is basically a throw-away
test on a concept.

Thank you for letting me know this, and for your citation on where the
documentation is... I'll be very grateful when I get around to doing all
that stuff. 8)

-- 
Dawn McKnight      | "Who cares what the hipbone's connected to? I'm in Neurology!"
McK### [at] maccom   |					-- Justine Devlin, M.D.


Post a reply to this message

From: Ken
Subject: Re: Width of character
Date: 23 Nov 2000 16:46:52
Message: <3A1D90E0.439B4C87@pacbell.net>
Dawn McKnight wrote:

> Sadly, that requires me to download MegaPOV, install it, figure out
> where it's different from standard POV, so that I don't get
> unpredictable results in my scene files, read the docs on text, etc., etc.
> 
> Of course, I probably will do this, eventually, but it's really rather
> more involved than I wanted to get for what is basically a throw-away
> test on a concept.

For all intents and purposes you should be able to use Megapov
with little or no extra knowlege other than learning it's extra
feature sets. It is basically the same as the official version
with enhancements.

-- 
Ken Tyler


Post a reply to this message

From: Ron Parker
Subject: Re: Width of character
Date: 24 Nov 2000 00:28:06
Message: <slrn91rv3a.fuv.ron.parker@fwi.com>
On Thu, 23 Nov 2000 16:33:02 +0000, Mike Williams wrote:
>Text centring is directly available in MegaPOV. Just add the
>"align_center" modifier to the text object. 

Note that this won't be directly supported in POV 3.5.  

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Dawn McKnight
Subject: Re: Width of character
Date: 24 Nov 2000 10:11:18
Message: <3A1E8516.C988E611@mac.com>
Ron Parker wrote:
> Note that this won't be directly supported in POV 3.5.

Will there be any text handling improvements in 3.5?

-- 
Dawn McKnight      | "Who cares what the hipbone's connected to? I'm in Neurology!"
McK### [at] maccom   |					-- Justine Devlin, M.D.


Post a reply to this message

From: Ron Parker
Subject: Re: Width of character
Date: 24 Nov 2000 12:50:37
Message: <slrn91taji.gfc.ron.parker@fwi.com>
On Fri, 24 Nov 2000 08:11:19 -0700, Dawn McKnight wrote:
>
>
>Ron Parker wrote:
>> Note that this won't be directly supported in POV 3.5.
>
>Will there be any text handling improvements in 3.5?

The min_extent and max_extent functions will make it in, and we'll likely
provide macros to give the same functionality as the MegaPOV text alignment
keywords provide.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

<<< Previous 6 Messages Goto Initial 10 Messages

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