aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Font.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Font.cc')
-rw-r--r--src/FbTk/Font.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc
index 8ba5a0a..bf07ee0 100644
--- a/src/FbTk/Font.cc
+++ b/src/FbTk/Font.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22//$Id: Font.cc,v 1.15 2004/08/31 20:27:08 fluxgen Exp $ 22//$Id: Font.cc,v 1.16 2004/08/31 21:24:05 fluxgen Exp $
23 23
24 24
25#include "StringUtil.hh" 25#include "StringUtil.hh"
@@ -119,8 +119,15 @@ char* recode(iconv_t cd,
119 char *new_msg_ptr = new_msg; 119 char *new_msg_ptr = new_msg;
120 char *msg_ptr = strdup(msg); 120 char *msg_ptr = strdup(msg);
121 char *orig_msg_ptr = msg_ptr; // msg_ptr modified in iconv call 121 char *orig_msg_ptr = msg_ptr; // msg_ptr modified in iconv call
122 size_t result = (size_t)(-1);
122 123
123 if (iconv(cd, &msg_ptr, &inbytesleft, &new_msg, &outbytesleft) == -1) { 124#ifdef HAVE_CONST_ICONV
125 result = iconv(cd, const_cast<char **>(&msg_ptr), &inbytesleft, &new_msg, &outbytesleft);
126#else
127 result = iconv(cd, &msg_ptr, &inbytesleft, &new_msg, &outbytesleft);
128#endif // HAVE_CONST_ICONV
129
130 if (result == (size_t)(-1)) {
124 // iconv can fail for three reasons 131 // iconv can fail for three reasons
125 // 1) Invalid multibyte sequence is encountered in the input 132 // 1) Invalid multibyte sequence is encountered in the input
126 // 2) An incomplete multibyte sequence 133 // 2) An incomplete multibyte sequence
@@ -143,7 +150,7 @@ char* recode(iconv_t cd,
143} 150}
144#else 151#else
145 152
146char *recode(iconv_t cd, 153char *recode(int cd,
147 const char *msg, size_t size) { 154 const char *msg, size_t size) {
148 return 0; 155 return 0;
149} 156}
@@ -232,8 +239,13 @@ Font::Font(const char *name, bool antialias):
232 m_antialias(false), m_rotated(false), 239 m_antialias(false), m_rotated(false),
233 m_shadow(false), m_shadow_color("#000000"), 240 m_shadow(false), m_shadow_color("#000000"),
234 m_shadow_offx(1), m_shadow_offy(1), 241 m_shadow_offx(1), m_shadow_offy(1),
235 m_halo(false), m_halo_color("#ffffff"), 242 m_halo(false), m_halo_color("#ffffff") {
236 m_iconv((iconv_t)-1) { 243
244#ifdef HAVE_ICONV
245 m_iconv = (iconv_t)(-1);
246#else
247 m_iconv = -1;
248#endif // HAVE_ICONV
237 249
238 // MB_CUR_MAX returns the size of a char in the current locale 250 // MB_CUR_MAX returns the size of a char in the current locale
239 if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte 251 if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte
@@ -252,6 +264,8 @@ Font::Font(const char *name, bool antialias):
252#ifdef DEBUG 264#ifdef DEBUG
253 cerr<<"FbTk::Font: check UTF-8 convert for codeset = "<<locale_codeset<<endl; 265 cerr<<"FbTk::Font: check UTF-8 convert for codeset = "<<locale_codeset<<endl;
254#endif // DEBUG 266#endif // DEBUG
267
268#ifdef HAVE_ICONV
255 m_iconv = iconv_open("UTF-8", locale_codeset); 269 m_iconv = iconv_open("UTF-8", locale_codeset);
256 if(m_iconv == (iconv_t)(-1)) { 270 if(m_iconv == (iconv_t)(-1)) {
257 cerr<<"FbTk::Font: code error: from "<<locale_codeset<<" to: UTF-8"<<endl; 271 cerr<<"FbTk::Font: code error: from "<<locale_codeset<<" to: UTF-8"<<endl;
@@ -266,6 +280,7 @@ Font::Font(const char *name, bool antialias):
266 m_utf8mode = true; 280 m_utf8mode = true;
267 } 281 }
268 } 282 }
283#endif // HAVE_ICONV
269 284
270#ifdef DEBUG 285#ifdef DEBUG
271 cerr<<"FbTk::Font m_iconv = "<<(int)m_iconv<<endl; 286 cerr<<"FbTk::Font m_iconv = "<<(int)m_iconv<<endl;