DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR Pending]

Link: http://www.fltk.org/str.php?L2221
Version: 1.3-feature
Fix Version: 1.3.0 (r6951)





Link: http://www.fltk.org/str.php?L2221
Version: 1.3-feature
Fix Version: 1.3.0 (r6951)
Index: src/fl_font_mac.cxx
===================================================================
--- src/fl_font_mac.cxx (revision 6985)
+++ src/fl_font_mac.cxx (working copy)
@@ -34,6 +34,9 @@
 #define check_default_font() {if (!fl_fontsize) fl_font(0, 12);}
 
 static const CGAffineTransform font_mx = { 1, 0, 0, -1, 0, 0 };
+#if defined(__APPLE_COCOA__)
+static SInt32 MACsystemVersion = 0;
+#endif
 
 Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) {
   next = 0;
@@ -47,7 +50,9 @@
   size = Size;
   minsize = maxsize = Size;
 #if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 
MAC_OS_X_VERSION_10_5
-if(CTFontCreateWithName != NULL) {
+  if(MACsystemVersion == 0) Gestalt(gestaltSystemVersion, &MACsystemVersion);
+
+if(MACsystemVersion >= 0x1050) {//unfortunately, CTFontCreateWithName != NULL 
on 10.4 also!
   CFStringRef str = CFStringCreateWithCString(NULL, name, 
kCFStringEncodingUTF8);
   fontref = CTFontCreateWithName(str, size, NULL);
   CGGlyph glyph[2];
@@ -58,11 +63,11 @@
   CTFontGetAdvancesForGlyphs(fontref, kCTFontHorizontalOrientation, glyph, 
advances, 2);
   w = advances[0].width;
   if( abs(advances[0].width - advances[1].width) < 1E-2 ) {//this is a 
fixed-width font
-       //slightly rescale fixed-width fonts so the character width has an 
integral value
-       CFRelease(fontref);
-       CGFloat fsize = size / ( w/floor(w + 0.5) );
-       fontref = CTFontCreateWithName(str, fsize, NULL);
-       w = CTFontGetAdvancesForGlyphs(fontref, kCTFontHorizontalOrientation, 
glyph, NULL, 1);
+    //slightly rescale fixed-width fonts so the character width has an 
integral value
+    CFRelease(fontref);
+    CGFloat fsize = size / ( w/floor(w + 0.5) );
+    fontref = CTFontCreateWithName(str, fsize, NULL);
+    w = CTFontGetAdvancesForGlyphs(fontref, kCTFontHorizontalOrientation, 
glyph, NULL, 1);
   }
   CFRelease(str);
   ascent = (short)(CTFontGetAscent(fontref) + 0.5);
@@ -165,7 +170,7 @@
   */
   if (this == fl_fontsize) fl_fontsize = 0;
 #if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 
MAC_OS_X_VERSION_10_5
-  if(CTFontCreateWithName != NULL)  CFRelease(fontref);
+  if(MACsystemVersion >= 0x1050)  CFRelease(fontref);
 #else
        /*  ATSUDisposeTextLayout(layout);
   ATSUDisposeStyle(style); */
@@ -272,7 +277,7 @@
       return 8*n; // user must select a font first!
   }
 #if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 
MAC_OS_X_VERSION_10_5
-if(CTFontCreateWithName != NULL) {
+if(MACsystemVersion >= 0x1050) {
   CTFontRef fontref = fl_fontsize->fontref;
   CFStringRef str = CFStringCreateWithBytes(NULL, (const UInt8*)txt, n * 
sizeof(UniChar), kCFStringEncodingUTF16, false);
   CFAttributedStringRef astr = CFAttributedStringCreate(NULL, str, NULL);
@@ -340,7 +345,7 @@
       return;
   }
 #if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 
MAC_OS_X_VERSION_10_5
-if(CTFontCreateWithName != NULL) {
+if(MACsystemVersion >= 0x1050) {
   CTFontRef fontref = fl_fontsize->fontref;
   CFStringRef str16 = CFStringCreateWithBytes(NULL, (const UInt8*)txt, n 
*sizeof(UniChar), kCFStringEncodingUTF16, false);
   CFAttributedStringRef astr = CFAttributedStringCreate(NULL, str16, NULL);
@@ -444,7 +449,7 @@
   // convert to UTF-16 first
   UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n);
 #if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 
MAC_OS_X_VERSION_10_5
-  if(CTFontCreateWithName != NULL) {
+  if(MACsystemVersion >= 0x1050) {
     CFStringRef keys[2];
     CFTypeRef values[2];  
     CFStringRef str16 = CFStringCreateWithBytes(NULL, (const UInt8*)uniStr, n 
* sizeof(UniChar), kCFStringEncodingUTF16, false);
Index: src/fl_set_fonts_mac.cxx
===================================================================
--- src/fl_set_fonts_mac.cxx    (revision 6991)
+++ src/fl_set_fonts_mac.cxx    (working copy)
@@ -61,10 +61,14 @@
 Fl_Font Fl::set_fonts(const char* xstarname) {
 #pragma unused ( xstarname )
 #if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 
MAC_OS_X_VERSION_10_5
-if(CTFontCreateWithFontDescriptor != NULL) {
+static SInt32 MACsystemVersion = 0;
+if(MACsystemVersion == 0) Gestalt(gestaltSystemVersion, &MACsystemVersion);
+if(MACsystemVersion >= 0x1050) {
+//if(CTFontCreateWithFontDescriptor != NULL) {// 
CTFontCreateWithFontDescriptor != NULL on 10.4 also!
   int value[1] = {1};
-  CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void 
**)kCTFontCollectionRemoveDuplicatesOption, 
-                                                                               
        (const void **)&value, 1, NULL, NULL);
+  CFDictionaryRef dict = CFDictionaryCreate(NULL, 
+                                           (const void 
**)kCTFontCollectionRemoveDuplicatesOption, 
+                                           (const void **)&value, 1, NULL, 
NULL);
   CTFontCollectionRef fcref = CTFontCollectionCreateFromAvailableFonts(dict);
   CFRelease(dict);
   CFArrayRef arrayref = CTFontCollectionCreateMatchingFontDescriptors(fcref);
Index: src/fl_draw_pixmap.cxx
===================================================================
--- src/fl_draw_pixmap.cxx      (revision 6985)
+++ src/fl_draw_pixmap.cxx      (working copy)
@@ -336,7 +336,7 @@
       }
     } else {
       for (int X = 0; X < d.w; X++) {
-        U32* colors = d.byte1[*p++];
+        U32* colors = (U32*)d.byte1[*p++];
         *q++ = colors[*p++];
       }
     }
Index: src/Fl_cocoa.mm
===================================================================
--- src/Fl_cocoa.mm     (revision 7011)
+++ src/Fl_cocoa.mm     (working copy)
@@ -122,7 +122,6 @@
 // forward declarations of variables in this file
 static int got_events = 0;
 static Fl_Window* resize_from_system;
-static NSView *viewWithLockedFocus = nil;
 static SInt32 MACsystemVersion;
 
 #if CONSOLIDATE_MOTION
@@ -1533,13 +1532,7 @@
 void Fl_X::flush()
 {
   w->flush();
-  if (fl_gc) {
-    CGContextFlush(fl_gc);
-    if (viewWithLockedFocus) {
-      [viewWithLockedFocus unlockFocus];
-      viewWithLockedFocus = nil;
-    }
-  }
+  if (fl_gc) CGContextFlush(fl_gc);
 }
 
 /*
@@ -2222,8 +2215,8 @@
     win = (Fl_Window*)win->window();
   }
   
-  viewWithLockedFocus = [(NSWindow*)i->xid contentView];
-  [viewWithLockedFocus lockFocusIfCanDraw];// important
+  [[NSView focusView] unlockFocus];
+  [[(NSWindow*)i->xid contentView]  lockFocus];
   i->gc = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
   fl_gc = i->gc;
   if ( fl_window_region ) XDestroyRegion(fl_window_region);
_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to