diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-12-19 17:08:29 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-12-19 17:55:56 +0300 |
commit | 7e8525663c71aa350c00b17b6150e40134c3e467 (patch) | |
tree | f6b7beeecffb558586e0b5d4bcc8dba4a4528085 /source/blender/blenkernel/intern/font.c | |
parent | ab1af38c74a5f20115e14fdd54d7580df380a924 (diff) |
Font objects: Support proper auto-space
Annoyingly, need to convert vfont to nurbs, do minmax and toss nurbs away.
This is likely to be fine, since this function is not intended to be used
a lot, and this is the only way to get more meaningful result.
However, it's not very clear what to do with font on curve.
This fixes rendering of font object with auto texture space in Cycles
introduced in c34f3c7.
It is probably possible to introduce new mode to vfont_to_curve which
will do boundbox without extra allocations, but that's more like an
optimization.
Reviewers: campbellbarton, mano-wii
Reviewed By: campbellbarton
Subscribers: zeauro
Differential Revision: https://developer.blender.org/D2971
Diffstat (limited to 'source/blender/blenkernel/intern/font.c')
-rw-r--r-- | source/blender/blenkernel/intern/font.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index d6b28cfaf70..ef479d77915 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -635,11 +635,10 @@ struct TempLineInfo { int wspace_nr; /* number of whitespaces of line */ }; -bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, int mode, ListBase *r_nubase, +bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, Curve *cu, int mode, ListBase *r_nubase, const wchar_t **r_text, int *r_text_len, bool *r_text_free, struct CharTrans **r_chartransdata) { - Curve *cu = ob->data; EditFont *ef = cu->editfont; EditFontSelBox *selboxes = NULL; VFont *vfont, *oldvfont; @@ -670,7 +669,7 @@ bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, int mode, ListBase *r_nubase /* remark: do calculations including the trailing '\0' of a string * because the cursor can be at that location */ - BLI_assert(ob->type == OB_FONT); + BLI_assert(ob == NULL || ob->type == OB_FONT); /* Set font data */ vfont = cu->vfont; @@ -708,7 +707,7 @@ bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, int mode, ListBase *r_nubase if (cu->tb == NULL) cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "TextBox compat"); - if (ef) { + if (ef != NULL && ob != NULL) { if (ef->selboxes) MEM_freeN(ef->selboxes); @@ -1258,7 +1257,7 @@ makebreak: cha = towupper(cha); } - if (info->mat_nr > (ob->totcol)) { + if (ob == NULL || info->mat_nr > (ob->totcol)) { /* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */ info->mat_nr = 0; } @@ -1334,7 +1333,7 @@ bool BKE_vfont_to_curve_nubase(Main *bmain, Object *ob, int mode, ListBase *r_nu { BLI_assert(ob->type == OB_FONT); - return BKE_vfont_to_curve_ex(bmain, ob, mode, r_nubase, + return BKE_vfont_to_curve_ex(bmain, ob, ob->data, mode, r_nubase, NULL, NULL, NULL, NULL); } @@ -1342,7 +1341,7 @@ bool BKE_vfont_to_curve(Main *bmain, Object *ob, int mode) { Curve *cu = ob->data; - return BKE_vfont_to_curve_ex(bmain, ob, mode, &cu->nurb, NULL, NULL, NULL, NULL); + return BKE_vfont_to_curve_ex(bmain, ob, ob->data, mode, &cu->nurb, NULL, NULL, NULL, NULL); } |