Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/freetypefont.c
| Show First 20 Lines • Show All 475 Lines • ▼ Show 20 Lines | VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf) | ||||
| } | } | ||||
| /* free Freetype */ | /* free Freetype */ | ||||
| FT_Done_FreeType(library); | FT_Done_FreeType(library); | ||||
| return vfd; | return vfd; | ||||
| } | } | ||||
| static void *vfontdata_copy_characters_value_cb(const void *src) { | |||||
| return BLI_vfontchar_copy(src, 0); | |||||
| } | |||||
| VFontData *BLI_vfontdata_copy(const VFontData *vfont_src, const int UNUSED(flag)) | |||||
| { | |||||
| VFontData *vfont_dst = MEM_dupallocN(vfont_src); | |||||
| if (vfont_src->characters != NULL) { | |||||
| vfont_dst->characters = BLI_ghash_copy(vfont_src->characters, NULL, vfontdata_copy_characters_value_cb); | |||||
| } | |||||
| return vfont_dst; | |||||
| } | |||||
| VChar *BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character) | VChar *BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character) | ||||
| { | { | ||||
| VChar *che = NULL; | VChar *che = NULL; | ||||
| if (!vfont) return NULL; | if (!vfont) return NULL; | ||||
| /* Init Freetype */ | /* Init Freetype */ | ||||
| err = FT_Init_FreeType(&library); | err = FT_Init_FreeType(&library); | ||||
| if (err) { | if (err) { | ||||
| /* XXX error("Failed to load the Freetype font library"); */ | /* XXX error("Failed to load the Freetype font library"); */ | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* Load the character */ | /* Load the character */ | ||||
| che = objchr_to_ftvfontdata(vfont, character); | che = objchr_to_ftvfontdata(vfont, character); | ||||
| /* Free Freetype */ | /* Free Freetype */ | ||||
| FT_Done_FreeType(library); | FT_Done_FreeType(library); | ||||
| return che; | return che; | ||||
| } | } | ||||
| /* Yeah, this is very bad... But why is this in BLI in the first place, since it uses Nurb data? | |||||
| * Anyway, do not feel like duplicating whole Nurb copy code here, so unless someone has a better idea... */ | |||||
| #include "../../blenkernel/BKE_curve.h" | |||||
| VChar *BLI_vfontchar_copy(const VChar *vchar_src, const int UNUSED(flag)) | |||||
| { | |||||
| VChar *vchar_dst = MEM_dupallocN(vchar_src); | |||||
| BLI_listbase_clear(&vchar_dst->nurbsbase); | |||||
| BKE_nurbList_duplicate(&vchar_dst->nurbsbase, &vchar_src->nurbsbase); | |||||
| return vchar_dst; | |||||
| } | |||||
| #if 0 | #if 0 | ||||
| /* Freetype2 Outline struct */ | /* Freetype2 Outline struct */ | ||||
| typedef struct FT_Outline_ { | typedef struct FT_Outline_ { | ||||
| short n_contours; /* number of contours in glyph */ | short n_contours; /* number of contours in glyph */ | ||||
| short n_points; /* number of points in the glyph */ | short n_points; /* number of points in the glyph */ | ||||
| ▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines | |||||