UI: Allow Float Kerning for Text Objects
Change Text Object character `kern` member to float from int, and allow fractional changes to kerning with Shift-Alt-arrows. Pull Request: https://projects.blender.org/blender/blender/pulls/105181
This commit is contained in:
parent
0ee0e8c0d4
commit
2b6c1600cf
@ -5600,9 +5600,13 @@ def km_font(params):
|
||||
("font.move_select", {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True, "repeat": True},
|
||||
{"properties": [("type", 'NEXT_PAGE')]}),
|
||||
("font.change_spacing", {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True, "repeat": True},
|
||||
{"properties": [("delta", -1)]}),
|
||||
{"properties": [("delta", -1.0)]}),
|
||||
("font.change_spacing", {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True, "repeat": True},
|
||||
{"properties": [("delta", 1)]}),
|
||||
{"properties": [("delta", 1.0)]}),
|
||||
("font.change_spacing", {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "alt": True, "repeat": True},
|
||||
{"properties": [("delta", -0.1)]}),
|
||||
("font.change_spacing", {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "alt": True, "repeat": True},
|
||||
{"properties": [("delta", 0.1)]}),
|
||||
("font.change_character", {"type": 'UP_ARROW', "value": 'PRESS', "alt": True, "repeat": True},
|
||||
{"properties": [("delta", 1)]}),
|
||||
("font.change_character", {"type": 'DOWN_ARROW', "value": 'PRESS', "alt": True, "repeat": True},
|
||||
|
@ -4865,8 +4865,8 @@ class VIEW3D_MT_edit_font_kerning(Menu):
|
||||
text = ob.data
|
||||
kerning = text.edit_format.kerning
|
||||
|
||||
layout.operator("font.change_spacing", text="Decrease Kerning").delta = -1
|
||||
layout.operator("font.change_spacing", text="Increase Kerning").delta = 1
|
||||
layout.operator("font.change_spacing", text="Decrease Kerning").delta = -1.0
|
||||
layout.operator("font.change_spacing", text="Increase Kerning").delta = 1.0
|
||||
layout.operator("font.change_spacing", text="Reset Kerning").delta = -kerning
|
||||
|
||||
|
||||
|
@ -381,7 +381,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
|
||||
}
|
||||
ef->textbuf[ef->pos] = c;
|
||||
ef->textbufinfo[ef->pos] = cu->curinfo;
|
||||
ef->textbufinfo[ef->pos].kern = 0;
|
||||
ef->textbufinfo[ef->pos].kern = 0.0f;
|
||||
ef->textbufinfo[ef->pos].mat_nr = obedit->actcol;
|
||||
|
||||
ef->pos++;
|
||||
@ -1346,7 +1346,7 @@ static int change_spacing_exec(bContext *C, wmOperator *op)
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Curve *cu = obedit->data;
|
||||
EditFont *ef = cu->editfont;
|
||||
int kern, delta = RNA_int_get(op->ptr, "delta");
|
||||
float kern, delta = RNA_float_get(op->ptr, "delta");
|
||||
int selstart, selend;
|
||||
bool changed = false;
|
||||
|
||||
@ -1361,7 +1361,6 @@ static int change_spacing_exec(bContext *C, wmOperator *op)
|
||||
|
||||
for (int i = selstart; i <= selend; i++) {
|
||||
kern = ef->textbufinfo[i].kern + delta;
|
||||
CLAMP(kern, -20, 20);
|
||||
|
||||
if (ef->textbufinfo[i].kern != kern) {
|
||||
ef->textbufinfo[i].kern = kern;
|
||||
@ -1392,15 +1391,15 @@ void FONT_OT_change_spacing(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_int(ot->srna,
|
||||
RNA_def_float(ot->srna,
|
||||
"delta",
|
||||
1,
|
||||
-20,
|
||||
20,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
"Delta",
|
||||
"Amount to decrease or increase character spacing with",
|
||||
-20,
|
||||
20);
|
||||
0.0,
|
||||
0.0);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -158,11 +158,11 @@ typedef struct Nurb {
|
||||
} Nurb;
|
||||
|
||||
typedef struct CharInfo {
|
||||
short kern;
|
||||
float kern;
|
||||
/** Index start at 1, unlike mesh & nurbs. */
|
||||
short mat_nr;
|
||||
char flag;
|
||||
char _pad[3];
|
||||
char _pad[1];
|
||||
} CharInfo;
|
||||
|
||||
typedef struct TextBox {
|
||||
|
@ -1365,8 +1365,8 @@ static void rna_def_charinfo(BlenderRNA *brna)
|
||||
"rna_Curve_material_index_range");
|
||||
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
|
||||
|
||||
prop = RNA_def_property(srna, "kerning", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, NULL, "kern");
|
||||
prop = RNA_def_property(srna, "kerning", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "kern");
|
||||
RNA_def_property_ui_text(prop, "Kerning", "Spacing between characters");
|
||||
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user