diff --git a/source/blender/blenkernel/BKE_vfont.h b/source/blender/blenkernel/BKE_vfont.h index aea662d6548..e3a7e07de97 100644 --- a/source/blender/blenkernel/BKE_vfont.h +++ b/source/blender/blenkernel/BKE_vfont.h @@ -98,6 +98,10 @@ void BKE_vfont_clipboard_get(char32_t **r_text_buf, size_t *r_len_utf8, size_t *r_len_utf32); +/* Declared in `bpy_interface.c` */ +int text_toupper_unicode(const unsigned int ch); +int text_tolower_unicode(const unsigned int ch); + #ifdef __cplusplus } #endif diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt index 6b46c822e86..18fbb3c3d0c 100644 --- a/source/blender/editors/curve/CMakeLists.txt +++ b/source/blender/editors/curve/CMakeLists.txt @@ -41,6 +41,9 @@ set(LIB extern_curve_fit_nd ) +if(WITH_PYTHON) + add_definitions(-DWITH_PYTHON) +endif() blender_add_lib(bf_editor_curve "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index f96bb85d53e..6a28c04913c 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1982,23 +1982,26 @@ static int set_case(bContext *C, int ccase) len = (selend - selstart) + 1; str = &ef->textbuf[selstart]; while (len) { - if (*str >= 'a' && *str <= 'z') { - *str -= 32; - } - len--; - str++; - } - - if (ccase == CASE_LOWER) { - len = (selend - selstart) + 1; - str = &ef->textbuf[selstart]; - while (len) { + if (ccase == CASE_LOWER) { +#ifdef WITH_PYTHON + *str = text_tolower_unicode(*str); +#else if (*str >= 'A' && *str <= 'Z') { *str += 32; } - len--; - str++; +#endif } + else { +#ifdef WITH_PYTHON + *str = text_toupper_unicode(*str); +#else + if (*str >= 'a' && *str <= 'z') { + *str -= 32; + } +#endif + } + len--; + str++; } text_update_edited(C, obedit, FO_EDIT); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 4fe39e1c5b0..9f5469e1564 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -46,6 +46,7 @@ #include "BKE_global.h" /* only for script checking */ #include "BKE_main.h" #include "BKE_text.h" +#include "BKE_vfont.h" /* For `text_toupper_unicode` declaration. */ #ifdef WITH_CYCLES # include "CCL_api.h" @@ -956,3 +957,14 @@ int text_check_identifier_nodigit_unicode(const uint ch) { return (ch < 255 && text_check_identifier_nodigit((char)ch)) || Py_UNICODE_ISALPHA(ch); } + +/* EVIL: define `editfont.c` functions here (declared in `BKE_vfont.h`). */ +int text_toupper_unicode(const uint ch) +{ + return Py_UNICODE_TOUPPER(ch); +} + +int text_tolower_unicode(const uint ch) +{ + return Py_UNICODE_TOLOWER(ch); +}