* src/base/ftglyph.c (FT_Glyph_To_Bitmap): re-ordered code for debugging purposes.. * src/smooth/ftsmooth.c (ft_smooth_render): fixed a nasty hidden bug where outline shifting wasn't correctly undone after bitmap rasterization. this created problems with certain glyphs (like '"' of certain fonts..) and the cache system..
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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
diff --git a/ChangeLog b/ChangeLog
index ba173b5..6255a37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2001-12-05 David Turner <david@freetype.org>
+ * src/base/ftglyph.c (FT_Glyph_To_Bitmap): re-ordered code for debugging
+ purposes..
+
+
+ * src/smooth/ftsmooth.c (ft_smooth_render): fixed a nasty hidden bug where
+ outline shifting wasn't correctly undone after bitmap rasterization. this
+ created problems with certain glyphs (like '"' of certain fonts..) and
+ the cache system..
+
+
+2001-12-05 David Turner <david@freetype.org>
+
First of all, a big thanks to Werner and Antoine for their latest work !!
* src/pshinter/pshalgo2.c (psh2_hint_table_init),
diff --git a/docs/BUGS b/docs/BUGS
index 6d87e0f..e4d62cf 100644
--- a/docs/BUGS
+++ b/docs/BUGS
@@ -46,6 +46,7 @@ Identifier Date Closed by Closure date
BAD-TTNAMEID.H 12-09-2001 Antoine N/A
BAD-T1-CHARMAP 15-06-2001 David 2.0.5
BAD-UNIXXX-NAMES 30-07-2001 David 2.0.5
+GLYPH_TO_BITMAP-BUG 05-12-2001 David 05-12-2001
--------------------END-OF-CLOSED-BUGS-TABLE----------------------------------
@@ -183,4 +184,18 @@ ADVANCED-COMPOSITES
for "load_flag", some other way to set preferences is probably needed.
+GLYPH_TO_BITMAP-BUG
+
+ Calling FT_Glyph_To_Bitmap sometimes modifies the original glyph outline,
+ creating weird alignment artefacts.
+
+ this subtle bug was really in the file src/smooth/ftsmooth.c. Basically,
+ the outline was shifted before rendering it into a new bitmap buffer.
+ However, it wasn't properly un-shifted after that operation..
+
+ this was only noticeable with certain glyphs or certain fonts and crept
+ for a long time here..
+
+
+
=== end of file ===
diff --git a/include/freetype/cache/ftcimage.h b/include/freetype/cache/ftcimage.h
index e27b398..7614c1b 100644
--- a/include/freetype/cache/ftcimage.h
+++ b/include/freetype/cache/ftcimage.h
@@ -56,18 +56,21 @@ FT_BEGIN_HEADER
#define FTC_IMAGE_FORMAT( x ) ( (x) & 7 )
-#define ftc_image_format_bitmap 0
-#define ftc_image_format_outline 1
+#define ftc_image_format_bitmap 0x0000
+#define ftc_image_format_outline 0x0001
-#define ftc_image_flag_monochrome 16
-#define ftc_image_flag_unhinted 32
-#define ftc_image_flag_autohinted 64
-#define ftc_image_flag_unscaled 128
-#define ftc_image_flag_no_sbits 256
+#define ftc_image_format_mask 0x000F
+
+#define ftc_image_flag_monochrome 0x0010
+#define ftc_image_flag_unhinted 0x0020
+#define ftc_image_flag_autohinted 0x0040
+#define ftc_image_flag_unscaled 0x0080
+#define ftc_image_flag_no_sbits 0x0100
/* monochrome bitmap */
#define ftc_image_mono ftc_image_format_bitmap | \
ftc_image_flag_monochrome
+
/* anti-aliased bitmap */
#define ftc_image_grays ftc_image_format_bitmap
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index c3b37e5..d7f8f25 100644
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -574,7 +574,7 @@
FT_GlyphSlotRec dummy;
FT_Error error;
FT_Glyph glyph;
- FT_BitmapGlyph bitmap;
+ FT_BitmapGlyph bitmap = NULL;
const FT_Glyph_Class* clazz;
@@ -598,27 +598,24 @@
dummy.library = glyph->library;
dummy.format = clazz->glyph_format;
- /* if `origin' is set, translate the glyph image */
- if ( origin )
- FT_Glyph_Transform( glyph, 0, origin );
-
/* create result bitmap glyph */
error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class,
(FT_Glyph*)&bitmap );
- if ( error )
+ if (error)
goto Exit;
+#if 0
+ /* if `origin' is set, translate the glyph image */
+ if ( origin )
+ FT_Glyph_Transform( glyph, 0, origin );
+#endif
+
/* prepare dummy slot for rendering */
error = clazz->glyph_prepare( glyph, &dummy );
if ( !error )
error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
- if ( error )
- {
- FT_Done_Glyph( FT_GLYPH( bitmap ) );
- goto Exit;
- }
-
+#if 0
if ( !destroy && origin )
{
FT_Vector v;
@@ -628,28 +625,28 @@
v.y = -origin->y;
FT_Glyph_Transform( glyph, 0, &v );
}
+#endif
+
+ if (error)
+ goto Exit;
/* in case of success, copy the bitmap to the glyph bitmap */
- if ( !error )
- {
- error = ft_bitmap_glyph_init( bitmap, &dummy );
- if ( error )
- {
- /* this should never happen, but let's be safe */
- FT_Done_Glyph( FT_GLYPH( bitmap ) );
- goto Exit;
- }
+ error = ft_bitmap_glyph_init( bitmap, &dummy );
+ if ( error )
+ goto Exit;
- /* copy advance */
- bitmap->root.advance = glyph->advance;
+ /* copy advance */
+ bitmap->root.advance = glyph->advance;
- if ( destroy )
- FT_Done_Glyph( glyph );
+ if ( destroy )
+ FT_Done_Glyph( glyph );
- *the_glyph = FT_GLYPH( bitmap );
- }
+ *the_glyph = FT_GLYPH( bitmap );
Exit:
+ if (error && bitmap)
+ FT_Done_Glyph( FT_GLYPH(bitmap) );
+
return error;
Bad:
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index e8d58b8..ff5895e 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2243,7 +2243,7 @@
error = FT_Err_Unimplemented_Feature;
while ( renderer )
{
- error = renderer->render( renderer, slot, render_mode, 0 );
+ error = renderer->render( renderer, slot, render_mode, NULL );
if ( !error ||
FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph )
break;
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index 735ef22..fb31efc 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -100,7 +100,7 @@
FT_Vector* origin )
{
FT_Error error;
- FT_Outline* outline;
+ FT_Outline* outline = NULL;
FT_BBox cbox;
FT_UInt width, height, pitch;
FT_Bitmap* bitmap;
@@ -169,6 +169,9 @@
/* render outline into the bitmap */
error = render->raster_render( render->raster, ¶ms );
+
+ FT_Outline_Translate( outline, cbox.xMin, cbox.yMin );
+
if ( error )
goto Exit;
@@ -177,6 +180,9 @@
slot->bitmap_top = cbox.yMax >> 6;
Exit:
+ if ( outline && origin )
+ FT_Outline_Translate( outline, -origin->x, -origin->y );
+
return error;
}