ecere:gui/gfx:drivers/cocoa: Partial native Cocoa drivers implementation for Mac...
[sdk] / ecere / src / gfx / drivers / LFBDisplayDriver.ec
index b307f91..322216e 100644 (file)
@@ -4,6 +4,7 @@ namespace gfx::drivers;
 #define ECERE_NOTRUETYPE
 #endif
 
+#undef __BLOCKS__
 #define uint _uint
 #if !defined(ECERE_NOTRUETYPE)
 #include <ft2build.h>
@@ -60,7 +61,6 @@ import "Direct3D9DisplayDriver"
 #define MAX_FONT_LINK_ENTRIES   10
 
 static HB_Script theCurrentScript;
-static DisplaySystem theDisplaySystem;
 
 static unichar UTF16GetChar(uint16 *string, int * nw)
 {
@@ -121,7 +121,7 @@ static void hb_getAdvances(HB_Font font, const HB_Glyph * glyphs, uint numGlyphs
          if(!pack)
          {
             glFont.glyphPacks.Add((pack = GlyphPack { key = packNo }));
-            pack.Render(glFont, fontEntryNum, theDisplaySystem);
+            pack.Render(glFont, fontEntryNum, glFont.displaySystem);
             pack.bitmap.alphaBlend = true;
          }
          lastPack = packNo;
@@ -208,7 +208,7 @@ static void hb_getGlyphMetrics(HB_Font font, HB_Glyph theGlyph, HB_GlyphMetrics
          {
             pack = { key = packNo };
             glFont.glyphPacks.Add(pack);
-            pack.Render(glFont, fontEntryNum, theDisplaySystem);
+            pack.Render(glFont, fontEntryNum, glFont.displaySystem);
             pack.bitmap.alphaBlend = true;
          }
          lastPack = packNo;
@@ -687,6 +687,7 @@ public class Font : struct
    int height;
    FontFlags flags;
    char faceName[512];
+   DisplaySystem displaySystem;
    int ascent;
    float scale;
 
@@ -2794,6 +2795,7 @@ public class LFBDisplayDriver : DisplayDriver
          strcpy(fileName, faceName);
          strcpy(font.faceName, faceName);
          font.flags = flags;
+         font.displaySystem = displaySystem;
 
          if(!FileExists(fileName))
          {
@@ -3035,7 +3037,7 @@ public class LFBDisplayDriver : DisplayDriver
                         matrix.yy = (FT_Fixed)( 1.0 * 0x10000L );
                         FT_Set_Transform(fontEntry.face, &matrix, &pen );
                      }
-                     FT_Set_Char_Size( fontEntry.face, (int)(size * 64), (int)(size * 64), 96, 96);
+                     FaceSetCharSize(fontEntry.face, size);
                      font.height = ((fontEntry.face->size->metrics.height) >> 6); //* y_scale;
                      // printf("Font height is %d\n", font.height);
                      font.fakeItalic = fakeItalic;
@@ -3158,7 +3160,6 @@ public class LFBDisplayDriver : DisplayDriver
          int glyphScript = 0;
          FontEntry curFontEntry;
          
-         theDisplaySystem = displaySystem;
          pack.bitmap.alphaBlend = true;
 
          for(c = 0; c < len || (numGlyphs && (rightToLeft ? (glyphIndex >= 0) : (glyphIndex < numGlyphs)));)
@@ -3424,7 +3425,7 @@ public class LFBDisplayDriver : DisplayDriver
                      }
                      if(fontEntry)
                      {
-                        FT_Set_Char_Size( fontEntry.face, (int)(font.size * 64), (int)(font.size * 64), 96, 96);
+                        FaceSetCharSize(fontEntry.face, font.size);
 
                         font.fontEntries[fontEntryNum] = fontEntry;
                         fontEntry.used++;