ref: 032646139df66c13761b506b3163d8c109140402
parent: 478c59136498fc34e5086e8dacab8256066509cc
author: Wu, Chia-I (吳佳一) <[email protected]>
date: Fri Feb 24 06:18:40 EST 2006
* 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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-02-24 Chia-I Wu <[email protected]>
+
+ * 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 <[email protected]>
* tagging Third release candidate with VER-2-2-0-RC3
--- a/include/freetype/ftbitmap.h
+++ b/include/freetype/ftbitmap.h
@@ -120,8 +120,8 @@
/* 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,
--- a/include/freetype/ftsynth.h
+++ b/include/freetype/ftsynth.h
@@ -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 );
--- a/src/base/ftsynth.c
+++ b/src/base/ftsynth.c
@@ -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,22 +114,14 @@
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 )
@@ -113,20 +128,9 @@
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 )