diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-12-28 10:33:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-12-28 10:40:13 +0400 |
commit | 961d0409c89dff01fd4c2c5f9d6e0406068e7552 (patch) | |
tree | 00916af7b8c2cdbce51c1c67349a1fcd4482a76b /source/blender/blenlib/intern/freetypefont.c | |
parent | 2b3fc4dea7d9928206da639cfc550b0f62377cb6 (diff) |
3D Text: use ghash for character lookups
Diffstat (limited to 'source/blender/blenlib/intern/freetypefont.c')
-rw-r--r-- | source/blender/blenlib/intern/freetypefont.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 4f703d2d148..9cd0bf01856 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -50,6 +50,7 @@ #include "BLI_utildefines.h" #include "BLI_vfontdata.h" #include "BLI_listbase.h" +#include "BLI_ghash.h" #include "BLI_string.h" #include "BLI_math.h" @@ -100,7 +101,6 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf /* First we create entry for the new character to the character list */ che = (VChar *) MEM_callocN(sizeof(struct VChar), "objfnt_char"); - BLI_addtail(&vfd->characters, che); /* Take some data for modifying purposes */ glyph = face->glyph; @@ -110,8 +110,10 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf che->index = charcode; che->width = glyph->advance.x * scale; + BLI_ghash_insert(vfd->characters, SET_UINT_IN_POINTER(che->index), che); + /* Start converting the FT data */ - npoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "endpoints"); + npoints = (int *)MEM_mallocN((ftoutline.n_contours) * sizeof(int), "endpoints"); onpoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "onpoints"); /* calculate total points of each contour */ @@ -319,6 +321,7 @@ 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; const char *fontname; @@ -393,7 +396,9 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) } /* Load characters */ - while (charcode < 256) { + vfd->characters = BLI_ghash_int_new_ex(__func__, charcode_reserve); + + while (charcode < charcode_reserve) { /* Generate the font data */ freetypechar_to_vchar(face, charcode, vfd); |