From 303e3e9748b6e1970c06203c192ea1b2743f10df Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 28 Sep 2005 10:35:55 +0000 Subject: [PATCH] Use _cairo_utf8_to_utf16 for character conversion. --- ChangeLog | 5 +++++ src/cairo-atsui-font.c | 24 ++++++------------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98bed97da..8978b5bb1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-09-28 T Rowley + + * src/cairo-atsui-font.c (_cairo_atsui_font_text_to_glyphs): + Use _cairo_utf8_to_utf16 for character conversion. + 2005-09-28 T Rowley * ROADMAP: Note that Bug #4612 (Text not being drawn if first diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c index 84b7ea19a..5eebae647 100644 --- a/src/cairo-atsui-font.c +++ b/src/cairo-atsui-font.c @@ -38,9 +38,6 @@ #include "cairo-atsui.h" #include "cairoint.h" #include "cairo.h" -#if 0 -#include -#endif /* * FixedToFloat/FloatToFixed are 10.3+ SDK items - include definitions @@ -245,8 +242,10 @@ _cairo_atsui_font_text_to_glyphs(void *abstract_font, OSStatus err; ATSUTextLayout textLayout; ATSLayoutRecord *layoutRecords; - ItemCount glyphCount, charCount; + ItemCount glyphCount; + int charCount; UniChar *theText; + cairo_status_t status; // liberal estimate of size charCount = strlen(utf8); @@ -257,20 +256,9 @@ _cairo_atsui_font_text_to_glyphs(void *abstract_font, return CAIRO_STATUS_SUCCESS; } - // Set the text in the text layout object, so we can measure it - theText = (UniChar *) malloc(charCount * sizeof(UniChar)); - -#if 1 - for (i = 0; i < charCount; i++) { - theText[i] = utf8[i]; - } -#endif - -#if 0 - size_t inBytes = charCount, outBytes = charCount; - iconv_t converter = iconv_open("UTF-8", "UTF-16"); - charCount = iconv(converter, utf8, &inBytes, theText, &outBytes); -#endif + status = _cairo_utf8_to_utf16 (utf8, -1, &theText, &charCount); + if (status) + return status; err = ATSUCreateTextLayout(&textLayout);