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 03:51:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-07-14 03:51:21 +0400
commit3580d6229a2c2ee5815ff76665d4bb014eacfb99 (patch)
tree24a38ec45f417458760875c20d10914e4aa5c973 /source/blender/blenkernel/intern/font.c
parent03e638d1285b2a26902230772ae9261406fd6658 (diff)
- text3d was missing menu items for toggling bold/underline/italic/smallcaps.
- made smallcaps use a temp flag so caps can still have the smallcaps flag. - utility function for getting the char from a font. find_vfont_char(), was inline in ~5 places. - removed CU_STYLE mix of flags only used in one place, not needed. removed 'style' from rna too. - fix for some warnings.
Diffstat (limited to 'source/blender/blenkernel/intern/font.c')
-rw-r--r--source/blender/blenkernel/intern/font.c81
1 files changed, 31 insertions, 50 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index d07bd2ba8e5..a99f2599f66 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -427,12 +427,12 @@ VFont *load_vfont(char *name)
static VFont *which_vfont(Curve *cu, CharInfo *info)
{
- switch(info->flag & CU_STYLE) {
- case CU_BOLD:
+ switch(info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) {
+ case CU_CHINFO_BOLD:
if (cu->vfontb) return(cu->vfontb); else return(cu->vfont);
- case CU_ITALIC:
+ case CU_CHINFO_ITALIC:
if (cu->vfonti) return(cu->vfonti); else return(cu->vfont);
- case (CU_BOLD|CU_ITALIC):
+ case (CU_CHINFO_BOLD|CU_CHINFO_ITALIC):
if (cu->vfontbi) return(cu->vfontbi); else return(cu->vfont);
default:
return(cu->vfont);
@@ -450,6 +450,17 @@ VFont *get_builtin_font(void)
return load_vfont("<builtin>");
}
+static VChar *find_vfont_char(VFontData *vfd, intptr_t character)
+{
+ VChar *che= NULL;
+
+ for(che = vfd->characters.first; che; che = che->next) {
+ if(che->index == character)
+ break;
+ }
+ return che; /* NULL if not found */
+}
+
static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, int charidx, short mat_nr)
{
Nurb *nu2;
@@ -524,14 +535,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
si= (float)sin(rot);
co= (float)cos(rot);
- // Find the correct character from the font
- che = vfd->characters.first;
- while(che)
- {
- if(che->index == character)
- break;
- che = che->next;
- }
+ che= find_vfont_char(vfd, character);
// Select the glyph data
if(che)
@@ -598,7 +602,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
}
bezt2 = nu2->bezt;
- if(info->flag & CU_SMALLCAPS) {
+ if(info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
const float sca= cu->smallcaps_scale;
for (i= nu2->pntsu; i > 0; i--) {
fp= bezt2->vec[0];
@@ -656,7 +660,7 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info)
if(che == NULL) {
return 0.0f;
}
- else if(info->flag & CU_SMALLCAPS) {
+ else if(info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
return che->width * cu->smallcaps_scale;
}
else {
@@ -745,7 +749,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
oldvfont = NULL;
- for (i=0; i<slen; i++) custrinfo[i].flag &= ~CU_WRAP;
+ for (i=0; i<slen; i++) custrinfo[i].flag &= ~(CU_CHINFO_WRAP|CU_CHINFO_SMALLCAPS_CHECK);
if (cu->selboxes) MEM_freeN(cu->selboxes);
cu->selboxes = NULL;
@@ -760,26 +764,19 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
che = vfd->characters.first;
info = &(custrinfo[i]);
ascii = mem[i];
- if(info->flag & CU_SMALLCAPS) {
+ if(info->flag & CU_CHINFO_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 */
+ info->flag |= CU_CHINFO_SMALLCAPS_CHECK;
}
}
vfont = which_vfont(cu, info);
if(vfont==NULL) break;
-
- // Find the character
- while(che) {
- if(che->index == ascii)
- break;
- che = che->next;
- }
+
+ che= find_vfont_char(vfd, ascii);
/*
* The character wasn't in the current curve base so load it
@@ -791,12 +788,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
}
/* Try getting the character again from the list */
- che = vfd->characters.first;
- while(che) {
- if(che->index == ascii)
- break;
- che = che->next;
- }
+ che= find_vfont_char(vfd, ascii);
/* No VFont found */
if (vfont==0) {
@@ -833,13 +825,13 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
i = j-1;
xof = ct->xof;
ct[1].dobreak = 1;
- custrinfo[i+1].flag |= CU_WRAP;
+ custrinfo[i+1].flag |= CU_CHINFO_WRAP;
goto makebreak;
}
if (chartransdata[j].dobreak) {
// fprintf(stderr, "word too long: %c%c%c...\n", mem[j], mem[j+1], mem[j+2]);
ct->dobreak= 1;
- custrinfo[i+1].flag |= CU_WRAP;
+ custrinfo[i+1].flag |= CU_CHINFO_WRAP;
ct -= 1;
cnr -= 1;
i--;
@@ -1047,14 +1039,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
/* rotate around center character */
ascii = mem[i];
-
- // Find the character
- che = vfd->characters.first;
- while(che) {
- if(che->index == ascii)
- break;
- che = che->next;
- }
+
+ che= find_vfont_char(vfd, ascii);
twidth = char_width(cu, che, info);
@@ -1180,22 +1166,17 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
if(cha != '\n' && cha != '\r')
buildchar(cu, cha, info, ct->xof, ct->yof, ct->rot, i);
- if ((info->flag & CU_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) {
+ if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) {
float ulwidth, uloverlap= 0.0f;
if ( (i<(slen-1)) && (mem[i+1] != '\n') && (mem[i+1] != '\r') &&
- ((mem[i+1] != ' ') || (custrinfo[i+1].flag & CU_UNDERLINE)) && ((custrinfo[i+1].flag & CU_WRAP)==0)
+ ((mem[i+1] != ' ') || (custrinfo[i+1].flag & CU_CHINFO_UNDERLINE)) && ((custrinfo[i+1].flag & CU_CHINFO_WRAP)==0)
) {
uloverlap = xtrax + 0.1;
}
// Find the character, the characters has to be in the memory already
// since character checking has been done earlier already.
- che = vfd->characters.first;
- while(che) {
- if(che->index == cha)
- break;
- che = che->next;
- }
+ che= find_vfont_char(vfd, cha);
twidth = char_width(cu, che, info);
ulwidth = cu->fsize * ((twidth* (1.0+(info->kern/40.0)))+uloverlap);