* include/freetype/ftbitmap.h (FT_Bitmap_Embolden): Minor documentation improvements. * include/freetype/ftoutln.h (FT_Outline_Embolden): Fix typos. * src/base/ftbitmap.c (FT_Bitmap_Embolden): Add support for bitmap of pixel_mode FT_PIXEL_MODE_GRAY2 or FT_PIXEL_MODE_GRAY4. If xstr is larger than 8 and bitmap is of pixel_mode FT_PIXEL_MODE_MONO, set xstr to 8 instead of returning error.
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 133 134 135 136 137 138 139 140 141
diff --git a/ChangeLog b/ChangeLog
index 206d821..31780be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-05-30 Chia I Wu <b90201047@ntu.edu.tw>
+
+ * include/freetype/ftbitmap.h (FT_Bitmap_Embolden): Minor
+ documentation improvements.
+
+ * include/freetype/ftoutln.h (FT_Outline_Embolden): Fix typos.
+
+ * src/base/ftbitmap.c (FT_Bitmap_Embolden): Add support for bitmap
+ of pixel_mode FT_PIXEL_MODE_GRAY2 or FT_PIXEL_MODE_GRAY4.
+ If xstr is larger than 8 and bitmap is of pixel_mode
+ FT_PIXEL_MODE_MONO, set xstr to 8 instead of returning error.
+
2005-05-29 Chia I Wu <b90201047@ntu.edu.tw>
* src/base/ftbitmap.c (FT_Bitmap_Embolden): Fix emboldening bitmap
diff --git a/include/freetype/ftbitmap.h b/include/freetype/ftbitmap.h
index 2d9e368..319dd08 100644
--- a/include/freetype/ftbitmap.h
+++ b/include/freetype/ftbitmap.h
@@ -97,7 +97,7 @@ FT_BEGIN_HEADER
/* FT_Bitmap_Embolden */
/* */
/* <Description> */
- /* Emboldens a bitmap. The new bitmap will be about `xStrength' */
+ /* Embolden a bitmap. The new bitmap will be about `xStrength' */
/* pixels wider and `yStrength' pixels higher. The left and bottom */
/* borders are kept unchanged. */
/* */
@@ -105,10 +105,10 @@ FT_BEGIN_HEADER
/* library :: A handle to a library object. */
/* */
/* xStrength :: How strong the glyph is emboldened horizontally. */
- /* Expressed in 16.16 pixel format. */
+ /* Expressed in 26.6 pixel format. */
/* */
/* yStrength :: How strong the glyph is emboldened vertically. */
- /* Expressed in 16.16 pixel format. */
+ /* Expressed in 26.6 pixel format. */
/* */
/* <InOut> */
/* bitmap :: A handle to the target bitmap. */
@@ -118,12 +118,11 @@ FT_BEGIN_HEADER
/* */
/* <Note> */
/* The current implementation restricts `xStrength' to be less than */
- /* or equal to 8. */
+ /* or equal to 8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */
/* */
/* Don't embolden the bitmap owned by a @FT_GlyphSlot directly! Call */
/* @FT_Bitmap_Copy to get a copy and work on the copy instead. */
/* */
- /* */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Embolden( FT_Library library,
FT_Bitmap* bitmap,
diff --git a/include/freetype/ftoutln.h b/include/freetype/ftoutln.h
index 543f151..76ad60a 100644
--- a/include/freetype/ftoutln.h
+++ b/include/freetype/ftoutln.h
@@ -319,7 +319,7 @@ FT_BEGIN_HEADER
/* */
/* <Input> */
/* strength :: How strong the glyph is emboldened. Expressed in */
- /* 16.16 pixel format. */
+ /* 26.6 pixel format. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
index 6380391..7c95af7 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -211,30 +211,56 @@
if ( !library )
return FT_Err_Invalid_Library_Handle;
- if ( !bitmap )
+ if ( !bitmap || !bitmap->buffer )
return FT_Err_Invalid_Argument;
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 )
+ return FT_Err_Invalid_Argument;
+
switch ( bitmap->pixel_mode )
{
case FT_PIXEL_MODE_GRAY2:
case FT_PIXEL_MODE_GRAY4:
- return FT_Err_Invalid_Glyph_Format;
+ {
+ FT_Bitmap tmp;
+ FT_Int align;
+
+
+ if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY2 )
+ align = ( bitmap->width + xstr + 3 ) / 4;
+ else
+ align = ( bitmap->width + xstr + 1 ) / 2;
+
+ FT_Bitmap_New( &tmp );
+ error = FT_Bitmap_Convert( library, bitmap, &tmp, align );
+
+ if ( error )
+ return error;
+
+ FT_Bitmap_Done( library, bitmap );
+ *bitmap = tmp;
+ }
+ break;
+
+ case FT_PIXEL_MODE_MONO:
+ if ( xstr > 8 )
+ xstr = 8;
+ break;
+
case FT_PIXEL_MODE_LCD:
xstr *= 3;
break;
+
case FT_PIXEL_MODE_LCD_V:
ystr *= 3;
break;
}
- if ( xstr == 0 && ystr == 0 )
- return FT_Err_Ok;
- else if ( xstr < 0 || ystr < 0 || xstr > 8 )
- return FT_Err_Invalid_Argument;
-
error = ft_bitmap_assure_buffer( library->memory, bitmap, xstr, ystr );
if ( error )
return error;