Author: manolo
Date: 2011-01-24 13:58:44 -0800 (Mon, 24 Jan 2011)
New Revision: 8311
Log:
Fix STR #2530 (Mac OS only)-continued. Change to allow display of the surrogate 
zone of UniChar.


Modified:
   branches/branch-1.3/src/fl_font_mac.cxx

Modified: branches/branch-1.3/src/fl_font_mac.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_mac.cxx     2011-01-24 21:00:17 UTC (rev 
8310)
+++ branches/branch-1.3/src/fl_font_mac.cxx     2011-01-24 21:58:44 UTC (rev 
8311)
@@ -474,9 +474,11 @@
 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 @@
   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));

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to