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:
authorCampbell Barton <ideasman42@gmail.com>2014-01-07 13:18:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-07 13:19:20 +0400
commit54ebaad377e70d1ee0270304fd5d0fda2103c800 (patch)
tree041221e4fea38a0f30eab4dc3c4afd5f498db9a5 /source/blender/blenkernel/intern/font.c
parentda16b3000b7c34ff078d66a34a6221bb38d6eca4 (diff)
Text3d: Add support for underline characters with text-on-path
Diffstat (limited to 'source/blender/blenkernel/intern/font.c')
-rw-r--r--source/blender/blenkernel/intern/font.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 454db17b649..d5d57ec616e 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -292,14 +292,14 @@ 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, ListBase *nubase, 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,
+ float rot, int charidx, short mat_nr)
{
Nurb *nu2;
BPoint *bp;
nu2 = (Nurb *) MEM_callocN(sizeof(Nurb), "underline_nurb");
- if (nu2 == NULL) return;
nu2->resolu = cu->resolu;
nu2->bezt = NULL;
nu2->knotsu = nu2->knotsv = NULL;
@@ -313,10 +313,6 @@ static void build_underline(Curve *cu, ListBase *nubase, float x1, float y1, flo
nu2->flagu = CU_NURB_CYCLIC;
bp = (BPoint *)MEM_callocN(4 * sizeof(BPoint), "underline_bp");
- if (bp == NULL) {
- MEM_freeN(nu2);
- return;
- }
copy_v4_fl4(bp[0].vec, x1, y1, 0.0f, 1.0f);
copy_v4_fl4(bp[1].vec, x2, y1, 0.0f, 1.0f);
@@ -326,6 +322,29 @@ static void build_underline(Curve *cu, ListBase *nubase, float x1, float y1, flo
nu2->bp = bp;
BLI_addtail(nubase, nu2);
+ if (rot != 0.0f) {
+ float si, co;
+ int i;
+
+ si = sinf(rot);
+ co = cosf(rot);
+
+ for (i = nu2->pntsu; i > 0; i--) {
+ float *fp;
+ float x, y;
+
+ fp = bp->vec;
+
+ x = fp[0] - x1;
+ y = fp[1] - y1;
+
+ fp[0] = (+co * x + si * y) + x1;
+ fp[1] = (-si * x + co * y) + y1;
+
+ bp++;
+ }
+ }
+
}
static void buildchar(Main *bmain, Curve *cu, ListBase *nubase, unsigned int character, CharInfo *info,
@@ -1049,7 +1068,7 @@ makebreak:
if (cha != '\n' && cha != '\r')
buildchar(bmain, cu, r_nubase, cha, info, ct->xof, ct->yof, ct->rot, i);
- if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) {
+ if ((info->flag & CU_CHINFO_UNDERLINE) && (cha != '\n') && (cha != '\r')) {
float ulwidth, uloverlap = 0.0f;
if ((i < (slen - 1)) && (mem[i + 1] != '\n') && (mem[i + 1] != '\r') &&
@@ -1068,7 +1087,7 @@ makebreak:
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);
+ ct->rot, i, info->mat_nr);
}
ct++;
}