freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Freetype] Font bounding box?


From: henry . maddocks
Subject: Re: [Freetype] Font bounding box?
Date: Thu, 25 Oct 2001 09:05:53 +1300

On Thursday, October 25, 2001, at 01:33 AM, Marcelo E. Magallon wrote:

I'm implementing a text rasterizer on top of OpenGL and I want to use
FreeType in order to load fonts (yes, I know about gltt, *that's* why
I'm doing this). At the momemt I'm just learning about FreeType and
trying to figure out an efficient way of supporting what I'd like to
do.

Have you had a look at FTGL.

http://homepages.paradise.net.nz/henryj/code/index.html

There is code in there that implements texture fonts which might be helpful...

Basically my problem

<snip>

and the result should be pixels, is that right? (My guess is not,
because it's not working as I expect).


I had some problems with this also. Initially I used the scaled height and width but there is no guarantee that the glyph wont extend outside these bounds so I changed to the bounding box. But there are still some things to watch...
non scalable fonts don't have a bounding box so you have to revert to height and width
Some font formats have there bbox stored incorrectly. The bbox is supposed to be in font units but sometimes it's stored in 16.16 fixed float. I'm not sure if this has been fixed in 2.0.5

Anyway here's the current version of my function to calculate the height.

int FTSize::Height() const
{
if( FT_IS_SCALABLE((*ftFace)))
{
float height;
if( FT_IS_SFNT((*ftFace))) // Don't think this is correct
{
height = (*ftFace)->bbox.yMax - (*ftFace)->bbox.yMin; // bbox.yMax-bbox.yMin
}
else
{
height = (*ftFace)->bbox.yMax - (*ftFace)->bbox.yMin >> 16; // bbox.yMax-bbox.yMin
}

height = height * ( (float)ftSize->metrics.y_ppem / (float)(*ftFace)->units_per_EM);
return static_cast<int>(height);
}
else
{
return ftSize->metrics.height >> 6;
}
}


And by the way... "the result should be pixels" It depends what you mean by pixels. Texels yes, screen pixels not necessarily.


The other thing I noticed is that the advance is not constant, which I
kinda expected for monospaced fonts... what did I miss?

Sorry, can't help with this one. I jumped straight in and implemented all fonts.

Henry


"A lack of planning on your part doesn't constitute a crisis on mine."
reply via email to

[Prev in Thread] Current Thread [Next in Thread]