diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/font.c | 26 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_vfontdata.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/freetypefont.c | 38 |
3 files changed, 34 insertions, 32 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 0839ed82a8d..40da6e01d4c 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -524,10 +524,7 @@ struct CharTrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int utf8len = BLI_strlen_utf8(cu->str); mem = MEM_mallocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem"); - BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1); - - /* Count the wchar_t string length */ - slen = wcslen(mem); + slen = BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1); if (cu->ulheight == 0.0f) cu->ulheight = 0.05f; @@ -597,20 +594,19 @@ makebreak: if (vfont == NULL) break; - che = find_vfont_char(vfd, ascii); + if (i != slen) { + che = find_vfont_char(vfd, ascii); - /* - * The character wasn't in the current curve base so load it - * But if the font is built-in then do not try loading since - * whole font is in the memory already - */ - if (che == NULL && BKE_vfont_is_builtin(vfont) == FALSE) { - BLI_vfontchar_from_freetypefont(vfont, ascii); + /* + * The character wasn't in the current curve base so load it + * But if the font is built-in then do not try loading since + * whole font is in the memory already + */ + if (che == NULL && BKE_vfont_is_builtin(vfont) == false) { + che = BLI_vfontchar_from_freetypefont(vfont, ascii); + } } - /* Try getting the character again from the list */ - che = find_vfont_char(vfd, ascii); - /* No VFont found */ if (vfont == NULL) { if (mem) diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h index 9130061c53e..cb41fe488db 100644 --- a/source/blender/blenlib/BLI_vfontdata.h +++ b/source/blender/blenlib/BLI_vfontdata.h @@ -52,7 +52,7 @@ typedef struct VChar { VFontData *BLI_vfontdata_from_freetypefont(struct PackedFile *pf); -int BLI_vfontchar_from_freetypefont(struct VFont *vfont, unsigned long character); +VChar *BLI_vfontchar_from_freetypefont(struct VFont *vfont, unsigned long character); #endif diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 9cd0bf01856..f9e09abef54 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -63,7 +63,7 @@ static FT_Library library; static FT_Error err; -static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd) +static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd) { const float eps = 0.0001f; const float eps_sq = eps * eps; @@ -287,11 +287,17 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } if (npoints) MEM_freeN(npoints); if (onpoints) MEM_freeN(onpoints); + + return che; } + + return NULL; } -static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) +static VChar *objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) { + VChar *che; + /* Freetype2 */ FT_Face face; @@ -302,18 +308,20 @@ static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) vfont->temp_pf->size, 0, &face); - if (err) return FALSE; + if (err) { + return NULL; + } } else { err = TRUE; - return FALSE; + return NULL; } - + /* Read the char */ - freetypechar_to_vchar(face, charcode, vfont->data); - + che = freetypechar_to_vchar(face, charcode, vfont->data); + /* And everything went ok */ - return TRUE; + return che; } @@ -508,28 +516,26 @@ VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf) return vfd; } -int BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character) +VChar *BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character) { - int success = FALSE; + VChar *che = NULL; - if (!vfont) return FALSE; + if (!vfont) return NULL; /* Init Freetype */ err = FT_Init_FreeType(&library); if (err) { /* XXX error("Failed to load the Freetype font library"); */ - return 0; + return NULL; } /* Load the character */ - success = objchr_to_ftvfontdata(vfont, character); - if (success == FALSE) return FALSE; + che = objchr_to_ftvfontdata(vfont, character); /* Free Freetype */ FT_Done_FreeType(library); - /* Ahh everything ok */ - return TRUE; + return che; } #if 0 |