[Bf-blender-cvs] [19202736d51] blender-v3.3-release: Fix T99872: Crash Loading Embedded Fonts - 3.3
Harley Acheson
noreply at git.blender.org
Wed Nov 9 09:43:21 CET 2022
Commit: 19202736d51679e3669e75e53780e6aeb4924303
Author: Harley Acheson
Date: Wed Nov 9 09:27:59 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB19202736d51679e3669e75e53780e6aeb4924303
Fix T99872: Crash Loading Embedded Fonts - 3.3
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
===================================================================
M source/blender/blenfont/intern/blf_font.c
===================================================================
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;
}
More information about the Bf-blender-cvs
mailing list