POV-Ray : Newsgroups : povray.newusers : Width of character Server Time
5 Nov 2024 05:23:21 EST (-0500)
  Width of character (Message 1 to 10 of 16)  
Goto Latest 10 Messages Next 6 Messages >>>
From: Jessica Bushnaq
Subject: Width of character
Date: 19 Nov 2000 05:25:34
Message: <3a17aa9e@news.povray.org>
Hello, (hope I do this right, first time try to write to a newsgroup)

I try to make a text in a povray picture, putting together characters in
different textures.( with the text object and a truetype fond)
I have problems setting the distance between the characters right, because I
do not know the exact width of the characters.
Have I to do this by try and error, translate the characters until it looks
right or can somebody think of another method to do this ?
Especially: Is there a method to get the exact width of a given character?

Jessica Bushnaq


Post a reply to this message

From: Christoph Hormann
Subject: Re: Width of character
Date: 19 Nov 2000 06:27:48
Message: <3A17B933.82F38498@schunter.etc.tu-bs.de>
Jessica Bushnaq wrote:
> 
> Hello, (hope I do this right, first time try to write to a newsgroup)

Welcome to these groups, the posting looks ok to me, some general
information about things here can be found in: 

povray.announce.frequently-asked-questions

> I try to make a text in a povray picture, putting together characters in
> different textures.( with the text object and a truetype fond)
> I have problems setting the distance between the characters right, because I
> do not know the exact width of the characters.
> Have I to do this by try and error, translate the characters until it looks
> right or can somebody think of another method to do this ?
> Especially: Is there a method to get the exact width of a given character?
> 
> Jessica Bushnaq

IIRC there is no method in Povray to find out the width of the single
characters. Some things you could do anyway:

- The character width is stored somewhere in the TTF file, you could try
to read it with an external program and put a table with the data of all
character in a pov-file

- You could use a non proportial font (like Courier), where all the
characters have the same width.

- you could try to find the gaps between the characters with megapov's
trace function and use a gradient pattern to give the different characters
different textures.  This probably sounds quite complicated and it
requires some (pov-)programming knowledge, but IMO this is the most
elegant way :-)

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
Homepage: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Chris Huff
Subject: Re: Width of character
Date: 19 Nov 2000 08:39:46
Message: <chrishuff-210975.08400519112000@news.povray.org>
In article <3A17B933.82F38498@schunter.etc.tu-bs.de>, 
chr### [at] gmxde wrote:

> - you could try to find the gaps between the characters with 
> megapov's trace function and use a gradient pattern to give the 
> different characters different textures.  This probably sounds quite 
> complicated and it requires some (pov-)programming knowledge, but IMO 
> this is the most elegant way :-)

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.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: ingo
Subject: Re: Width of character
Date: 19 Nov 2000 09:12:09
Message: <8FF1992A9seed7@povray.org>
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.
>

Ron Parker made a macro for that:
Newsgroups: povray.programming
Subject: Re: Font metrics function
Message-ID: <slr### [at] parkerrfwicom>
Date: 27 Feb 2000 13:13:40 -0500


Ingo

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


Post a reply to this message

From: Christoph Hormann
Subject: Re: Width of character
Date: 19 Nov 2000 09:20:35
Message: <3A17E1B3.1E153F0@schunter.etc.tu-bs.de>
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 think that's only partly true, because the nominal width of the
characters (used for positioning them) and the de facto with do not need
to be the same.  I don't know which width is used for the bounding box
(whether all characters in a non proportional font have the same for
example), there can be even overlapping characters (they would not work
with the trace method either) so things are more complicated in fact...

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
Homepage: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Ron Parker
Subject: Re: Width of character
Date: 19 Nov 2000 23:52:05
Message: <slrn91hbfp.bn5.ron.parker@fwi.com>
On Sun, 19 Nov 2000 15:20:35 +0100, Christoph Hormann wrote:
>I think that's only partly true, because the nominal width of the
>characters (used for positioning them) and the de facto with do not need
>to be the same.  I don't know which width is used for the bounding box

The difference is advance width and kerning.  Those are taken into account
in the macro Ingo made note of.

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


Post a reply to this message

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

Goto Latest 10 Messages Next 6 Messages >>>

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