Ticket #1243: gdft.c.patch

File gdft.c.patch, 2.5 kB (added by jlacroix, 4 years ago)

patch gdft.c to use freetype outline

  • gdft.c

    old new  
    109109#include FT_FREETYPE_H 
    110110#include FT_GLYPH_H 
    111111#include FT_SIZES_H 
     112#include FT_STROKER_H 
    112113#else 
    113114#include <freetype/freetype.h> 
    114115#include <freetype/ftglyph.h> 
    115116#include <freetype/ftsizes.h> 
     117#include <freetype/ftstroker.h> 
    116118#endif 
    117119 
    118120/* number of fonts cached before least recently used is replaced */ 
     
    12851287          /* load and transform glyph image */ 
    12861288          FT_Get_Glyph (slot, &image); 
    12871289 
     1290          /* Draw an outline for the character if requested  
     1291             and if we have a valid outline color to draw with. */ 
     1292          if (strex &&  
     1293              (strex->flags & gdFTEX_DRAWOUTLINE) == gdFTEX_DRAWOUTLINE &&  
     1294              (im && (im->trueColor || (strex->outlinecolor <= 255 &&  
     1295                                        strex->outlinecolor >= -255)))) 
     1296            { 
     1297              FT_Glyph borderimg; 
     1298              FT_Stroker stroker; 
     1299 
     1300              /* Copy the image to work the outline */ 
     1301              FT_Glyph_Copy(image, &borderimg); 
     1302 
     1303              /* Extract the character stroker */ 
     1304              FT_Stroker_New (face->memory, &stroker); 
     1305              FT_Stroker_Set (stroker, 
     1306                              80, 
     1307                              FT_STROKER_LINECAP_ROUND, 
     1308                              FT_STROKER_LINEJOIN_ROUND, 
     1309                              1); 
     1310              FT_Glyph_Stroke (&borderimg, stroker, 1); 
     1311 
     1312              /* Draw the stroker on the image */ 
     1313              if (borderimg->format != ft_glyph_format_bitmap) 
     1314              { 
     1315                  err = FT_Glyph_To_Bitmap (&borderimg, ft_render_mode_normal, 0, 1); 
     1316                  if (err) 
     1317                  { 
     1318                      gdCacheDelete (tc_cache); 
     1319                      gdMutexUnlock (gdFontCacheMutex); 
     1320                      return "Problem rendering glyph"; 
     1321                  } 
     1322              } 
     1323              bm = (FT_BitmapGlyph) borderimg; 
     1324 
     1325              /* Draw the actual character outline */ 
     1326              gdft_draw_bitmap (tc_cache, im, strex->outlinecolor, bm->bitmap, 
     1327                                x + (penf.x * cos_a + penf.y * sin_a)*hdpi/(METRIC_RES*64) + bm->left, 
     1328                                y - (penf.x * sin_a - penf.y * cos_a)*vdpi/(METRIC_RES*64) - bm->top); 
     1329 
     1330              FT_Done_Glyph (borderimg); 
     1331            } 
     1332 
    12881333          if (image->format != ft_glyph_format_bitmap) 
    12891334            { 
    12901335              err = FT_Glyph_To_Bitmap (&image, ft_render_mode_normal, 0, 1);