nanovg icon indicating copy to clipboard operation
nanovg copied to clipboard

FONS_GLYPH_BITMAP_OPTIONAL doesn't inhibit FT_LOAD in fons__tt_buildGlyphBitmap

Open mulle-nat opened this issue 1 year ago • 0 comments

nanovg uses the FONS_GLYPH_BITMAP_OPTIONAL flag in various places to avoid the creation of superflous font atlas entries for glyphs. The actual glyph information is queried by fons__tt_buildGlyphBitmap , which always uses FT_LOAD_RENDER to render a (then unneeded) bitmap though. This is probably expensive and could be avoided, by passing an extra parameter to fons__tt_buildGlyphBitmap, telling FreeType not to.

fontstash.h:

	ftError = FT_Load_Glyph(font->font, glyph, FT_LOAD_RENDER | FT_LOAD_FORCE_AUTOHINT | FT_LOAD_TARGET_LIGHT);
	if (ftError) return 0;

The same should be done for stb_truetype (or could be harmlessly ignored, if not supported there).

mulle-nat avatar Aug 04 '22 12:08 mulle-nat