UI: Allow Float Kerning for Text Objects #105181

Merged
Harley Acheson merged 1 commits from pioverfour/blender:dp_kerning_float into main 2023-04-12 19:12:07 +02:00
5 changed files with 20 additions and 17 deletions

View File

@ -5596,9 +5596,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},

View File

@ -4796,8 +4796,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

View File

@ -378,7 +378,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++;
@ -1295,7 +1295,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;
@ -1310,7 +1310,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;
@ -1341,15 +1340,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);
}
/** \} */

View File

@ -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 {

View File

@ -1366,8 +1366,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");
}