* include/freetype/ftbitmap.h (FT_Bitmap_Embolden): Update

documentation.

* include/freetype/ftsynth.h (FT_GlyphSlot_Own_Bitmap),
src/base/ftsynth.c (FT_GlyphSlot_Own_Bitmap): New function to make
sure a glyph slot owns its bitmap.  It is also marked experimental and
due to change.
(FT_GlyphSlot_Embolden): Undo the last change.  It turns out rendering
the outline confuses some applications.
This commit is contained in:
Wu, Chia-I (吳佳一) 2006-02-24 11:18:40 +00:00
parent 478c591364
commit 032646139d
4 changed files with 53 additions and 35 deletions

View File

@ -1,3 +1,15 @@
2006-02-24 Chia-I Wu <b90201047@ntu.edu.tw>
* include/freetype/ftbitmap.h (FT_Bitmap_Embolden): Update
documentation.
* include/freetype/ftsynth.h (FT_GlyphSlot_Own_Bitmap),
src/base/ftsynth.c (FT_GlyphSlot_Own_Bitmap): New function to make
sure a glyph slot owns its bitmap. It is also marked experimental and
due to change.
(FT_GlyphSlot_Embolden): Undo the last change. It turns out rendering
the outline confuses some applications.
2006-02-24 David Turner <david@freetype.org>
* tagging Third release candidate with VER-2-2-0-RC3

View File

@ -120,8 +120,8 @@ FT_BEGIN_HEADER
/* The current implementation restricts `xStrength' to be less than */
/* 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. */
/* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */
/* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */
/* */
FT_EXPORT( FT_Error )
FT_Bitmap_Embolden( FT_Library library,

View File

@ -5,7 +5,7 @@
/* FreeType synthesizing code for emboldening and slanting */
/* (specification). */
/* */
/* Copyright 2000-2001, 2003 by */
/* Copyright 2000-2001, 2003, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -50,10 +50,12 @@
FT_BEGIN_HEADER
/* Make sure slot owns slot->bitmap. */
FT_EXPORT( FT_Error )
FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot );
/* This code is completely experimental -- use with care! */
/* It will probably be completely rewritten in the future */
/* or even integrated into the library. */
/* Do not use this function directly! Copy the code to */
/* your application and modify it to suit your need. */
FT_EXPORT( void )
FT_GlyphSlot_Embolden( FT_GlyphSlot slot );

View File

@ -68,6 +68,29 @@
/*************************************************************************/
FT_EXPORT_DEF( FT_Error )
FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot )
{
if ( slot && slot->format == FT_GLYPH_FORMAT_BITMAP &&
!( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
{
FT_Bitmap bitmap;
FT_Error error;
FT_Bitmap_New( &bitmap );
error = FT_Bitmap_Copy( slot->library, &slot->bitmap, &bitmap );
if ( error )
return error;
slot->bitmap = bitmap;
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
}
return FT_Err_Ok;
}
/* documentation is in ftsynth.h */
FT_EXPORT_DEF( void )
@ -91,42 +114,23 @@
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
error = FT_Outline_Embolden( &slot->outline, xstr );
if ( error )
{
error = FT_Render_Glyph( slot, FT_RENDER_MODE_NORMAL );
if ( error )
return;
}
else
{
/* this is more than enough for most glyphs; if you need accurate */
/* values, you have to call FT_Outline_Get_CBox */
xstr = xstr * 2;
ystr = xstr;
}
}
/* ignore error */
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
/* this is more than enough for most glyphs; if you need accurate */
/* values, you have to call FT_Outline_Get_CBox */
xstr = xstr * 2;
ystr = xstr;
}
else if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
{
xstr = FT_PIX_FLOOR( xstr );
if ( xstr == 0 )
xstr = 1 << 6;
ystr = FT_PIX_FLOOR( ystr );
/* slot must be bitmap-owner */
if ( !( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
{
FT_Bitmap bitmap;
FT_Bitmap_New( &bitmap );
error = FT_Bitmap_Copy( library, &slot->bitmap, &bitmap );
if ( error )
return;
slot->bitmap = bitmap;
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
}
error = FT_GlyphSlot_Own_Bitmap( slot );
if ( error )
return;
error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
if ( error )