Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarley Acheson <harley.acheson@gmail.com>2022-10-06 20:35:36 +0300
committerHarley Acheson <harley.acheson@gmail.com>2022-10-06 20:36:57 +0300
commitbe8ee05dcba6987fd4098cc61d414b0b8cef4b3e (patch)
tree25dfd30001997ecc97d814a9034aab2bd2d71273
parentc592bff0474548d69b3d1a63b05c670c4f499727 (diff)
Fix for T53332: BFont 43 Inaccessible Glyphs
Preloading of BFont (default for 3D Text Objects) glyphs will not load any with a character code greater than 256, resulting in 43 characters that are inaccessible. This patch corrects that preloading code. See D16122 for more details Differential Revision: https://developer.blender.org/D16122 Reviewed by Campbell Barton
-rw-r--r--source/blender/blenkernel/intern/vfontdata_freetype.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c b/source/blender/blenkernel/intern/vfontdata_freetype.c
index 30e5f29e6a8..91ca3100f8c 100644
--- a/source/blender/blenkernel/intern/vfontdata_freetype.c
+++ b/source/blender/blenkernel/intern/vfontdata_freetype.c
@@ -270,9 +270,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
{
/* Variables */
FT_Face face;
- const FT_ULong charcode_reserve = 256;
- FT_ULong charcode = 0, lcode;
- FT_UInt glyph_index;
VFontData *vfd;
/* load the freetype font */
@@ -305,9 +302,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
return NULL;
}
- /* Extract the first 256 character from TTF */
- lcode = charcode = FT_Get_First_Char(face, &glyph_index);
-
/* Blender default BFont is not "complete". */
const bool complete_font = (face->ascender != 0) && (face->descender != 0) &&
(face->ascender != face->descender);
@@ -335,21 +329,19 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
vfd->scale = 1.0f / 1000.0f;
}
- /* Load characters */
- vfd->characters = BLI_ghash_int_new_ex(__func__, charcode_reserve);
+ /* Load the first 256 glyphs. */
- while (charcode < charcode_reserve) {
- /* Generate the font data */
- freetypechar_to_vchar(face, charcode, vfd);
+ const FT_ULong preload_count = 256;
+ vfd->characters = BLI_ghash_int_new_ex(__func__, preload_count);
- /* Next glyph */
+ FT_ULong charcode = 0;
+ FT_UInt glyph_index;
+ for (int i = 0; i < preload_count; i++) {
charcode = FT_Get_Next_Char(face, charcode, &glyph_index);
-
- /* Check that we won't start infinite loop */
- if (charcode <= lcode) {
+ if (!charcode || !glyph_index) {
break;
}
- lcode = charcode;
+ freetypechar_to_vchar(face, charcode, vfd);
}
return vfd;