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>2010-07-14 02:21:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-07-14 02:21:59 +0400
commit03e638d1285b2a26902230772ae9261406fd6658 (patch)
tree44334ffbbe2cc7917c14fa24c244652e88f2a5f5 /source/blender/blenkernel/intern/font.c
parentc5d6665cb3965cde556e58b182070a41a3956732 (diff)
- make duplis real wasnt redrawing
- small caps option for titles (doing manually is quite painful to watch).
Diffstat (limited to 'source/blender/blenkernel/intern/font.c')
-rw-r--r--source/blender/blenkernel/intern/font.c65
1 files changed, 47 insertions, 18 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 01f2b57de71..d07bd2ba8e5 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -1,4 +1,4 @@
-/* font.c
+/* font.c
*
*
* $Id$
@@ -34,6 +34,7 @@
#include <math.h>
#include <stdlib.h>
#include <wchar.h>
+#include <wctype.h>
#include "MEM_guardedalloc.h"
@@ -597,9 +598,23 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
}
bezt2 = nu2->bezt;
+ if(info->flag & CU_SMALLCAPS) {
+ const float sca= cu->smallcaps_scale;
+ for (i= nu2->pntsu; i > 0; i--) {
+ fp= bezt2->vec[0];
+ fp[0] *= sca;
+ fp[1] *= sca;
+ fp[3] *= sca;
+ fp[4] *= sca;
+ fp[6] *= sca;
+ fp[7] *= sca;
+ bezt2++;
+ }
+ }
+ bezt2 = nu2->bezt;
+
for (i= nu2->pntsu; i > 0; i--) {
fp= bezt2->vec[0];
-
fp[0]= (fp[0]+ofsx)*fsize;
fp[1]= (fp[1]+ofsy)*fsize;
fp[3]= (fp[3]+ofsx)*fsize;
@@ -635,6 +650,20 @@ int BKE_font_getselection(Object *ob, int *start, int *end)
}
}
+static float char_width(Curve *cu, VChar *che, CharInfo *info)
+{
+ // The character wasn't found, propably ascii = 0, then the width shall be 0 as well
+ if(che == NULL) {
+ return 0.0f;
+ }
+ else if(info->flag & CU_SMALLCAPS) {
+ return che->width * cu->smallcaps_scale;
+ }
+ else {
+ return che->width;
+ }
+}
+
struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
{
VFont *vfont, *oldvfont;
@@ -729,8 +758,18 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
makebreak:
// Characters in the list
che = vfd->characters.first;
- ascii = mem[i];
info = &(custrinfo[i]);
+ ascii = mem[i];
+ if(info->flag & CU_SMALLCAPS) {
+ ascii = towupper(ascii);
+ if(mem[i] != ascii) {
+ mem[i]= ascii;
+ }
+ else {
+ info->flag &= ~CU_SMALLCAPS; /* could have a different way to not scale caps */
+ }
+ }
+
vfont = which_vfont(cu, info);
if(vfont==NULL) break;
@@ -780,11 +819,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
return 0;
}
- // The character wasn't found, propably ascii = 0, then the width shall be 0 as well
- if(!che)
- twidth = 0;
- else
- twidth = che->width;
+ twidth = char_width(cu, che, info);
// Calculate positions
if((tb->w != 0.0) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w) {
@@ -881,10 +916,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
else wsfac = 1.0;
// Set the width of the character
- if(!che)
- twidth = 0;
- else
- twidth = che->width;
+ twidth = char_width(cu, che, info);
xof += (twidth*wsfac*(1.0+(info->kern/40.0)) ) + xtrax;
@@ -1024,10 +1056,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
che = che->next;
}
- if(che)
- twidth = che->width;
- else
- twidth = 0;
+ twidth = char_width(cu, che, info);
dtime= distfac*0.35f*twidth; /* why not 0.5? */
dtime= distfac*0.5f*twidth; /* why not 0.5? */
@@ -1167,8 +1196,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
break;
che = che->next;
}
-
- if(!che) twidth =0; else twidth=che->width;
+
+ twidth = char_width(cu, che, info);
ulwidth = cu->fsize * ((twidth* (1.0+(info->kern/40.0)))+uloverlap);
build_underline(cu, ct->xof*cu->fsize, ct->yof*cu->fsize + (cu->ulpos-0.05)*cu->fsize,
ct->xof*cu->fsize + ulwidth,