diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-03 10:04:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-03 10:08:23 +0400 |
commit | 15bc30f4ee49c69f3ed6f92701a0f5cd52d306c5 (patch) | |
tree | fc77fe7096673256d90c512267adb58eb53c23de /source/blender/blenkernel/intern/curve.c | |
parent | a5cb2229abbc7d43f34dabea332afd33614fc0db (diff) |
Text3d: store number of characters and utf8 length separately
EditFont's use of Curve.len was very confusing, in editmode it
represented the number of characters, in object mode the number of
bytes. add Curve.len_wchar and keep track of both.
Also don't convert the editmode text into utf8 on every keystroke.
Now this is done on exiting editmode or save - to match most other
object types.
This also fixes curves 'body_format' being reported with an invalid size.
Diffstat (limited to 'source/blender/blenkernel/intern/curve.c')
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 1c4560cd2b2..d1dde91feb6 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -190,7 +190,7 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type) cu->vfont->id.us += 4; cu->str = MEM_mallocN(12, "str"); BLI_strncpy(cu->str, "Text", 12); - cu->len = cu->pos = 4; + cu->len = cu->len_wchar = cu->pos = 4; cu->strinfo = MEM_callocN(12 * sizeof(CharInfo), "strinfo new"); cu->totbox = cu->actbox = 1; cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "textbox"); @@ -4041,7 +4041,7 @@ void BKE_curve_material_index_remove(Curve *cu, int index) if (curvetype == OB_FONT) { struct CharInfo *info = cu->strinfo; int i; - for (i = cu->len - 1; i >= 0; i--, info++) { + for (i = cu->len_wchar - 1; i >= 0; i--, info++) { if (info->mat_nr && info->mat_nr >= index) { info->mat_nr--; } @@ -4068,7 +4068,7 @@ void BKE_curve_material_index_clear(Curve *cu) if (curvetype == OB_FONT) { struct CharInfo *info = cu->strinfo; int i; - for (i = cu->len - 1; i >= 0; i--, info++) { + for (i = cu->len_wchar - 1; i >= 0; i--, info++) { info->mat_nr = 0; } } |