[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41164] trunk/blender/source: replace BLF' s blf_utf8_next() with BLI_str_utf8_as_unicode_step(),

Campbell Barton ideasman42 at gmail.com
Fri Oct 21 03:33:08 CEST 2011


Revision: 41164
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41164
Author:   campbellbarton
Date:     2011-10-21 01:33:06 +0000 (Fri, 21 Oct 2011)
Log Message:
-----------
replace BLF's blf_utf8_next() with BLI_str_utf8_as_unicode_step(),
also fixed some spelling errors.

Modified Paths:
--------------
    trunk/blender/source/blender/blenfont/intern/blf_font.c
    trunk/blender/source/blender/blenfont/intern/blf_internal.h
    trunk/blender/source/blender/blenfont/intern/blf_util.c
    trunk/blender/source/blender/blenkernel/intern/softbody.c
    trunk/blender/source/blender/blenlib/PIL_time.h
    trunk/blender/source/blender/blenlib/intern/string_utf8.c
    trunk/blender/source/blender/editors/transform/transform.h
    trunk/blender/source/gameengine/GameLogic/SCA_KeyboardSensor.h

Modified: trunk/blender/source/blender/blenfont/intern/blf_font.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_font.c	2011-10-21 00:48:02 UTC (rev 41163)
+++ trunk/blender/source/blender/blenfont/intern/blf_font.c	2011-10-21 01:33:06 UTC (rev 41164)
@@ -129,7 +129,7 @@
 		g= (glyph_ascii_table)[c];                                            \
 		i++;                                                                  \
 	}                                                                         \
-	else if ((c= blf_utf8_next((str), &(i))) != BLI_UTF8_ERR) {               \
+	else if ((c= BLI_str_utf8_as_unicode_step((str), &(i))) != BLI_UTF8_ERR) {               \
 		if ((g= blf_glyph_search((font)->glyph_cache, c)) == NULL) {          \
 			g= blf_glyph_add(font, FT_Get_Char_Index((font)->face, c), c);    \
 		}                                                                     \

Modified: trunk/blender/source/blender/blenfont/intern/blf_internal.h
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_internal.h	2011-10-21 00:48:02 UTC (rev 41163)
+++ trunk/blender/source/blender/blenfont/intern/blf_internal.h	2011-10-21 01:33:06 UTC (rev 41164)
@@ -40,7 +40,6 @@
 
 unsigned int blf_next_p2(unsigned int x);
 unsigned int blf_hash(unsigned int val);
-unsigned int blf_utf8_next(const char *buf, size_t *iindex);
 
 char *blf_dir_search(const char *file);
 char *blf_dir_metrics_search(const char *filename);

Modified: trunk/blender/source/blender/blenfont/intern/blf_util.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_util.c	2011-10-21 00:48:02 UTC (rev 41163)
+++ trunk/blender/source/blender/blenfont/intern/blf_util.c	2011-10-21 01:33:06 UTC (rev 41164)
@@ -64,67 +64,3 @@
 	key ^= (key >> 17);
 	return key % 257;
 }
-
-/*
- * This function is from Imlib2 library (font_main.c), a
- * library that does image file loading and saving as well
- * as rendering, manipulation, arbitrary polygon support, etc.
- *
- * Copyright (C) 2000 Carsten Haitzler and various contributors
- * The original name: imlib_font_utf8_get_next
- * more info here: http://docs.enlightenment.org/api/imlib2/html/
- */
-unsigned int blf_utf8_next(const char *buf, size_t *iindex)
-{
-	/* Reads UTF8 bytes from 'buf', starting at 'index' and
-	 * returns the code point of the next valid code point.
-	 * 'index' is updated ready for the next call.
-	 *
-	 * Returns 0 to indicate an error (e.g. invalid UTF8)
-	 */
-	int index= *iindex, len, r;
-	unsigned char d, d2, d3, d4;
-
-	d= buf[index++];
-	if (!d)
-		return BLI_UTF8_ERR;
-
-	while (buf[index] && ((buf[index] & 0xc0) == 0x80))
-		index++;
-
-	len= index - *iindex;
-	if (len == 1)
-		r= d;
-	else if (len == 2) {
-		/* 2 byte */
-		d2= buf[*iindex + 1];
-		r= d & 0x1f; /* copy lower 5 */
-		r <<= 6;
-		r |= (d2 & 0x3f); /* copy lower 6 */
-	}
-	else if (len == 3) {
-		/* 3 byte */
-		d2= buf[*iindex + 1];
-		d3= buf[*iindex + 2];
-		r= d & 0x0f; /* copy lower 4 */
-		r <<= 6;
-		r |= (d2 & 0x3f);
-		r <<= 6;
-		r |= (d3 & 0x3f);
-	}
-	else {
-		/* 4 byte */
-		d2= buf[*iindex + 1];
-		d3= buf[*iindex + 2];
-		d4= buf[*iindex + 3];
-		r= d & 0x0f; /* copy lower 4 */
-		r <<= 6;
-		r |= (d2 & 0x3f);
-		r <<= 6;
-		r |= (d3 & 0x3f);
-		r <<= 6;
-		r |= (d4 & 0x3f);
-	}
-	*iindex= index;
-	return r;
-}

Modified: trunk/blender/source/blender/blenkernel/intern/softbody.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/softbody.c	2011-10-21 00:48:02 UTC (rev 41163)
+++ trunk/blender/source/blender/blenkernel/intern/softbody.c	2011-10-21 01:33:06 UTC (rev 41164)
@@ -208,7 +208,7 @@
 	}
 	return (1.0f);
 	/*
-	this would be frames/sec independant timing assuming 25 fps is default
+	this would be frames/sec independent timing assuming 25 fps is default
 	but does not work very well with NLA
 		return (25.0f/scene->r.frs_sec)
 	*/

Modified: trunk/blender/source/blender/blenlib/PIL_time.h
===================================================================
--- trunk/blender/source/blender/blenlib/PIL_time.h	2011-10-21 00:48:02 UTC (rev 41163)
+++ trunk/blender/source/blender/blenlib/PIL_time.h	2011-10-21 01:33:06 UTC (rev 41164)
@@ -1,7 +1,5 @@
-/*
- * @file PIL_time.h
- * 
- * Platform independant time functions.
+/* 
+ * Platform independent time functions.
  * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
@@ -51,7 +49,7 @@
 double	PIL_check_seconds_timer		(void);
 
 	/**
-	 * Platform-independant sleep function.
+	 * Platform-independent sleep function.
 	 * @param ms Number of milliseconds to sleep
 	 */
 void	PIL_sleep_ms				(int ms);

Modified: trunk/blender/source/blender/blenlib/intern/string_utf8.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/string_utf8.c	2011-10-21 00:48:02 UTC (rev 41163)
+++ trunk/blender/source/blender/blenlib/intern/string_utf8.c	2011-10-21 01:33:06 UTC (rev 41164)
@@ -297,12 +297,12 @@
 		Len = -1;                                                             \
 	}
 
-
-#define UTF8_GET(Result, Chars, Count, Mask, Len)                             \
+/* same as glib define but added an 'Err' arg */
+#define UTF8_GET(Result, Chars, Count, Mask, Len, Err)                        \
 	(Result) = (Chars)[0] & (Mask);                                           \
 	for ((Count) = 1; (Count) < (Len); ++(Count)) {                           \
 		if (((Chars)[(Count)] & 0xc0) != 0x80) {                              \
-			(Result) = -1;                                                    \
+			(Result) = Err;                                                   \
 			break;                                                            \
 		}                                                                     \
 		(Result) <<= 6;                                                       \
@@ -332,7 +332,7 @@
   UTF8_COMPUTE (c, mask, len);
   if (len == -1)
     return BLI_UTF8_ERR;
-  UTF8_GET (result, p, i, mask, len);
+  UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR);
 
   return result;
 }
@@ -347,12 +347,13 @@
 	UTF8_COMPUTE (c, mask, len);
 	if (len == -1)
 		return BLI_UTF8_ERR;
-	UTF8_GET (result, p, i, mask, len);
+	UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR);
 	*index += len;
 	return result;
 }
 
-/* another varient that steps over the index */
+/* another varient that steps over the index,
+ * note, currently this also falls back to latin1 for text drawing. */
 unsigned int BLI_str_utf8_as_unicode_step(const char *p, size_t *index)
 {
 	int i, mask = 0, len;
@@ -372,7 +373,26 @@
 		*index += (size_t)(p_next - p);
 		return BLI_UTF8_ERR;
 	}
-	UTF8_GET (result, p, i, mask, len);
+
+	/* this is tricky since there are a few ways we can bail out of bad unicode
+	 * values, 3 possible solutions. */
+#if 0
+	UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR);
+#elif 1
+	/* WARNING: this is NOT part of glib, or supported by similar functions.
+	 * this is added for text drawing because some filepaths can have latin1
+	 * characters */
+	UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR);
+	if(result == BLI_UTF8_ERR) {
+		len= 1;
+		result= *p;
+	}
+	/* end warning! */
+#else
+	/* without a fallback like '?', text drawing will stop on this value */
+	UTF8_GET (result, p, i, mask, len, '?');
+#endif
+
 	*index += len;
 	return result;
 }

Modified: trunk/blender/source/blender/editors/transform/transform.h
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.h	2011-10-21 00:48:02 UTC (rev 41163)
+++ trunk/blender/source/blender/editors/transform/transform.h	2011-10-21 01:33:06 UTC (rev 41164)
@@ -152,7 +152,7 @@
 	float loc[3];		/* Location of data used to transform (x,y,0) */
 	float *loc2d;		/* Pointer to real 2d location of data */
 
-	float *h1, *h2;     /* Pointer to handle locations, if handles aren't being moved independantly*/
+	float *h1, *h2;     /* Pointer to handle locations, if handles aren't being moved independently */
 	float ih1[2], ih2[2];
 } TransData2D;
 

Modified: trunk/blender/source/gameengine/GameLogic/SCA_KeyboardSensor.h
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_KeyboardSensor.h	2011-10-21 00:48:02 UTC (rev 41163)
+++ trunk/blender/source/gameengine/GameLogic/SCA_KeyboardSensor.h	2011-10-21 01:33:06 UTC (rev 41164)
@@ -69,7 +69,7 @@
 	 * The property that indicates whether or not to log text when in
 	 * loggin mode. If the property equals 0, no loggin is done. For
 	 * all other values, logging is active. Logging can only become
-	 * active if there is a property to log to. Logging is independant
+	 * active if there is a property to log to. Logging is independent
 	 * from hotkey settings. */
 	STR_String	m_toggleprop;
 




More information about the Bf-blender-cvs mailing list