diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_font.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/font.c | 29 |
3 files changed, 29 insertions, 13 deletions
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h index 85aaafda39f..199b19402aa 100644 --- a/source/blender/blenkernel/BKE_font.h +++ b/source/blender/blenkernel/BKE_font.h @@ -83,6 +83,9 @@ 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); +bool BKE_vfont_to_curve_nubase(struct Main *bmain, struct Scene *scene, struct Object *ob, + struct ListBase *nubase, int mode, struct CharTrans **r_chartransdata); + bool BKE_vfont_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode, struct CharTrans **r_chartransdata); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index b9d89be6f9d..4282e860c4e 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1374,10 +1374,12 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (ob->curve_cache->path) free_path(ob->curve_cache->path); ob->curve_cache->path = NULL; - if (ob->type == OB_FONT) - BKE_vfont_to_curve(G.main, scene, ob, FO_EDIT, NULL); - - BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(cu)); + if (ob->type == OB_FONT) { + BKE_vfont_to_curve_nubase(G.main, scene, ob, &nubase, FO_EDIT, NULL); + } + else { + BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(cu)); + } if (!forOrco) curve_calc_modifiers_pre(scene, ob, &nubase, forRender, renderResolution); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 556e9dc8c37..2a5f8cb8041 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -293,7 +293,7 @@ static VChar *find_vfont_char(VFontData *vfd, unsigned int character) return BLI_ghash_lookup(vfd->characters, SET_UINT_IN_POINTER(character)); } -static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, int charidx, short mat_nr) +static void build_underline(Curve *cu, ListBase *nubase, float x1, float y1, float x2, float y2, int charidx, short mat_nr) { Nurb *nu2; BPoint *bp; @@ -324,11 +324,11 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i copy_v4_fl4(bp[3].vec, x1, y2, 0.0f, 1.0f); nu2->bp = bp; - BLI_addtail(&(cu->nurb), nu2); + BLI_addtail(nubase, nu2); } -static void buildchar(Main *bmain, Curve *cu, unsigned int character, CharInfo *info, +static void buildchar(Main *bmain, Curve *cu, ListBase *nubase, unsigned int character, CharInfo *info, float ofsx, float ofsy, float rot, int charidx) { BezTriple *bezt1, *bezt2; @@ -450,7 +450,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned int character, CharInfo * bezt2++; } - BLI_addtail(&(cu->nurb), nu2); + BLI_addtail(nubase, nu2); } nu1 = nu1->next; @@ -495,8 +495,8 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info) } } -bool BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode, - struct CharTrans **r_chartransdata) +bool BKE_vfont_to_curve_nubase(Main *bmain, Scene *scene, Object *ob, ListBase *nubase, + int mode, struct CharTrans **r_chartransdata) { Curve *cu = ob->data; EditFont *ef = cu->editfont; @@ -1020,7 +1020,7 @@ makebreak: if (mode == FO_EDIT) { /* make nurbdata */ - BKE_nurbList_free(&cu->nurb); + BKE_nurbList_free(nubase); ct = chartransdata; for (i = 0; i < slen; i++) { @@ -1037,7 +1037,7 @@ makebreak: } /* We do not want to see any character for \n or \r */ if (cha != '\n' && cha != '\r') - buildchar(bmain, cu, cha, info, ct->xof, ct->yof, ct->rot, i); + buildchar(bmain, cu, nubase, cha, info, ct->xof, ct->yof, ct->rot, i); if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) { float ulwidth, uloverlap = 0.0f; @@ -1054,7 +1054,8 @@ makebreak: twidth = char_width(cu, che, info); ulwidth = cu->fsize * ((twidth * (1.0f + (info->kern / 40.0f))) + uloverlap); - build_underline(cu, ct->xof * cu->fsize, ct->yof * cu->fsize + (cu->ulpos - 0.05f) * cu->fsize, + build_underline(cu, nubase, + ct->xof * cu->fsize, ct->yof * cu->fsize + (cu->ulpos - 0.05f) * cu->fsize, ct->xof * cu->fsize + ulwidth, ct->yof * cu->fsize + (cu->ulpos - 0.05f) * cu->fsize - cu->ulheight * cu->fsize, i, info->mat_nr); @@ -1081,3 +1082,13 @@ finally: return ok; } + +bool BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode, + struct CharTrans **r_chartransdata) +{ + Curve *cu = (Curve *) ob->data; + + BLI_assert(ob->type == OB_FONT); + + return BKE_vfont_to_curve_nubase(bmain, scene, ob, &cu->nurb, mode, r_chartransdata); +} |