Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-01-05 13:52:31 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-05 14:15:25 +0400
commit42bd5d7c8081a4f4524c07cc542c772ccf0a26eb (patch)
tree418ee0cb712a0e827256ba16aa920efbaee8bca9 /source/blender/blenkernel/intern/font.c
parent3eb818e53a988228fa997fcf09eebb66d8fb344e (diff)
Text3d: fix for smallcaps modifying the original text input in editmode.
Oversight in own recent commit to avoid allocating a new wchar_t array.
Diffstat (limited to 'source/blender/blenkernel/intern/font.c')
-rw-r--r--source/blender/blenkernel/intern/font.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index d0656b0824c..a85ddb8733e 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -512,7 +512,8 @@ bool BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode,
int curbox;
int selstart, selend;
short cnr = 0, lnr = 0, wsnr = 0;
- wchar_t *mem, *tmp, ascii;
+ const wchar_t *mem;
+ wchar_t ascii;
bool ok = false;
/* remark: do calculations including the trailing '\0' of a string
@@ -540,17 +541,20 @@ bool BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode,
custrinfo = ef->textbufinfo;
}
else {
+ wchar_t *mem_tmp;
slen = cu->len_wchar;
/* Create unicode string */
- mem = MEM_mallocN(((slen + 1) * sizeof(wchar_t)), "convertedmem");
+ mem_tmp = MEM_mallocN(((slen + 1) * sizeof(wchar_t)), "convertedmem");
- BLI_strncpy_wchar_from_utf8(mem, cu->str, slen + 1);
+ BLI_strncpy_wchar_from_utf8(mem_tmp, cu->str, slen + 1);
if (cu->strinfo == NULL) { /* old file */
cu->strinfo = MEM_callocN((slen + 4) * sizeof(CharInfo), "strinfo compat");
}
custrinfo = cu->strinfo;
+
+ mem = mem_tmp;
}
if (cu->tb == NULL)
@@ -592,7 +596,6 @@ makebreak:
if (info->flag & CU_CHINFO_SMALLCAPS) {
ascii = towupper(ascii);
if (mem[i] != ascii) {
- mem[i] = ascii;
info->flag |= CU_CHINFO_SMALLCAPS_CHECK;
}
}
@@ -760,10 +763,9 @@ makebreak:
}
cu->lines = 1;
- ct = chartransdata;
- tmp = mem;
- for (i = 0; i <= slen; i++, tmp++, ct++) {
- ascii = *tmp;
+ for (i = 0; i <= slen; i++) {
+ ascii = mem[i];
+ ct = &chartransdata[i];
if (ascii == '\n' || ascii == '\r' || ct->dobreak) cu->lines++;
}
@@ -895,6 +897,9 @@ makebreak:
/* rotate around center character */
info = &custrinfo[i];
ascii = mem[i];
+ if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
+ ascii = towupper(ascii);
+ }
che = find_vfont_char(vfd, ascii);
@@ -1015,6 +1020,11 @@ makebreak:
for (i = 0; i < slen; i++) {
unsigned int cha = (unsigned int) mem[i];
info = &(custrinfo[i]);
+
+ if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
+ cha = towupper(cha);
+ }
+
if (info->mat_nr > (ob->totcol)) {
/* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */
info->mat_nr = 0;
@@ -1052,7 +1062,7 @@ makebreak:
finally:
if (ef == NULL)
- MEM_freeN(mem);
+ MEM_freeN((void *)mem);
if (chartransdata) {
if (ok && r_chartransdata) {