Author: manolo
Date: 2011-01-24 12:05:34 -0800 (Mon, 24 Jan 2011)
New Revision: 8309
Log:
Fix STR #2530 (Mac OS only)-continued. Use 512 blocks of 128 character widths
(instead of 256x256) because this reduces greatly the opening time of windows
with several new fonts.

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

Modified: branches/branch-1.3/src/Fl_Font.H
===================================================================
--- branches/branch-1.3/src/Fl_Font.H   2011-01-24 19:48:36 UTC (rev 8308)
+++ branches/branch-1.3/src/Fl_Font.H   2011-01-24 20:05:34 UTC (rev 8309)
@@ -63,8 +63,8 @@
   ATSUTextLayout layout;
 #     if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
   CTFontRef fontref;
-  // the unicode span is divided in 256 blocks of 256 characters
-  float *width[256]; // array of arrays of character widths
+  // the unicode span is divided in 512 blocks of 128 characters
+  float *width[512]; // array of arrays of character widths
 #     endif
   ATSUStyle style;
   short ascent, descent, q_width;

Modified: branches/branch-1.3/src/fl_font_mac.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_mac.cxx     2011-01-24 19:48:36 UTC (rev 
8308)
+++ branches/branch-1.3/src/fl_font_mac.cxx     2011-01-24 20:05:34 UTC (rev 
8309)
@@ -312,15 +312,15 @@
       i++; // because a pair of UniChar's represent a single character
       continue;
       }
-    unsigned int r = uni >> 8; // index of the character block containing uni
+    unsigned int r = uni >> 7; // index of the character block containing uni
     if (!fl_fontsize->width[r]) { // this character block has not been hit yet
 //fprintf(stderr,"r=%d size=%d name=%s\n",r,fl_fontsize->size, 
fl_fontsize->q_name);
       // allocate memory to hold width of each character in the block
-      fl_fontsize->width[r] = (float*) malloc(sizeof(float) * 0x100);
-      UniChar ii = r * 0x100;
+      fl_fontsize->width[r] = (float*) malloc(sizeof(float) * 0x80);
+      UniChar ii = r * 0x80;
       CGGlyph glyph;
       CGSize advance_size;
-      for (int j = 0; j < 0x100; j++) { // loop over the block
+      for (int j = 0; j < 0x80; j++) { // loop over the block
        CTFontRef font2 = fl_fontsize->fontref;
        bool must_release = false;
        // ii spans all characters of this block
@@ -342,7 +342,7 @@
       }
     }
     // sum the widths of all characters of txt
-    retval += fl_fontsize->width[r][uni & 0xFF];
+    retval += fl_fontsize->width[r][uni & 0x7F];
   }
   return retval;
 } else {

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

Reply via email to