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')
-rw-r--r--source/blender/blenkernel/BKE_font.h3
-rw-r--r--source/blender/blenkernel/intern/anim.c4
-rw-r--r--source/blender/blenkernel/intern/displist.c3
-rw-r--r--source/blender/blenkernel/intern/font.c87
-rw-r--r--source/blender/editors/curve/editfont.c4
-rw-r--r--source/blender/editors/object/object_edit.c2
-rw-r--r--source/blender/makesrna/intern/rna_ID.c2
7 files changed, 57 insertions, 48 deletions
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index 8f5ccf1087e..76fc7350d19 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -77,7 +77,8 @@ void BKE_vfont_free(struct VFont *sc);
struct VFont *BKE_vfont_builtin_get(void);
struct VFont *BKE_vfont_load(struct Main *bmain, const char *name);
-struct CharTrans *BKE_vfont_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode);
+bool BKE_vfont_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode,
+ struct CharTrans **r_chartransdata);
int BKE_vfont_select_get(struct Object *ob, int *start, int *end);
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 80890ebb947..7ae7fb3a9a0 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -1613,7 +1613,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int persiste
{
Object *ob, *obar[256] = {NULL};
Curve *cu;
- struct CharTrans *ct, *chartransdata;
+ struct CharTrans *ct, *chartransdata = NULL;
float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof;
int slen, a;
@@ -1624,7 +1624,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int persiste
/* in par the family name is stored, use this to find the other objects */
- chartransdata = BKE_vfont_to_curve(G.main, scene, par, FO_DUPLI);
+ BKE_vfont_to_curve(G.main, scene, par, FO_DUPLI, &chartransdata);
if (chartransdata == NULL) return;
cu = par->data;
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 7ad8e80665e..b9d89be6f9d 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -41,6 +41,7 @@
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_material_types.h"
+#include "DNA_vfont_types.h"
#include "BLI_blenlib.h"
#include "BLI_memarena.h"
@@ -1374,7 +1375,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
ob->curve_cache->path = NULL;
if (ob->type == OB_FONT)
- BKE_vfont_to_curve(G.main, scene, ob, 0);
+ BKE_vfont_to_curve(G.main, scene, ob, FO_EDIT, NULL);
BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(cu));
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 63095091fa6..90362c7a3ad 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -494,7 +494,8 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info)
}
}
-struct CharTrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode)
+bool BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode,
+ struct CharTrans **r_chartransdata)
{
VFont *vfont, *oldvfont;
VFontData *vfd = NULL;
@@ -508,53 +509,56 @@ struct CharTrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int
int i, slen, j;
int curbox;
int selstart, selend;
- int utf8len;
short cnr = 0, lnr = 0, wsnr = 0;
wchar_t *mem, *tmp, ascii;
+ bool ok = false;
/* remark: do calculations including the trailing '\0' of a string
* because the cursor can be at that location */
- if (ob->type != OB_FONT) return NULL;
+ BLI_assert(ob->type == OB_FONT);
/* Set font data */
cu = (Curve *) ob->data;
vfont = cu->vfont;
- if (cu->str == NULL) return NULL;
- if (vfont == NULL) return NULL;
+ if (cu->str == NULL) return ok;
+ if (vfont == NULL) return ok;
- /* Create unicode string */
- utf8len = BLI_strlen_utf8(cu->str);
- mem = MEM_mallocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
+ vfd = vfont_get_data(bmain, vfont);
- slen = BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1);
+ /* The VFont Data can not be found */
+ if (!vfd) return ok;
if (cu->ulheight == 0.0f)
cu->ulheight = 0.05f;
- if (cu->strinfo == NULL) /* old file */
- cu->strinfo = MEM_callocN((slen + 4) * sizeof(CharInfo), "strinfo compat");
-
- custrinfo = cu->strinfo;
- if (cu->editfont)
+ if (cu->editfont) {
+ slen = cu->len;
+ mem = cu->editfont->textbuf;
custrinfo = cu->editfont->textbufinfo;
-
- if (cu->tb == NULL)
- cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "TextBox compat");
+ }
+ else {
+ size_t utf8len;
- vfd = vfont_get_data(bmain, vfont);
+ utf8len = BLI_strlen_utf8(cu->str);
- /* The VFont Data can not be found */
- if (!vfd) {
- if (mem)
- MEM_freeN(mem);
- return NULL;
+ /* Create unicode string */
+ mem = MEM_mallocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
+
+ slen = BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1);
+
+ if (cu->strinfo == NULL) { /* old file */
+ cu->strinfo = MEM_callocN((slen + 4) * sizeof(CharInfo), "strinfo compat");
+ }
+ custrinfo = cu->strinfo;
}
+ if (cu->tb == NULL)
+ cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "TextBox compat");
+
/* calc offset and rotation of each char */
- ct = chartransdata =
- (struct CharTrans *)MEM_callocN((slen + 1) * sizeof(struct CharTrans), "buildtext");
+ ct = chartransdata = MEM_callocN((slen + 1) * sizeof(struct CharTrans), "buildtext");
/* We assume the worst case: 1 character per line (is freed at end anyway) */
@@ -628,10 +632,9 @@ makebreak:
/* No VFont found */
if (vfont == NULL) {
- if (mem)
- MEM_freeN(mem);
MEM_freeN(chartransdata);
- return NULL;
+ chartransdata = NULL;
+ goto finally;
}
if (vfont != oldvfont) {
@@ -641,10 +644,9 @@ makebreak:
/* VFont Data for VFont couldn't be found */
if (!vfd) {
- if (mem)
- MEM_freeN(mem);
MEM_freeN(chartransdata);
- return NULL;
+ chartransdata = NULL;
+ goto finally;
}
twidth = char_width(cu, che, info);
@@ -1010,8 +1012,8 @@ makebreak:
if (mode == FO_SELCHANGE) {
MEM_freeN(chartransdata);
- MEM_freeN(mem);
- return NULL;
+ chartransdata = NULL;
+ goto finally;
}
if (mode == FO_EDIT) {
@@ -1080,14 +1082,19 @@ makebreak:
}
}
- if (mode == FO_DUPLI) {
- MEM_freeN(mem);
- return chartransdata;
- }
+ ok = true;
+
+finally:
- if (mem)
+ if (cu->editfont == NULL)
MEM_freeN(mem);
- MEM_freeN(chartransdata);
- return NULL;
+ if (r_chartransdata) {
+ *r_chartransdata = chartransdata;
+ }
+ else {
+ MEM_freeN(chartransdata);
+ }
+
+ return ok;
}
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 59075d44c67..6bb6b286047 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -288,7 +288,7 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re
if (mode == FO_EDIT)
update_string(cu);
- BKE_vfont_to_curve(bmain, scene, obedit, mode);
+ BKE_vfont_to_curve(bmain, scene, obedit, mode, NULL);
if (recalc)
DAG_id_tag_update(obedit->data, 0);
@@ -955,7 +955,7 @@ static int move_cursor(bContext *C, int type, int select)
struct Main *bmain = CTX_data_main(C);
cu->selstart = cu->selend = 0;
update_string(cu);
- BKE_vfont_to_curve(bmain, scene, obedit, FO_SELCHANGE);
+ BKE_vfont_to_curve(bmain, scene, obedit, FO_SELCHANGE, NULL);
}
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index dc641dbe765..4dc9c6a2a9d 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -931,7 +931,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
cu1->vfontbi = cu->vfontbi;
id_us_plus((ID *)cu1->vfontbi);
- BKE_vfont_to_curve(bmain, scene, base->object, 0); /* needed? */
+ BKE_vfont_to_curve(bmain, scene, base->object, FO_EDIT, NULL); /* needed? */
BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family));
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 075f852a032..a36bd8e27c2 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -280,7 +280,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag)
if (ob->type == OB_FONT) {
Curve *cu = ob->data;
freedisplist(&cu->disp);
- BKE_vfont_to_curve(sce, ob, CU_LEFT);
+ BKE_vfont_to_curve(bmain, sce, ob, FO_EDIT, NULL);
}
#endif