- 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.
This commit is contained in:
Campbell Barton
2010-07-13 23:51:21 +00:00
parent 03e638d128
commit 3580d6229a
12 changed files with 84 additions and 91 deletions

View File

@@ -31,12 +31,12 @@ def man_format(data):
data = data.replace("-", "\\-")
data = data.replace("\t", " ")
# data = data.replace("$", "\\fI")
data_ls = []
for w in data.split():
if w.startswith("$"):
w = "\\fI" + w[1:] + "\\fR"
data_ls.append(w)
data = data[:len(data) - len(data.lstrip())] + " ".join(data_ls)
@@ -90,16 +90,16 @@ lines = [line.rstrip() for line in blender_help.split("\n")]
while lines:
l = lines.pop(0)
if l.startswith("Environment Variables:"):
fw('.SH "ENVIRONMENT VARIABLES"\n')
fw('.SH "ENVIRONMENT VARIABLES"\n')
elif l.endswith(":"): # one line
fw('.SS "%s"\n\n' % l)
fw('.SS "%s"\n\n' % l)
elif l.startswith("-") or l.startswith("/"): # can be multi line
fw('.TP\n')
fw('.B %s\n' % man_format(l))
while lines:
# line with no
# line with no
if lines[0].strip() and len(lines[0].lstrip()) == len(lines[0]): # no white space
break
@@ -112,7 +112,7 @@ while lines:
l = l[1:] # remove first whitespace (tab)
fw('%s\n' % man_format(l))
else:
if not l.strip():
fw('.br\n')

View File

@@ -631,6 +631,8 @@ if __name__ == "__main__":
props = [(prop.identifier, prop) for prop in v.properties]
for prop_id, prop in sorted(props):
if prop.type == 'boolean':
continue
data += "%s.%s -> %s: %s%s %s\n" % (struct_id_str, prop.identifier, prop.identifier, prop.type, ", (read-only)" if prop.is_readonly else "", prop.description)
if bpy.app.background:

View File

@@ -27,8 +27,8 @@ class AddPresetBase(bpy.types.Operator):
subclasses must define
- preset_values
- preset_subdir '''
bl_idname = "script.add_preset_base"
bl_label = "Add a Python Preset"
# bl_idname = "script.preset_base_add"
# bl_label = "Add a Python Preset"
name = bpy.props.StringProperty(name="Name", description="Name of the preset, used to make the path name", maxlen=64, default="")

View File

@@ -313,8 +313,6 @@ class DATA_PT_font(DataButtonsPanel):
colsub.label(text="Underline:")
colsub.prop(text, "ul_position", text="Position")
colsub.prop(text, "ul_height", text="Thickness")
col.label(text="")
col.prop(text, "small_caps_scale", text="Small Caps")
if wide_ui:
col = split.column()
@@ -322,9 +320,13 @@ class DATA_PT_font(DataButtonsPanel):
col.prop(char, "bold")
col.prop(char, "italic")
col.prop(char, "underline")
split = layout.split()
col = split.column()
col.prop(text, "small_caps_scale", text="Small Caps")
col = split.column()
col.prop(char, "use_small_caps")
# col.prop(char, "style")
# col.prop(char, "wrap")
class DATA_PT_paragraph(DataButtonsPanel):

View File

@@ -1707,6 +1707,13 @@ class VIEW3D_MT_edit_text(bpy.types.Menu):
layout.menu("VIEW3D_MT_edit_text_chars")
layout.separator()
layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
bl_label = "Special Characters"

View File

@@ -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);

View File

@@ -147,9 +147,10 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
keymap->poll= ED_operator_editfont;
/* only set in editmode font, by space_view3d listener */
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", BKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_BOLD);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_ITALIC);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", UKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_UNDERLINE);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", BKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_BOLD);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_ITALIC);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", UKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_UNDERLINE);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", PKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_SMALLCAPS);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_SEL);
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_SEL);

View File

@@ -611,9 +611,10 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */
/******************* set style operator ********************/
static EnumPropertyItem style_items[]= {
{CU_BOLD, "BOLD", 0, "Bold", ""},
{CU_ITALIC, "ITALIC", 0, "Italic", ""},
{CU_UNDERLINE, "UNDERLINE", 0, "Underline", ""},
{CU_CHINFO_BOLD, "BOLD", 0, "Bold", ""},
{CU_CHINFO_ITALIC, "ITALIC", 0, "Italic", ""},
{CU_CHINFO_UNDERLINE, "UNDERLINE", 0, "Underline", ""},
{CU_CHINFO_SMALLCAPS, "SMALL_CAPS", 0, "Small Caps", ""},
{0, NULL, 0, NULL, NULL}};
static int set_style(bContext *C, int style, int clear)
@@ -664,7 +665,7 @@ void FONT_OT_style_set(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_enum(ot->srna, "style", style_items, CU_BOLD, "Style", "Style to set selection to.");
RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to.");
RNA_def_boolean(ot->srna, "clear", 0, "Clear", "Clear style rather than setting it.");
}
@@ -702,7 +703,7 @@ void FONT_OT_style_toggle(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_enum(ot->srna, "style", style_items, CU_BOLD, "Style", "Style to set selection to.");
RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to.");
}
/******************* copy text operator ********************/
@@ -862,7 +863,7 @@ static int move_cursor(bContext *C, int type, int select)
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
while(cu->pos>0) {
if(ef->textbuf[cu->pos-1]=='\n') break;
if(ef->textbufinfo[cu->pos-1].flag & CU_WRAP ) break;
if(ef->textbufinfo[cu->pos-1].flag & CU_CHINFO_WRAP) break;
cu->pos--;
}
cursmove=FO_CURS;
@@ -873,7 +874,7 @@ static int move_cursor(bContext *C, int type, int select)
while(cu->pos<cu->len) {
if(ef->textbuf[cu->pos]==0) break;
if(ef->textbuf[cu->pos]=='\n') break;
if(ef->textbufinfo[cu->pos].flag & CU_WRAP ) break;
if(ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP ) break;
cu->pos++;
}
cursmove=FO_CURS;

View File

@@ -50,6 +50,7 @@
struct DerivedMesh;
struct GHash;
struct DMGridData;
/* V - vertex, N - normal, T - uv, C - color
F - float, UB - unsigned byte */

View File

@@ -68,6 +68,7 @@
#include "GPU_extensions.h"
#include "GPU_material.h"
#include "GPU_draw.h"
#include "gpu_buffers.h"
#include "smoke_API.h"

View File

@@ -324,12 +324,13 @@ typedef enum eBezTriple_KeyframeType {
/* *************** CHARINFO **************** */
/* flag */
#define CU_STYLE (1+2)
#define CU_BOLD 1
#define CU_ITALIC 2
#define CU_UNDERLINE 4
#define CU_WRAP 8 /* wordwrap occured here */
#define CU_SMALLCAPS 16
/* note: CU_CHINFO_WRAP and CU_CHINFO_SMALLCAPS_TEST are set dynamically */
#define CU_CHINFO_BOLD (1<<0)
#define CU_CHINFO_ITALIC (1<<1)
#define CU_CHINFO_UNDERLINE (1<<2)
#define CU_CHINFO_WRAP (1<<3) /* wordwrap occured here */
#define CU_CHINFO_SMALLCAPS (1<<4)
#define CU_CHINFO_SMALLCAPS_CHECK (1<<5) /* set at runtime, checks if case switching is needed */
#endif

View File

@@ -878,33 +878,29 @@ static void rna_def_charinfo(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Text Character Format", "Text character formatting settings");
/* flags */
prop= RNA_def_property(srna, "style", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STYLE);
RNA_def_property_ui_text(prop, "Style", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop= RNA_def_property(srna, "bold", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_BOLD);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_BOLD);
RNA_def_property_ui_text(prop, "Bold", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop= RNA_def_property(srna, "italic", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_ITALIC);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_ITALIC);
RNA_def_property_ui_text(prop, "Italic", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop= RNA_def_property(srna, "underline", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UNDERLINE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_UNDERLINE);
RNA_def_property_ui_text(prop, "Underline", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_WRAP);
/* probably there is no reason to expose this */
/* prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_WRAP);
RNA_def_property_ui_text(prop, "Wrap", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
RNA_def_property_update(prop, 0, "rna_Curve_update_data"); */
prop= RNA_def_property(srna, "use_small_caps", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_SMALLCAPS);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_SMALLCAPS);
RNA_def_property_ui_text(prop, "Small Caps", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
}