POV-Ray : Newsgroups : povray.programming : The math of circular truetype fonts : Font metrics function Server Time
28 Jul 2024 22:16:25 EDT (-0400)
  Font metrics function  
From: Lummox JR
Date: 26 Feb 2000 14:45:49
Message: <38B82E87.4402@aol.com>
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.
I think now that what's really needed here is not so much a redefinition
of the text primitive, but rather a function that will give the metrics
for a particular font. Specifically, it should be able to return the
following for any given font:

min_extent() of character (including spacing)
max_extent() of character (including spacing)
horizontal kerning of two characters
maximum height above baseline (all glyphs)
maximum descender size
maximum width

That ought to do it, I think.
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.
Now that I've got this idea in my head, I think I'll see if I can modify
truetype.c (and, necessarily, the parser) to support this function
instead. My concept for a syntax so far:

fontmetrics(<font name>,<function number>,<argument>)

And the function numbers:

  1 - min_extent of string <argument>, spacing included
  2 - max_extent of string <argument>, (horizontal) spacing included
  3 - horizontal kerning between the two characters in string
      <argument>, or 0 if the string is invalid
  4 - maximum ascent of the font
  5 - maximum descent of the font
  6 - maximum character width (spacing included)

Functions 4-6 will of course ignore the argument, so "" can be used.
Naturally this idea is in its infancy, so any suggestions that could
improve it would be most welcome.

Lummox JR


Post a reply to this message

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