ecere/gfx/fontRendering: Improved rendering of some fonts e.g. MS Sans Serif having...
authorJerome St-Louis <jerome@ecere.com>
Thu, 4 Aug 2016 09:37:39 +0000 (05:37 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 4 Aug 2016 09:38:19 +0000 (05:38 -0400)
- Also avoided a crash on null font

ecere/src/gfx/drivers/OpenGLDisplayDriver.ec
ecere/src/gfx/fontRendering.ec

index 18b9b6f..289d981 100644 (file)
@@ -2688,7 +2688,7 @@ class OpenGLDisplayDriver : DisplayDriver
 
    void WriteText(Display display, Surface surface, int x, int y, const char * text, int len, int prevGlyph, int * rPrevGlyph)
    {
-      if(len && text[0])
+      if(len && text[0] && surface.font)
       {
          OGLSurface oglSurface = surface.driverData;
          OGLSystem oglSystem = display.displaySystem.driverData;
index f94edda..8cdf1d6 100644 (file)
@@ -879,6 +879,8 @@ public class Font : struct
                FT_Set_Transform(fontEntry.face, &matrix, &pen );
                FaceSetCharSize(fontEntry.face, size);
                height = (int)((fontEntry.face->size->metrics.height) >> 6); //* y_scale;
+               if(!height)
+                  height = size * 96 / 72 + 4;
                // printf("Font height is %d\n", height);
                this.fakeItalic = info.fakeItalic;
             }
@@ -1183,6 +1185,8 @@ public class Font : struct
                   int h = (int)face->size->metrics.height;
                   int desc = (int)face->size->metrics.descender;
                   int oy = (numGlyphs ? shaper_item.offsets[index].y : 0);
+                  if(!h)
+                     h = height * 64;
 
                   oy += h + desc - glyph->by;
                   oy >>= 6;