* 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..
This commit is contained in:
David Turner 2001-12-05 17:24:34 +00:00
parent 7b37145b63
commit 7ebd63726b
6 changed files with 69 additions and 36 deletions

View File

@ -1,3 +1,15 @@
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 !!

View File

@ -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 ===

View File

@ -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

View File

@ -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:

View File

@ -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;

View File

@ -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;
}