diff options
author | Harley Acheson <harley> | 2022-11-09 11:27:59 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2022-11-09 11:41:57 +0300 |
commit | 19202736d51679e3669e75e53780e6aeb4924303 (patch) | |
tree | baf07be5feb30fa126af2044c4cb82b5d5f11cb7 /source/blender/blenfont/intern/blf_font.c | |
parent | e86b5230ca997b0c955c0114bc94d5d6f7a58614 (diff) |
Fix T99872: Crash Loading Embedded Fonts - 3.3blender-v3.3-release
Ensure kerning cache exists when loading embedded fonts
---
When loading embedded fonts from memory the font->kerning_cache is not
created and so we get a crash if the font does support kerning.
This was not caught because the loading of packed fonts was not
actually doing anything in VSE until {523bc981cfee}.
We have since consolidated `blf_font_new` and `blf_font_new_from_mem`
into a single function so that they cannot get out of sync like this
any more. So this fix is specific to Blender 3.3. But we can add this
as a candidate for corrective release 3.2.3
Reviewed By: brecht
Maniphest Tasks: T99872
Differential Revision: https://developer.blender.org/D15704
Diffstat (limited to 'source/blender/blenfont/intern/blf_font.c')
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 038e73cc928..07d19f307a2 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1356,13 +1356,24 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m return NULL; } + font->name = BLI_strdup(name); + font->filepath = NULL; + blf_font_fill(font); + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { FT_Get_MM_Var(font->face, &(font->variations)); } - font->name = BLI_strdup(name); - font->filepath = NULL; - blf_font_fill(font); + if (FT_HAS_KERNING(font->face)) { + /* Create kerning cache table and fill with value indicating "unset". */ + font->kerning_cache = MEM_mallocN(sizeof(KerningCacheBLF), __func__); + for (uint i = 0; i < KERNING_CACHE_TABLE_SIZE; i++) { + for (uint j = 0; j < KERNING_CACHE_TABLE_SIZE; j++) { + font->kerning_cache->ascii_table[i][j] = KERNING_ENTRY_UNSET; + } + } + } + return font; } |