Re: Finding out the appropriate texture size for a font
Sagar Tiwari <[email protected]> Sat, 27 Jul 2024 12:49:20 +0530
| Newsgroups | gmane.comp.fonts.freetype.user |
|---|---|
| Message-ID | <CAJ8WsYOdm=aQ19ANqhgXh+Yn_4MJSzjRO8zLgB1PBD_s8AL1Ag@mail.gmail.com> |
> 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).
This would be good enough for me. I tried it out and found that the value
of bbox is always *{xMin: -1735, yMin: -400, xMax: 695, yMax: 1120}*
regardless of what value I give to *FT_Set_Pixel_Sizes* for the ttf file
I'm using. But increasing the pixel size does increase the output bitmap
size.
> Where do you see that?
This is from the `FT_Set_Pixel_Sizes` api documentation:
> You should not rely on the resulting glyphs matching or being constrained
to this pixel size. Refer to FT_Request_Size to understand how requested
sizes relate to actual sizes.
On Sat, Jul 27, 2024 at 11:57=E2=80=AFAM Werner LEMBERG <[email protected]> wrote:
>
> > 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
>
--=20
Best Regards
Sagar Tiwari