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:
Diffstat (limited to 'source/blender/blenkernel/intern/font.c')
-rw-r--r--source/blender/blenkernel/intern/font.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index fc11b3d234d..2a2547fd839 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -73,6 +73,8 @@
struct SelBox *selboxes= NULL;
+static ListBase ttfdata= {NULL, NULL};
+
/* UTF-8 <-> wchar transformations */
void
chtoutf8(unsigned long c, char *o)
@@ -253,22 +255,46 @@ static PackedFile *get_builtin_packedfile(void)
}
}
-static VFontData *vfont_get_data(VFont *vfont)
+void free_ttfont(void)
+{
+ struct TmpFont *tf;
+
+ tf= ttfdata.first;
+ while(tf) {
+ freePackedFile(tf->pf);
+ tf->pf= NULL;
+ tf->vfont= NULL;
+ tf= tf->next;
+ }
+ BLI_freelistN(&ttfdata);
+}
+
+struct TmpFont *vfont_find_tmpfont(VFont *vfont)
{
struct TmpFont *tmpfnt = NULL;
- PackedFile *tpf;
if(vfont==NULL) return NULL;
// Try finding the font from font list
- tmpfnt = G.ttfdata.first;
-
+ tmpfnt = ttfdata.first;
while(tmpfnt)
{
if(tmpfnt->vfont == vfont)
break;
tmpfnt = tmpfnt->next;
}
+ return tmpfnt;
+}
+
+static VFontData *vfont_get_data(VFont *vfont)
+{
+ struct TmpFont *tmpfnt = NULL;
+ PackedFile *tpf;
+
+ if(vfont==NULL) return NULL;
+
+ // Try finding the font from font list
+ tmpfnt = vfont_find_tmpfont(vfont);
// And then set the data
if (!vfont->data) {
@@ -292,7 +318,7 @@ static VFontData *vfont_get_data(VFont *vfont)
tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
tmpfnt->pf= tpf;
tmpfnt->vfont= vfont;
- BLI_addtail(&G.ttfdata, tmpfnt);
+ BLI_addtail(&ttfdata, tmpfnt);
}
} else {
pf= newPackedFile(vfont->name);
@@ -305,7 +331,7 @@ static VFontData *vfont_get_data(VFont *vfont)
tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
tmpfnt->pf= tpf;
tmpfnt->vfont= vfont;
- BLI_addtail(&G.ttfdata, tmpfnt);
+ BLI_addtail(&ttfdata, tmpfnt);
}
}
if(!pf) {
@@ -385,7 +411,7 @@ VFont *load_vfont(char *name)
tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
tmpfnt->pf= tpf;
tmpfnt->vfont= vfont;
- BLI_addtail(&G.ttfdata, tmpfnt);
+ BLI_addtail(&ttfdata, tmpfnt);
}
}