POV-Ray : Newsgroups : povray.programming : The math of circular truetype fonts : Re: Font metrics function Server Time
28 Jul 2024 22:27:53 EDT (-0400)
  Re: Font metrics function  
From: Ron Parker
Date: 27 Feb 2000 13:13:40
Message: <slrn8biqdd.v8.ron.parker@parkerr.fwi.com>
On Sat, 26 Feb 2000 14:50:31 -0500, Lummox JR wrote:
>An update on the macro progress: As it turns out, min_extent() and
>max_extent() are indeed incapable of producing the desired result,
>because there is no spacing whatsover included between the characters;
>it's stripped out from the bounding boxes. Moreover, spaces don't appear
>at all.

This only happens if you do it a character at a time.  Kindly reread
my messages on the subject and try what I suggested.

>min_extent() of character (including spacing)
>max_extent() of character (including spacing)
>horizontal kerning of two characters

These three are all derivable using the methods I've already outlined.
Having a way to get them directly might be nice for speed purposes, but
the fact remains that you can use macros to get the information you 
need now.  However, I think you'll find that the POV Truetype code 
doesn't have any support for kern pairs anyway.

>maximum height above baseline (all glyphs)
>maximum descender size
>maximum width

What use are these, exactly?  Why do we care if the maximum height is
two X-heights if we don't plan to use the character that attains that
height?  If we do plan to use that character, we can derive all this
information with min_extent and max_extent.

>An advantage of this approach is that the text object for each character
>needn't be #declared until it's ready to be rotated. This saves all
>kinds of trouble, and all kinds of memory as well.

Doesn't save any memory at all.  You can #local the objects you need
to use and the memory will be freed when the macro returns.  Believe
it or not, I did think about all this stuff when I came up with 
min_extent and max_extent. 

Here are the macros I made to find the letter spacing and kerning. 
None of them allocate any memory that isn't freed before they return.
Try them.  They DO work.

// Find the advance width of character C in font F
#macro WidthWithSpacing( C, F )
  #local T=text {ttf F concat("|",C,"|") 1 0}
  #local W1=max_extent(T).x-min_extent(T).x;
  #local T=text {ttf F "||" 1 0}
  (W1-max_extent(T).x+min_extent(T).x)
#end

// Find the width of the glyph for character C in font F
#macro WidthNoSpacing( C, F )
  #local T=text {ttf F C 1 0}
  (max_extent(T).x-min_extent(T).x)
#end

// Find the kern for characters A and B from font F
#macro Kern( A, B, F )
  (WidthWithSpacing( concat(A, B), F)-WidthWithSpacing(A,F)
   -WidthWithSpacing(B,F))
#end

-- 
These are my opinions.  I do NOT speak for the POV-Team.
The superpatch: http://www2.fwi.com/~parkerr/superpatch/
My other stuff: http://www2.fwi.com/~parkerr/traces.html


Post a reply to this message

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