summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Turner <david@freetype.org>2001-12-05 17:24:34 +0000
committerDavid Turner <david@freetype.org>2001-12-05 17:24:34 +0000
commit7ebd63726b29638151172aab84c2e8dac803660d (patch)
tree6320093ffe6e4b32ef4dff87c5c1585331acbe91
parent7b37145b63e8e9f14701b7793ae7b5c92f69d67e (diff)
downloadfreetype2-7ebd63726b29638151172aab84c2e8dac803660d.tar.gz
* 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..
-rw-r--r--ChangeLog12
-rw-r--r--docs/BUGS15
-rw-r--r--include/freetype/cache/ftcimage.h17
-rw-r--r--src/base/ftglyph.c51
-rw-r--r--src/base/ftobjs.c2
-rw-r--r--src/smooth/ftsmooth.c8
6 files changed, 69 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index ba173b594..6255a3798 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 6d87e0ffb..e4d62cf6d 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 e27b398ef..7614c1ba1 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 c3b37e572..d7f8f25aa 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 e8d58b8c8..ff5895e44 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 735ef226d..fb31efc8c 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, &params );
+
+ 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;
}