freetype
[Top][All Lists]
Advanced

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

Re: [ft] Help with making sure all characters fit in Certain pixel dimen


From: Lawrence D'Oliveiro
Subject: Re: [ft] Help with making sure all characters fit in Certain pixel dimensions
Date: Fri, 26 Jun 2015 10:34:05 +1200

On Thu, 25 Jun 2015 16:10:06 -0500, Shomari Sharpe wrote:

> I'm creating an font system that uses bitmap fonts generated from
> freetype to be used in my game engine. It appears that even though I
> have specified a pixel size of 64px there are characters that are
> rendered outside the actual pixel size I have specified though the
> actual FT_Face->Glyph->Bitmap is actually smaller the 64px. There
> also seems to be a big gap of approximately 12px above glyphs.

The interpretation of the “size” of the font is very much up to the
font designer. Looking at the bitmap you supplied, the baseline of the
text is situated 64 pixels from the top of the image. But you forgot to
take into account descenders--those characters that extend below the
baseline.

If you want text to fit into an exact cell size, I would suggest
rendering all the needed glyphs into a larger image while measuring
them individually, to find the largest extents. Then use those largest
extents to compute a scale factor to shrink them all down uniformly to
fit into the desired cell dimensions.

The result will probably not look as good as the font designer intended.



reply via email to

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