* src/base/ftbitmap.c (FT_Bitmap_Embolden): Fix emboldening bitmap of mode FT_PIXEL_MODE_GRAY. Also add support for mode FT_PIXEL_MODE_LCD and FT_PIXEL_MODE_LCD_V. (ft_bitmap_assure_buffer): FT_PIXEL_MODE_LCD and FT_PIXEL_MODE_LCD_V should have ppb (pixel per byte) 1. Zero the padding when there's no need to allocate memory. * src/base/ftsynth.c (FT_GlyphSlot_Embolden): Handle slot->advance too. More suited emboldening strength.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
index 0306188..6380391 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -115,8 +115,6 @@
switch ( bitmap->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
- case FT_PIXEL_MODE_LCD:
- case FT_PIXEL_MODE_LCD_V:
ppb = 8;
break;
case FT_PIXEL_MODE_GRAY2:
@@ -126,15 +124,44 @@
ppb = 2;
break;
case FT_PIXEL_MODE_GRAY:
+ case FT_PIXEL_MODE_LCD:
+ case FT_PIXEL_MODE_LCD_V:
ppb = 1;
break;
default:
return FT_Err_Invalid_Glyph_Format;
}
- /* check whether we must allocate memory */
+ /* if no need to allocate memory */
if ( ypixels == 0 && pitch * ppb >= bitmap->width + xpixels )
+ {
+ /* zero the padding */
+ for ( i = 0; i < bitmap->rows; i++ )
+ {
+ unsigned char* last_byte;
+ int bits = xpixels * ( 8 / ppb );
+ int mask = 0;
+
+
+ last_byte = bitmap->buffer + i * pitch + ( bitmap->width - 1 ) / ppb;
+
+ if ( bits >= 8 )
+ {
+ FT_MEM_ZERO( last_byte + 1, bits / 8 );
+ bits %= 8;
+ }
+
+ if ( bits > 0 )
+ {
+ while ( bits-- > 0 )
+ mask |= 1 << bits;
+
+ *last_byte &= ~mask;
+ }
+ }
+
return FT_Err_Ok;
+ }
new_pitch = ( bitmap->width + xpixels + ppb - 1 ) / ppb;
@@ -187,16 +214,22 @@
if ( !bitmap )
return FT_Err_Invalid_Argument;
+ xstr = FT_PIX_ROUND( xStrength ) >> 6;
+ ystr = FT_PIX_ROUND( yStrength ) >> 6;
+
switch ( bitmap->pixel_mode )
{
case FT_PIXEL_MODE_GRAY2:
case FT_PIXEL_MODE_GRAY4:
return FT_Err_Invalid_Glyph_Format;
+ case FT_PIXEL_MODE_LCD:
+ xstr *= 3;
+ break;
+ case FT_PIXEL_MODE_LCD_V:
+ ystr *= 3;
+ break;
}
- xstr = FT_PIX_ROUND( xStrength ) >> 6;
- ystr = FT_PIX_ROUND( yStrength ) >> 6;
-
if ( xstr == 0 && ystr == 0 )
return FT_Err_Ok;
else if ( xstr < 0 || ystr < 0 || xstr > 8 )
@@ -245,19 +278,19 @@
break;
#endif
}
- else if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY )
+ else
{
if ( x - i >= 0 )
{
- if ( p[x] + p[x - i] > bitmap->num_grays )
+ if ( p[x] + p[x - i] > bitmap->num_grays - 1 )
{
- p[x] = bitmap->num_grays;
+ p[x] = bitmap->num_grays - 1;
break;
}
else
{
p[x] += p[x - i];
- if ( p[x] == bitmap->num_grays )
+ if ( p[x] == bitmap->num_grays - 1 )
break;
}
}
diff --git a/src/base/ftsynth.c b/src/base/ftsynth.c
index 4548a02..020bfdf 100644
--- a/src/base/ftsynth.c
+++ b/src/base/ftsynth.c
@@ -81,7 +81,7 @@
/* some reasonable strength */
xstr = FT_MulFix( face->units_per_EM,
- face->size->metrics.y_scale ) / 32;
+ face->size->metrics.y_scale ) / 42;
ystr = xstr;
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
@@ -122,6 +122,9 @@
/* modify the metrics accordingly */
if ( !error )
{
+ slot->advance.x += xstr;
+ slot->advance.y += ystr;
+
slot->metrics.width += xstr;
slot->metrics.height += ystr;
slot->metrics.horiBearingY += ystr;