Dear FreeTypers,
I am using FT_Glyphslot_Embolden and so far it seems to work quite well.
However, the default extra boldness (1/24 em) is too great for my purposes,
and ought to be settable via an argument, because different values are
needed at different times. For example, 1/32 em is adequate for making
DejaVu Sans Bold extra-bold.
I therefore suggest the following changes.
The function declaration in ftsynth,h becomes:
/*
Make a glyph bolder. The argument "boldness" is a
fixed-point value in ems. Strokes are thickened
by this value.
*/
FT_EXPORT( void )
FT_GlyphSlot_Embolden( FT_GlyphSlot slot,
FT_Fixed boldness );
The function itself in ftsynth.c becomes:
FT_EXPORT_DEF( void )
FT_GlyphSlot_Embolden( FT_GlyphSlot slot,
FT_Fixed boldness )
{
FT_Library library = slot->library;
FT_Face face= FT_SLOT_FACE( slot );
FT_Errorerror;
FT_Pos xstr, ystr;
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
slot->format != FT_GLYPH_FORMAT_BITMAP )
return;
/* convert boldness to pixels */
xstr = FT_MulFix( face->units_per_EM,
face->size->metrics.y_scale );
xstr = FT_MulFix( xstr, boldness );
ystr = xstr;
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
error = FT_Outline_Embolden( &slot->outline, xstr );
/* ignore error */
/* 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 );
error = FT_GlyphSlot_Own_Bitmap( slot );
if ( error )
return;
error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
if ( error )
return;
}
if ( slot->advance.x )
slot->advance.x += xstr;
if ( slot->advance.y )
slot->advance.y += ystr;
slot->metrics.width+= xstr;
slot->metrics.height += ystr;
slot->metrics.horiBearingY += ystr;
slot->metrics.horiAdvance += xstr;
slot->metrics.vertBearingX -= xstr / 2;
slot->metrics.vertBearingY += ystr;
slot->metrics.vertAdvance += ystr;
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
slot->bitmap_top += ystr >> 6;
}
Using the new function I can then pass the boldness value 65536 / 32 = 2048
to get extra boldness of 1/32 em. I have tested these changes and they work
well.
Best wishes,
Graham Asher
___
Freetype-devel mailing list
Freetype-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype-devel