diff options
Diffstat (limited to 'source/blender/editors/curve/editfont.c')
-rw-r--r-- | source/blender/editors/curve/editfont.c | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index dc5dc71106f..d78c543f94b 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -76,9 +76,9 @@ static int kill_selection(Object *obedit, int ins); /** \name Internal Utilities * \{ */ -static wchar_t findaccent(wchar_t char1, uint code) +static char32_t findaccent(char32_t char1, uint code) { - wchar_t new = 0; + char32_t new = 0; if (char1 == 'a') { if (code == '`') { @@ -373,9 +373,7 @@ static wchar_t findaccent(wchar_t char1, uint code) if (new) { return new; } - else { - return char1; - } + return char1; } static int insert_into_textbuf(Object *obedit, uintptr_t c) @@ -403,9 +401,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) return 1; } - else { - return 0; - } + return 0; } static void text_update_edited(bContext *C, Object *obedit, int mode) @@ -686,7 +682,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const cu->strinfo = MEM_callocN((nchars + 4) * sizeof(CharInfo), "strinfo"); cu->len = 0; - cu->len_wchar = nchars - 1; + cu->len_char32 = nchars - 1; cu->pos = 0; s = cu->str; @@ -707,7 +703,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const } } - cu->pos = cu->len_wchar; + cu->pos = cu->len_char32; *s = '\0'; WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, obedit); @@ -887,9 +883,7 @@ static int font_select_all_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void FONT_OT_select_all(wmOperatorType *ot) @@ -1015,10 +1009,9 @@ static bool paste_selection(Object *obedit, ReportList *reports) if (font_paste_wchar(obedit, text_buf, len, info_buf)) { return true; } - else { - BKE_report(reports, RPT_WARNING, "Text too long"); - return false; - } + + BKE_report(reports, RPT_WARNING, "Text too long"); + return false; } static int paste_text_exec(bContext *C, wmOperator *op) @@ -1347,9 +1340,7 @@ static int change_spacing_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void FONT_OT_change_spacing(wmOperatorType *ot) @@ -1635,7 +1626,7 @@ static int insert_text_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); char *inserted_utf8; - wchar_t *inserted_text; + char32_t *inserted_text; int a, len; if (!RNA_struct_property_is_set(op->ptr, "text")) { @@ -1645,8 +1636,8 @@ static int insert_text_exec(bContext *C, wmOperator *op) inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", NULL, 0); len = BLI_strlen_utf8(inserted_utf8); - inserted_text = MEM_callocN(sizeof(wchar_t) * (len + 1), "FONT_insert_text"); - BLI_strncpy_wchar_from_utf8(inserted_text, inserted_utf8, len + 1); + inserted_text = MEM_callocN(sizeof(char32_t) * (len + 1), "FONT_insert_text"); + len = BLI_str_utf8_as_utf32(inserted_text, inserted_utf8, MAXTEXT); for (a = 0; a < len; a++) { insert_into_textbuf(obedit, inserted_text[a]); @@ -1670,7 +1661,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) uintptr_t ascii = event->ascii; int alt = event->alt, shift = event->shift, ctrl = event->ctrl; int event_type = event->type, event_val = event->val; - wchar_t inserted_text[2] = {0}; + char32_t inserted_text[2] = {0}; if (RNA_struct_property_is_set(op->ptr, "text")) { return insert_text_exec(C, op); @@ -1688,9 +1679,8 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) if ((alt || ctrl || shift) == 0) { return OPERATOR_PASS_THROUGH; } - else { - ascii = 9; - } + + ascii = 9; } if (event_type == EVT_BACKSPACEKEY) { @@ -1743,7 +1733,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* store as utf8 in RNA string */ char inserted_utf8[8] = {0}; - BLI_strncpy_wchar_as_utf8(inserted_utf8, inserted_text, sizeof(inserted_utf8)); + BLI_str_utf32_as_utf8(inserted_utf8, inserted_text, sizeof(inserted_utf8)); RNA_string_set(op->ptr, "text", inserted_utf8); } @@ -1877,7 +1867,7 @@ void ED_curve_editfont_make(Object *obedit) { Curve *cu = obedit->data; EditFont *ef = cu->editfont; - int len_wchar; + int len_char32; if (ef == NULL) { ef = cu->editfont = MEM_callocN(sizeof(EditFont), "editfont"); @@ -1886,10 +1876,10 @@ void ED_curve_editfont_make(Object *obedit) ef->textbufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo"); } - /* Convert the original text to wchar_t */ - len_wchar = BLI_str_utf8_as_utf32(ef->textbuf, cu->str, MAXTEXT + 4); - BLI_assert(len_wchar == cu->len_wchar); - ef->len = len_wchar; + /* Convert the original text to chat32_t. */ + len_char32 = BLI_str_utf8_as_utf32(ef->textbuf, cu->str, MAXTEXT + 4); + BLI_assert(len_char32 == cu->len_char32); + ef->len = len_char32; BLI_assert(ef->len >= 0); memcpy(ef->textbufinfo, cu->strinfo, ef->len * sizeof(CharInfo)); @@ -1918,7 +1908,7 @@ void ED_curve_editfont_load(Object *obedit) MEM_freeN(cu->str); /* Calculate the actual string length in UTF-8 variable characters */ - cu->len_wchar = ef->len; + cu->len_char32 = ef->len; cu->len = BLI_str_utf32_as_utf8_len(ef->textbuf); /* Alloc memory for UTF-8 variable char length string */ @@ -1930,8 +1920,8 @@ void ED_curve_editfont_load(Object *obedit) if (cu->strinfo) { MEM_freeN(cu->strinfo); } - cu->strinfo = MEM_callocN((cu->len_wchar + 4) * sizeof(CharInfo), "texteditinfo"); - memcpy(cu->strinfo, ef->textbufinfo, cu->len_wchar * sizeof(CharInfo)); + cu->strinfo = MEM_callocN((cu->len_char32 + 4) * sizeof(CharInfo), "texteditinfo"); + memcpy(cu->strinfo, ef->textbufinfo, cu->len_char32 * sizeof(CharInfo)); /* Other vars */ cu->pos = ef->pos; @@ -2133,7 +2123,7 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event) vfont = (VFont *)idptr.owner_id; } - path = (vfont && !BKE_vfont_is_builtin(vfont)) ? vfont->name : U.fontdir; + path = (vfont && !BKE_vfont_is_builtin(vfont)) ? vfont->filepath : U.fontdir; if (RNA_struct_property_is_set(op->ptr, "filepath")) { return font_open_exec(C, op); @@ -2290,9 +2280,7 @@ bool ED_curve_editfont_select_pick( } return true; } - else { - return false; - } + return false; } /** \} */ |