freetype
[Top][All Lists]
Advanced

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

Re: Finding out the appropriate texture size for a font


From: Werner LEMBERG
Subject: Re: Finding out the appropriate texture size for a font
Date: Sat, 27 Jul 2024 06:27:18 +0000 (UTC)

> In my program I have a texture array where I want to cache the
> rasterized bitmaps for the characters.  This texture array will need
> to be big enough to accommodate the widest and tallest characters in
> the font.  How do I calculate the appropriate size for this texture.
> I'm using `FT_Set_Pixel_Size` to size the characters but the width
> and height of the rendered bitmaps is often bigger than the provided
> size, which matches what the documentation of this function says.

If you really need the tightest bitmap box that fits all glyphs of a
font for a given size, the only choice you have to do this reliably is
to render *all* glyphs and measure the bitmap dimensions.

If you can loosen this restriction you might use the font's global
bounding box (`FT_Face::bbox`) plus some pixels added for both the x
and y directions (to accommodate for hinting).

> It also says I need to use `FT_Request_Size` but I'm unable to
> understand how to use it.

Where do you see that?  AFAICS, the documentation only says that
`FT_Set_Char_Size` and `FT_Set_Pixel_Sizes` call the lower-level
`FT_Request_size` function.


    Werner



reply via email to

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