ecere/gfx/newFonts: Supporting 2 pass outlines for other cases
authorJerome St-Louis <jerome@ecere.com>
Mon, 25 Apr 2016 11:46:22 +0000 (07:46 -0400)
committerJerome St-Louis <jerome@ecere.com>
Mon, 21 Nov 2016 14:18:47 +0000 (09:18 -0500)
ecere/src/gfx/newFonts/fmFontManager.ec
ecere/src/gfx/newFonts/fontRenderer.ec

index ec70ed2..dc91677 100644 (file)
@@ -260,7 +260,7 @@ public:
    // If the renderer records per-image data, return an imageIndex passed to drawImage()
    virtual int registerImage( int offsetx, int offsety, int width, int height );
    // Draw an image, imageIndex passed as the value previously returned by registerImage()
-   virtual void drawImage( int targetx, int targety, int imageIndex );
+   virtual void drawImage( int targetx, int targety, int imageIndex, bool useExtColor );
    // Draw an image, called instead of drawImage() for text cursors, can point to exactly the same function
    virtual void drawImageCursor( int targetx, int targety, int imageIndex );
    // If drawImage is zero, then this alternate function is called, passing everything required to render the glyph
@@ -796,12 +796,12 @@ public class FontManager
      return glyph;
    }
 
-   static inline void drawTextGlyph( FMFont font, FMGlyph *glyph, int x, int y )
+   static inline void drawTextGlyph( FMFont font, FMGlyph *glyph, int x, int y, bool useExtColor )
    {
       int ptx = x + glyph->offsetx;
       int pty = y + glyph->offsety;
       if( renderer.drawImage )
-         renderer.drawImage( ptx, pty, glyph->imageIndex );
+         renderer.drawImage( ptx, pty, glyph->imageIndex, useExtColor );
       else if( renderer.drawImageAlt )
          renderer.drawImageAlt( texdata, ptx, pty, glyph->x0, glyph->y0, glyph->x1 - glyph->x0, glyph->y1 - glyph->y0 );
    }
@@ -1110,7 +1110,15 @@ public:
        if( glyph )
        {
          font.addKerning(prevGlyphIndex, glyph, &x, &subpixel );
-         drawTextGlyph(font, glyph, x, y );
+#if !defined(SHADERS)
+         if(font.processImage)
+         {
+            FMGlyph *outlineGlyph = getGlyph(font, codepoint, state->size, subpixel, blurradius, blurscale, true );
+            if(outlineGlyph)
+               drawTextGlyph(font, outlineGlyph, x, y, true );
+         }
+#endif
+         drawTextGlyph(font, glyph, x, y, false );
          addGlyphAdvance( &x, &subpixel, glyph );
        }
        prevGlyphIndex = ( glyph ? glyph->glyphindex : -1 );
@@ -1168,7 +1176,15 @@ public:
        if( glyph )
        {
          font.addKerning(prevGlyphIndex, glyph, &x, &subpixel );
-         drawTextGlyph(font, glyph, x, y );
+#if !defined(SHADERS)
+         if(font.processImage)
+         {
+            FMGlyph *outlineGlyph = getGlyph(font, codepoint, state->size, subpixel, blurradius, blurscale, true );
+            if(outlineGlyph)
+               drawTextGlyph(font, outlineGlyph, x, y, true );
+         }
+#endif
+         drawTextGlyph(font, glyph, x, y, false );
          addGlyphAdvance( &x, &subpixel, glyph );
        }
        prevGlyphIndex = ( glyph ? glyph->glyphindex : -1 );
@@ -1229,7 +1245,15 @@ public:
        if( glyph )
        {
          font.addKerning(prevGlyphIndex, glyph, &x, &subpixel );
-         drawTextGlyph(font, glyph, x, y );
+#if !defined(SHADERS)
+         if(font.processImage)
+         {
+            FMGlyph *outlineGlyph = getGlyph(font, codepoint, state->size, subpixel, blurradius, blurscale, true );
+            if(outlineGlyph)
+               drawTextGlyph(font, outlineGlyph, x, y, true );
+         }
+#endif
+         drawTextGlyph(font, glyph, x, y, false );
          addGlyphAdvance( &x, &subpixel, glyph );
          if( x > truncatepoint )
            break;
index 5487dd5..d0a35dc 100644 (file)
@@ -193,13 +193,13 @@ public:
       return imageindex;
    }
 
-   void drawImage( int targetx, int targety, int imageindex )
+   void drawImage( int targetx, int targety, int imageindex, bool useExtColor )
    {
       DMImage *image = &imageList[ imageindex ];
-   #if DM_ENABLE_EXT_COLOR
+   #if (DM_ENABLE_EXT_COLOR && defined(SHADERS))
       dm.drawImageExtColor( image, targetx, targety, image->sizex, image->sizey, stateColor, stateExtColor );
    #else
-      dm.drawImage( image, targetx, targety, image->sizex, image->sizey, stateColor );
+      dm.drawImage( image, targetx, targety, image->sizex, image->sizey, useExtColor ? stateExtColor : stateColor );
    #endif
    }