From 5d0a207ecb843c4c73be897cfccbf3a0d2db574b Mon Sep 17 00:00:00 2001 From: Chris Want Date: Wed, 16 Apr 2008 22:40:48 +0000 Subject: Patch from GSR that a) fixes a whole bunch of GPL/BL license blocks that were previously missed; and b) greatly increase my ohloh stats! --- source/blender/ftfont/CMakeLists.txt | 9 +++------ source/blender/ftfont/FTF_Api.h | 9 +++------ source/blender/ftfont/FTF_Settings.h | 9 +++------ source/blender/ftfont/Makefile | 9 +++------ source/blender/ftfont/intern/FTF_Api.cpp | 9 +++------ source/blender/ftfont/intern/FTF_TTFont.cpp | 9 +++------ source/blender/ftfont/intern/FTF_TTFont.h | 9 +++------ source/blender/ftfont/intern/Makefile | 9 +++------ 8 files changed, 24 insertions(+), 48 deletions(-) (limited to 'source/blender/ftfont') diff --git a/source/blender/ftfont/CMakeLists.txt b/source/blender/ftfont/CMakeLists.txt index 7b89416bbe1..134796d0799 100644 --- a/source/blender/ftfont/CMakeLists.txt +++ b/source/blender/ftfont/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC intern/*.cpp) diff --git a/source/blender/ftfont/FTF_Api.h b/source/blender/ftfont/FTF_Api.h index 0793c4b6dfb..8b04f5c09c1 100644 --- a/source/blender/ftfont/FTF_Api.h +++ b/source/blender/ftfont/FTF_Api.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _FTF_API_H diff --git a/source/blender/ftfont/FTF_Settings.h b/source/blender/ftfont/FTF_Settings.h index dc325c1de41..ff9d78e3f58 100644 --- a/source/blender/ftfont/FTF_Settings.h +++ b/source/blender/ftfont/FTF_Settings.h @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ /** diff --git a/source/blender/ftfont/Makefile b/source/blender/ftfont/Makefile index 1717fa34853..73f75e77e73 100644 --- a/source/blender/ftfont/Makefile +++ b/source/blender/ftfont/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # Bounces make to subdirectories. diff --git a/source/blender/ftfont/intern/FTF_Api.cpp b/source/blender/ftfont/intern/FTF_Api.cpp index bf6698a1cde..c8f779e5d5e 100644 --- a/source/blender/ftfont/intern/FTF_Api.cpp +++ b/source/blender/ftfont/intern/FTF_Api.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ /** diff --git a/source/blender/ftfont/intern/FTF_TTFont.cpp b/source/blender/ftfont/intern/FTF_TTFont.cpp index 34b22e5c9d2..77bfff5bd82 100644 --- a/source/blender/ftfont/intern/FTF_TTFont.cpp +++ b/source/blender/ftfont/intern/FTF_TTFont.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/blender/ftfont/intern/FTF_TTFont.h b/source/blender/ftfont/intern/FTF_TTFont.h index b5ff1cc54bf..51247a2d2a1 100644 --- a/source/blender/ftfont/intern/FTF_TTFont.h +++ b/source/blender/ftfont/intern/FTF_TTFont.h @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ /** diff --git a/source/blender/ftfont/intern/Makefile b/source/blender/ftfont/intern/Makefile index 4668241c5c8..6bddda9a25c 100644 --- a/source/blender/ftfont/intern/Makefile +++ b/source/blender/ftfont/intern/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # -- cgit v1.2.3 From 28c2d1b2aecf5b8faa7cfe0b0934b5fb1a1b96ff Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Thu, 24 Apr 2008 18:54:59 +0000 Subject: Interface --------- Bugfix #9222. Conversion from UTF-8 to wchar for international fonts did not check for valid encodings, so user strings with containing invalid characters could cause crashes. --- source/blender/ftfont/intern/FTF_TTFont.cpp | 90 +++++++++++++++++------------ 1 file changed, 52 insertions(+), 38 deletions(-) (limited to 'source/blender/ftfont') diff --git a/source/blender/ftfont/intern/FTF_TTFont.cpp b/source/blender/ftfont/intern/FTF_TTFont.cpp index 77bfff5bd82..6661031f6fc 100644 --- a/source/blender/ftfont/intern/FTF_TTFont.cpp +++ b/source/blender/ftfont/intern/FTF_TTFont.cpp @@ -48,48 +48,62 @@ #define FTF_MAX_STR_SIZE 512 +/* 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. + +*/ int utf8towchar(wchar_t *w, char *c) { - int len=0; - if(w==NULL || c==NULL) return(0); - //printf("%s\n",c); - while(*c) - { - //Converts Unicode to wchar: - - if(*c & 0x80) - { - if(*c & 0x40) - { - if(*c & 0x20) - { - if(*c & 0x10) - { - *w=(c[0] & 0x0f)<<18 | (c[1]&0x1f)<<12 | (c[2]&0x3f)<<6 | (c[3]&0x7f); - c++; - } - else - *w=(c[0] & 0x1f)<<12 | (c[1]&0x3f)<<6 | (c[2]&0x7f); - c++; - } - else - *w=(c[0] &0x3f)<<6 | c[1]&0x7f; - c++; - } - else - *w=(c[0] & 0x7f); - } - else - *w=(c[0] & 0x7f); - - c++; - w++; - len++; - } - return len; -} + 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; +} FTF_TTFont::FTF_TTFont(void) { -- cgit v1.2.3 From f4cb93bf1fea43dc6dda8e48eb2316d6b5b1895c Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Fri, 25 Apr 2008 17:11:37 +0000 Subject: Remove redundant utf8towchar() from FTGL code. --- source/blender/ftfont/intern/FTF_TTFont.cpp | 71 ++++------------------------- 1 file changed, 9 insertions(+), 62 deletions(-) (limited to 'source/blender/ftfont') diff --git a/source/blender/ftfont/intern/FTF_TTFont.cpp b/source/blender/ftfont/intern/FTF_TTFont.cpp index 6661031f6fc..a34ab39365d 100644 --- a/source/blender/ftfont/intern/FTF_TTFont.cpp +++ b/source/blender/ftfont/intern/FTF_TTFont.cpp @@ -32,6 +32,10 @@ #include "libintl.h" #include "BLI_blenlib.h" +extern "C" { +#include "BKE_font.h" +} + #include "../FTF_Settings.h" #include "FTF_TTFont.h" @@ -48,63 +52,6 @@ #define FTF_MAX_STR_SIZE 512 -/* 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. - -*/ - -int utf8towchar(wchar_t *w, 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; -} - FTF_TTFont::FTF_TTFont(void) { #ifdef __APPLE__ @@ -345,9 +292,9 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag) /* note; this utf8towchar() function I totally don't understand... without using translations it removes special characters completely. So, for now we just skip that then. (ton) */ if (FTF_USE_GETTEXT & flag) - utf8towchar(wstr, gettext(str)); + utf8towchar_(wstr, gettext(str)); else if (FTF_INPUT_UTF8 & flag) - utf8towchar(wstr, str); + utf8towchar_(wstr, str); glGetFloatv(GL_CURRENT_COLOR, color); @@ -404,7 +351,7 @@ float FTF_TTFont::GetStringWidth(char* str, unsigned int flag) removes special characters completely. So, for now we just skip that then. (ton) */ if (FTF_USE_GETTEXT & flag) { - len=utf8towchar(wstr, gettext(str)); + len=utf8towchar_(wstr, gettext(str)); if(mode == FTF_PIXMAPFONT) { return font->Advance(wstr); @@ -430,9 +377,9 @@ void FTF_TTFont::GetBoundingBox(char* str, float *llx, float *lly, float *llz, f int len=0; if (FTF_USE_GETTEXT & flag) - len=utf8towchar(wstr,gettext(str)); + len=utf8towchar_(wstr,gettext(str)); else - len=utf8towchar(wstr,str); + len=utf8towchar_(wstr,str); font->BBox(wstr, *llx, *lly, *llz, *urx, *ury, *urz); } -- cgit v1.2.3 From bc18e9e2908cad1d416c101f9aa07c29fdaed7c0 Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Fri, 25 Apr 2008 19:18:24 +0000 Subject: Suggestion by GSR; move "extern C" into header file, remove "_" from utf8towchar function name. --- source/blender/ftfont/intern/FTF_TTFont.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'source/blender/ftfont') diff --git a/source/blender/ftfont/intern/FTF_TTFont.cpp b/source/blender/ftfont/intern/FTF_TTFont.cpp index a34ab39365d..e8f2b82f970 100644 --- a/source/blender/ftfont/intern/FTF_TTFont.cpp +++ b/source/blender/ftfont/intern/FTF_TTFont.cpp @@ -31,10 +31,7 @@ #include #include "libintl.h" #include "BLI_blenlib.h" - -extern "C" { #include "BKE_font.h" -} #include "../FTF_Settings.h" @@ -292,9 +289,9 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag) /* note; this utf8towchar() function I totally don't understand... without using translations it removes special characters completely. So, for now we just skip that then. (ton) */ if (FTF_USE_GETTEXT & flag) - utf8towchar_(wstr, gettext(str)); + utf8towchar(wstr, gettext(str)); else if (FTF_INPUT_UTF8 & flag) - utf8towchar_(wstr, str); + utf8towchar(wstr, str); glGetFloatv(GL_CURRENT_COLOR, color); @@ -351,7 +348,7 @@ float FTF_TTFont::GetStringWidth(char* str, unsigned int flag) removes special characters completely. So, for now we just skip that then. (ton) */ if (FTF_USE_GETTEXT & flag) { - len=utf8towchar_(wstr, gettext(str)); + len=utf8towchar(wstr, gettext(str)); if(mode == FTF_PIXMAPFONT) { return font->Advance(wstr); @@ -377,9 +374,9 @@ void FTF_TTFont::GetBoundingBox(char* str, float *llx, float *lly, float *llz, f int len=0; if (FTF_USE_GETTEXT & flag) - len=utf8towchar_(wstr,gettext(str)); + len=utf8towchar(wstr,gettext(str)); else - len=utf8towchar_(wstr,str); + len=utf8towchar(wstr,str); font->BBox(wstr, *llx, *lly, *llz, *urx, *ury, *urz); } -- cgit v1.2.3