BLF: Fix FT_Get_Advance Wrong Value Without Size

Fix possibility of getting invalid fixed-pitch advance size.

See D15735 for more details.

Differential Revision: https://developer.blender.org/D15735

Own Code.
This commit is contained in:
Harley Acheson 2022-08-19 17:16:22 -07:00
parent 3a1ae5a02a
commit acf083a5bf
Notes: blender-bot 2023-02-13 14:09:53 +01:00
Referenced by issue #102238, Geometry Node: Memory leak -> EXCEPTION_ACCESS_VIOLATION -> EXCEPTION_INT_DIVIDE_BY_ZERO.
Referenced by issue #102066, Blender is no longer able to export .gltf objects with tangents
1 changed files with 2 additions and 1 deletions

View File

@ -96,6 +96,8 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font)
memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table));
memset(gc->bucket, 0, sizeof(gc->bucket));
blf_ensure_size(font);
/* Determine ideal fixed-width size for monospaced output. */
FT_UInt gindex = blf_get_char_index(font, U'0');
if (gindex && font->face) {
@ -106,7 +108,6 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font)
}
else {
/* Font does not have a face or does not contain "0" so use CSS fallback of 1/2 of em. */
blf_ensure_size(font);
gc->fixed_width = (int)((font->ft_size->metrics.height / 2) >> 6);
}
if (gc->fixed_width < 1) {