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>2011-10-20 13:47:05 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-20 13:47:05 +0400
commit8d6a554d7502029f04aca33efcdd004744b9bd84 (patch)
tree027f5dec3ea38784d3108f8d9b5c4a008bae7fb4 /source/blender/blenkernel
parente02dfe4a79b3632b3143d5d45e0dee1463ff7aa6 (diff)
- add BLI_string_utf8.h for unicode functions.
- move font.c unicode functions into string_utf8.c and rename to fit with other BLI_string funcs.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_font.h5
-rw-r--r--source/blender/blenkernel/intern/font.c140
-rw-r--r--source/blender/blenkernel/intern/particle_system.c1
-rw-r--r--source/blender/blenkernel/intern/smoke.c3
4 files changed, 3 insertions, 146 deletions
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index e4e8805164a..214ae03b453 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -85,11 +85,6 @@ struct chartrans *BKE_text_to_curve(struct Main *bmain, struct Scene *scene, str
int BKE_font_getselection(struct Object *ob, int *start, int *end);
-size_t chtoutf8(const unsigned long c, char o[4]);
-void wcs2utf8s(char *dst, const wchar_t *src);
-size_t wcsleninu8(wchar_t *src);
-size_t utf8towchar(wchar_t *w, const char *c);
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 9c01b35b91a..068e70bbb50 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -64,142 +64,6 @@
static ListBase ttfdata= {NULL, NULL};
-/* UTF-8 <-> wchar transformations */
-size_t chtoutf8(const unsigned long c, char o[4])
-{
- // Variables and initialization
-/* memset(o, 0, 4); */
-
- // Create the utf-8 string
- if (c < 0x80) {
- o[0] = (char) c;
- return 1;
- }
- else if (c < 0x800) {
- o[0] = (0xC0 | (c>>6));
- o[1] = (0x80 | (c & 0x3f));
- return 2;
- }
- else if (c < 0x10000) {
- o[0] = (0xe0 | (c >> 12));
- o[1] = (0x80 | (c >>6 & 0x3f));
- o[2] = (0x80 | (c & 0x3f));
- return 3;
- }
- else if (c < 0x200000) {
- o[0] = (0xf0 | (c>>18));
- o[1] = (0x80 | (c >>12 & 0x3f));
- o[2] = (0x80 | (c >> 6 & 0x3f));
- o[3] = (0x80 | (c & 0x3f));
- return 4;
- }
-
- /* should we assert here? */
- return 0;
-}
-
-void wcs2utf8s(char *dst, const wchar_t *src)
-{
- while(*src) {
- dst += chtoutf8(*src++, dst);
- }
-
- *dst= '\0';
-}
-
-size_t wcsleninu8(wchar_t *src)
-{
- char ch_dummy[4];
- size_t len = 0;
-
- while(*src) {
- len += chtoutf8(*src++, ch_dummy);
- }
-
- return len;
-}
-
-static size_t utf8slen(const char *strc)
-{
- int len=0;
-
- while(*strc) {
- if ((*strc & 0xe0) == 0xc0) {
- if((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00)
- strc++;
- } else if ((*strc & 0xf0) == 0xe0) {
- if((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00)
- strc += 2;
- } else if ((*strc & 0xf8) == 0xf0) {
- if((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00)
- strc += 3;
- }
-
- strc++;
- len++;
- }
-
- return len;
-}
-
-
-/* Converts Unicode to wchar
-
-According to RFC 3629 "UTF-8, a transformation format of ISO 10646"
-(http://tools.ietf.org/html/rfc3629), the valid UTF-8 encoding are:
-
- Char. number range | UTF-8 octet sequence
- (hexadecimal) | (binary)
- --------------------+---------------------------------------------
- 0000 0000-0000 007F | 0xxxxxxx
- 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
- 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
- 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-
-If the encoding incidated by the first character is incorrect (because the
-1 to 3 following characters do not match 10xxxxxx), the output is a '?' and
-only a single input character is consumed.
-
-*/
-
-size_t utf8towchar(wchar_t *w, const char *c)
-{
- int len=0;
-
- if(w==NULL || c==NULL) return(0);
-
- while(*c) {
- if ((*c & 0xe0) == 0xc0) {
- if((c[1] & 0x80) && (c[1] & 0x40) == 0x00) {
- *w=((c[0] &0x1f)<<6) | (c[1]&0x3f);
- c++;
- } else {
- *w = '?';
- }
- } else if ((*c & 0xf0) == 0xe0) {
- if((c[1] & c[2] & 0x80) && ((c[1] | c[2]) & 0x40) == 0x00) {
- *w=((c[0] & 0x0f)<<12) | ((c[1]&0x3f)<<6) | (c[2]&0x3f);
- c += 2;
- } else {
- *w = '?';
- }
- } else if ((*c & 0xf8) == 0xf0) {
- if((c[1] & c[2] & c[3] & 0x80) && ((c[1] | c[2] | c[3]) & 0x40) == 0x00) {
- *w=((c[0] & 0x07)<<18) | ((c[1]&0x1f)<<12) | ((c[2]&0x3f)<<6) | (c[3]&0x3f);
- c += 3;
- } else {
- *w = '?';
- }
- } else
- *w=(c[0] & 0x7f);
-
- c++;
- w++;
- len++;
- }
- return len;
-}
-
/* The vfont code */
void free_vfont(struct VFont *vf)
{
@@ -691,10 +555,10 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
if(vfont == NULL) return NULL;
// Create unicode string
- utf8len = utf8slen(cu->str);
+ utf8len = BLI_strlen_utf8(cu->str);
mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
- utf8towchar(mem, cu->str);
+ BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1);
// Count the wchar_t string length
slen = wcslen(mem);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 7b2d621aff2..64a90e15b60 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -70,7 +70,6 @@
#include "BLI_listbase.h"
#include "BLI_threads.h"
#include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */
-#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_main.h"
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 85140841f15..49c8831f06c 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -812,13 +812,12 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
}
}
+#ifdef WITH_SMOKE
// forward decleration
static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct);
static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
-#ifdef WITH_SMOKE
-
static int get_lamp(Scene *scene, float *light)
{
Base *base_tmp = NULL;