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 16:04:47 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-07 16:04:47 +0400
commit2328f94e1d9291233defafae62be2d1c372be985 (patch)
tree40d771413eb4a5108d435e0d69060fc9a87b7abf /source/blender/blenkernel/intern/font.c
parentebf23b51448e4bc9c67d656093ecc01be882c9d3 (diff)
Text3d: underline offset on curved path wasnt working right
Diffstat (limited to 'source/blender/blenkernel/intern/font.c')
-rw-r--r--source/blender/blenkernel/intern/font.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index d5d57ec616e..a31d3dedb7a 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -293,8 +293,8 @@ 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,
- float rot, int charidx, short mat_nr)
+static void build_underline(Curve *cu, ListBase *nubase, const rctf *rect,
+ float yofs, float rot, int charidx, short mat_nr)
{
Nurb *nu2;
BPoint *bp;
@@ -314,10 +314,10 @@ static void build_underline(Curve *cu, ListBase *nubase, float x1, float y1, flo
bp = (BPoint *)MEM_callocN(4 * sizeof(BPoint), "underline_bp");
- copy_v4_fl4(bp[0].vec, x1, y1, 0.0f, 1.0f);
- copy_v4_fl4(bp[1].vec, x2, y1, 0.0f, 1.0f);
- copy_v4_fl4(bp[2].vec, x2, y2, 0.0f, 1.0f);
- copy_v4_fl4(bp[3].vec, x1, y2, 0.0f, 1.0f);
+ copy_v4_fl4(bp[0].vec, rect->xmin, (rect->ymin + yofs), 0.0f, 1.0f);
+ copy_v4_fl4(bp[1].vec, rect->xmax, (rect->ymin + yofs), 0.0f, 1.0f);
+ copy_v4_fl4(bp[2].vec, rect->xmax, (rect->ymax + yofs), 0.0f, 1.0f);
+ copy_v4_fl4(bp[3].vec, rect->xmin, (rect->ymax + yofs), 0.0f, 1.0f);
nu2->bp = bp;
BLI_addtail(nubase, nu2);
@@ -335,16 +335,20 @@ static void build_underline(Curve *cu, ListBase *nubase, float x1, float y1, flo
fp = bp->vec;
- x = fp[0] - x1;
- y = fp[1] - y1;
+ x = fp[0] - rect->xmin;
+ y = fp[1] - rect->ymin;
- fp[0] = (+co * x + si * y) + x1;
- fp[1] = (-si * x + co * y) + y1;
+ fp[0] = (+co * x + si * y) + rect->xmin;
+ fp[1] = (-si * x + co * y) + rect->ymin;
bp++;
}
}
+ mul_v2_fl(bp[0].vec, cu->fsize);
+ mul_v2_fl(bp[1].vec, cu->fsize);
+ mul_v2_fl(bp[2].vec, cu->fsize);
+ mul_v2_fl(bp[3].vec, cu->fsize);
}
static void buildchar(Main *bmain, Curve *cu, ListBase *nubase, unsigned int character, CharInfo *info,
@@ -1070,6 +1074,7 @@ makebreak:
if ((info->flag & CU_CHINFO_UNDERLINE) && (cha != '\n') && (cha != '\r')) {
float ulwidth, uloverlap = 0.0f;
+ rctf rect;
if ((i < (slen - 1)) && (mem[i + 1] != '\n') && (mem[i + 1] != '\r') &&
((mem[i + 1] != ' ') || (custrinfo[i + 1].flag & CU_CHINFO_UNDERLINE)) &&
@@ -1082,11 +1087,16 @@ makebreak:
che = find_vfont_char(vfd, cha);
twidth = char_width(cu, che, info);
- ulwidth = cu->fsize * ((twidth * (1.0f + (info->kern / 40.0f))) + uloverlap);
+ ulwidth = (twidth * (1.0f + (info->kern / 40.0f))) + uloverlap;
+
+ rect.xmin = ct->xof;
+ rect.xmax = rect.xmin + ulwidth;
+
+ rect.ymin = ct->yof;
+ rect.ymax = rect.ymin - cu->ulheight;
+
build_underline(cu, r_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,
+ &rect, cu->ulpos - 0.05f,
ct->rot, i, info->mat_nr);
}
ct++;