From ece27e347c12b05feb8aa74ea809120b6f2f2519 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 24 Jan 2011 21:58:44 +0000 Subject: Fix STR #2530 (Mac OS only)-continued. Change to allow display of the surrogate zone of UniChar. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8311 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/fl_font_mac.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx index 9a7f086b6..222cc6a98 100644 --- a/src/fl_font_mac.cxx +++ b/src/fl_font_mac.cxx @@ -474,9 +474,11 @@ static CGColorRef flcolortocgcolor(Fl_Color i) void fl_draw(const char *str, int n, float x, float y) { // avoid a crash if no font has been selected by user yet ! check_default_font(); + // convert to UTF-16 first + UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if (fl_mac_os_version >= 0x1050) { - CFStringRef str16 = CFStringCreateWithBytes(NULL, (const UInt8*)str, n, kCFStringEncodingUTF8, false); + CFStringRef str16 = CFStringCreateWithBytes(NULL, (const UInt8*)uniStr, n * sizeof(UniChar), kCFStringEncodingUTF16, false); CGColorRef color = flcolortocgcolor(fl_color()); CFDictionarySetValue (attributes, kCTFontAttributeName, fl_fontsize->fontref); CFDictionarySetValue (attributes, kCTForegroundColorAttributeName, color); @@ -503,8 +505,6 @@ void fl_draw(const char *str, int n, float x, float y) { ATSUAttributeValuePtr iValuePtr=&fl_gc; ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr); - // convert to UTF-16 first - UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n); err = ATSUSetTextPointerLocation(layout, uniStr, kATSUFromTextBeginning, n, n); CGContextSetShouldAntialias(fl_gc, true); err = ATSUDrawText(layout, kATSUFromTextBeginning, n, FloatToFixed(x), FloatToFixed(y)); -- cgit v1.2.3