freetype2/src/base/ftsynth.c

153 lines
5.1 KiB
C
Raw Normal View History

/***************************************************************************/
/* */
/* ftsynth.c */
/* */
/* FreeType synthesizing code for emboldening and slanting (body). */
/* */
2006-02-23 22:01:34 +01:00
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
2000-12-08 17:17:16 +01:00
#include <ft2build.h>
#include FT_SYNTHESIS_H
2000-12-08 17:17:16 +01:00
#include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H
#include FT_BITMAP_H
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** EXPERIMENTAL OBLIQUING SUPPORT ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
2004-12-14 00:16:59 +01:00
/* documentation is in ftsynth.h */
FT_EXPORT_DEF( void )
FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
{
FT_Matrix transform;
FT_Outline* outline = &slot->outline;
/* only oblique outline glyphs */
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
return;
2000-10-31 21:42:18 +01:00
/* we don't touch the advance width */
/* For italic, simply apply a shear transform, with an angle */
/* of about 12 degrees. */
2000-10-31 21:42:18 +01:00
transform.xx = 0x10000L;
transform.yx = 0x00000L;
2000-10-31 21:42:18 +01:00
transform.xy = 0x06000L;
transform.yy = 0x10000L;
2000-10-31 21:42:18 +01:00
FT_Outline_Transform( outline, &transform );
}
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** EXPERIMENTAL EMBOLDENING/OUTLINING SUPPORT ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
2004-12-14 00:16:59 +01:00
/* documentation is in ftsynth.h */
FT_EXPORT_DEF( void )
FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
{
FT_Library library = slot->library;
FT_Face face = FT_SLOT_FACE( slot );
FT_Error error;
FT_Pos xstr, ystr;
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
slot->format != FT_GLYPH_FORMAT_BITMAP )
return;
/* some reasonable strength */
xstr = FT_MulFix( face->units_per_EM,
* src/base/ftoutln.c (FT_Outline_Embolden): Strength should be halved. * src/base/ftsynth.c (FT_GlyphSlot_Embolden): Change the default strength. Don't increase slot->advance.y. * include/freetype/freetype.h (FREETYPE_MINOR): Set to 2. (FREETYPE_PATCH): Set to 0. * builds/unix/configure.ac (version_info): Set to 9:9:3. Currently, we are still binary compatible. * builds/win32/visualc/index.html, builds/win32/visualc/freetype.dsp, builds/win32/visualc/freetype.vcproj: s/219/2110/, s/2.1.9/2.1.10/. * builds/freetype.mk (refdoc), README, Jamfile (RefDoc): s/2.1.9/2.1.10/. * docs/CHANGES, docs/VERSION.DLL: Updated. * ChangeLog: Split off older entries into... * ChangeLog.20, ChangeLog.21: These new files. The next release will be 2.2.0, so don't worry about source code backwards compatibility. * include/freetype/ftimage.h (FT_Outline_MoveToFunc, FT_Outline_LineToFunc, FT_Outline_ConicToFunc, FT_Outline_CubicToFunc, FT_SpanFunc, FT_Raster_RenderFunc), include/freetype/ftrender.h (FT_Glyph_TransformFunc, FT_Renderer_RenderFunc, FT_Renderer_TransformFunc): Decorate parameters with `const' where appropriate. * src/sfnt/ttsbit.c (tt_face_load_sbit_image): Compute vertBearingY to make glyphs centered vertically. * src/truetype/ttgload.c (compute_glyph_metrics): Compute vertBearingY to make glyphs centered vertically. Fix some bugs in vertical metrics: . loader->pp3.y and loader->pp4.y are in 26.6 format, not in font units. . As we use the glyph's cbox to calculate the top bearing now there iss no need to adjust `top'. * src/otvalid/otvcommn.h (OTV_OPTIONAL_TABLE): Use FT_UShort to be in sync with OTV_OPTIONAL_OFFSET. Reported by YAMATO Masatake. * docs/release: Update.
2005-06-16 21:07:08 +02:00
face->size->metrics.y_scale ) / 24;
ystr = xstr;
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
{
2006-02-23 22:01:34 +01:00
/* 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;
}
}
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_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
if ( error )
return;
}
/* assume the layout is horizontal */
slot->advance.x += xstr;
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;
}
/* END */