From 032646139df66c13761b506b3163d8c109140402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wu=2C=20Chia-I=20=28=E5=90=B3=E4=BD=B3=E4=B8=80=29?= Date: Fri, 24 Feb 2006 11:18:40 +0000 Subject: [PATCH] * 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. --- ChangeLog | 12 +++++++ include/freetype/ftbitmap.h | 4 +-- include/freetype/ftsynth.h | 10 +++--- src/base/ftsynth.c | 62 ++++++++++++++++++++----------------- 4 files changed, 53 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40511b9ff..caae98e54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-02-24 Chia-I Wu + + * 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 * tagging Third release candidate with VER-2-2-0-RC3 diff --git a/include/freetype/ftbitmap.h b/include/freetype/ftbitmap.h index cd970321f..7c61b6c6b 100644 --- a/include/freetype/ftbitmap.h +++ b/include/freetype/ftbitmap.h @@ -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, diff --git a/include/freetype/ftsynth.h b/include/freetype/ftsynth.h index f0c738532..36984bf1a 100644 --- 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 ); diff --git a/src/base/ftsynth.c b/src/base/ftsynth.c index e7b3d88f8..f363b3e45 100644 --- 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,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 )