diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/curve/editfont.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 92957c51c08..c9206e8df4a 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1320,20 +1320,36 @@ static int change_spacing_exec(bContext *C, wmOperator *op) Curve *cu = obedit->data; EditFont *ef = cu->editfont; int kern, delta = RNA_int_get(op->ptr, "delta"); + int selstart, selend; + bool changed = false; - kern = ef->textbufinfo[ef->pos - 1].kern; - kern += delta; - CLAMP(kern, -20, 20); - - if (ef->textbufinfo[ef->pos - 1].kern == kern) { - return OPERATOR_CANCELLED; + const bool has_select = BKE_vfont_select_get(obedit, &selstart, &selend); + if (has_select) { + selstart -= 1; + } + else { + selstart = selend = ef->pos - 1; } + selstart = max_ii(0, selstart); - ef->textbufinfo[ef->pos - 1].kern = kern; + for (int i = selstart; i <= selend; i++) { + kern = ef->textbufinfo[i].kern + delta; + CLAMP(kern, -20, 20); - text_update_edited(C, obedit, FO_EDIT); + if (ef->textbufinfo[i].kern != kern) { + ef->textbufinfo[i].kern = kern; + changed = true; + } + } - return OPERATOR_FINISHED; + if (changed) { + text_update_edited(C, obedit, FO_EDIT); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } } void FONT_OT_change_spacing(wmOperatorType *ot) |