2000-08-23 19:32:42 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftsynth.c */
|
|
|
|
/* */
|
|
|
|
/* FreeType synthesizing code for emboldening and slanting (body). */
|
|
|
|
/* */
|
2005-05-25 07:51:01 +02:00
|
|
|
/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */
|
2000-08-23 19:32:42 +02:00
|
|
|
/* 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>
|
2005-05-25 07:51:01 +02:00
|
|
|
#include FT_SYNTHESIS_H
|
2000-12-08 17:17:16 +01:00
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_OUTLINE_H
|
2005-05-25 07:51:01 +02:00
|
|
|
#include FT_BITMAP_H
|
2000-08-23 00:53:03 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-23 00:53:03 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/**** ****/
|
|
|
|
/**** EXPERIMENTAL OBLIQUING SUPPORT ****/
|
|
|
|
/**** ****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2004-12-14 00:16:59 +01:00
|
|
|
/* documentation is in ftsynth.h */
|
|
|
|
|
2002-07-01 23:33:48 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
|
2000-08-23 00:53:03 +02:00
|
|
|
{
|
2002-07-01 23:33:48 +02:00
|
|
|
FT_Matrix transform;
|
|
|
|
FT_Outline* outline = &slot->outline;
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2002-07-26 11:09:10 +02:00
|
|
|
|
2002-07-01 23:33:48 +02:00
|
|
|
/* only oblique outline glyphs */
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
|
2002-07-01 23:33:48 +02:00
|
|
|
return;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2002-07-01 23:33:48 +02:00
|
|
|
/* we don't touch the advance width */
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-23 00:53:03 +02:00
|
|
|
/* For italic, simply apply a shear transform, with an angle */
|
2000-08-23 19:32:42 +02:00
|
|
|
/* of about 12 degrees. */
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-10-15 23:59:58 +02:00
|
|
|
transform.xx = 0x10000L;
|
|
|
|
transform.yx = 0x00000L;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-10-15 23:59:58 +02:00
|
|
|
transform.xy = 0x06000L;
|
|
|
|
transform.yy = 0x10000L;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-10-15 23:59:58 +02:00
|
|
|
FT_Outline_Transform( outline, &transform );
|
2000-08-23 00:53:03 +02:00
|
|
|
}
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-23 00:53:03 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/**** ****/
|
|
|
|
/**** EXPERIMENTAL EMBOLDENING/OUTLINING SUPPORT ****/
|
|
|
|
/**** ****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2004-12-14 00:16:59 +01:00
|
|
|
/* documentation is in ftsynth.h */
|
2000-08-23 00:53:03 +02:00
|
|
|
|
2002-07-01 23:33:48 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
|
2000-08-23 00:53:03 +02:00
|
|
|
{
|
2005-05-25 07:51:01 +02:00
|
|
|
FT_Library library = slot->library;
|
|
|
|
FT_Face face = FT_SLOT_FACE( slot );
|
2005-05-27 06:18:20 +02:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2005-05-25 07:51:01 +02:00
|
|
|
FT_Pos xstr, ystr;
|
2002-07-01 23:33:48 +02:00
|
|
|
|
2002-07-26 11:09:10 +02:00
|
|
|
|
2005-05-25 07:51:01 +02:00
|
|
|
/* some reasonable strength */
|
|
|
|
xstr = FT_MulFix( face->units_per_EM,
|
2005-05-30 09:54:20 +02:00
|
|
|
face->size->metrics.y_scale ) / 42;
|
2005-05-25 07:51:01 +02:00
|
|
|
ystr = xstr;
|
2000-08-23 00:53:03 +02:00
|
|
|
|
2005-05-25 07:51:01 +02:00
|
|
|
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
|
2000-08-23 00:53:03 +02:00
|
|
|
{
|
2005-05-25 07:51:01 +02:00
|
|
|
error = FT_Outline_Embolden( &slot->outline, xstr );
|
2005-05-27 06:18:20 +02:00
|
|
|
xstr = xstr * 4; /* according to the documentation */
|
2005-05-25 07:51:01 +02:00
|
|
|
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 );
|
2000-08-23 00:53:03 +02:00
|
|
|
|
2005-05-26 23:02:25 +02:00
|
|
|
/* 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 )
|
|
|
|
{
|
|
|
|
slot->bitmap = bitmap;
|
|
|
|
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
|
|
|
|
}
|
|
|
|
}
|
2000-08-23 00:53:03 +02:00
|
|
|
|
2005-05-25 07:51:01 +02:00
|
|
|
if ( !error )
|
2005-05-26 23:02:25 +02:00
|
|
|
error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
|
2000-08-23 00:53:03 +02:00
|
|
|
}
|
2005-05-25 07:51:01 +02:00
|
|
|
else
|
|
|
|
error = FT_Err_Invalid_Argument;
|
2000-08-23 00:53:03 +02:00
|
|
|
|
2005-05-26 23:02:25 +02:00
|
|
|
/* modify the metrics accordingly */
|
2005-05-25 07:51:01 +02:00
|
|
|
if ( !error )
|
|
|
|
{
|
2005-05-30 09:54:20 +02:00
|
|
|
slot->advance.x += xstr;
|
|
|
|
slot->advance.y += ystr;
|
|
|
|
|
2005-05-25 07:51:01 +02:00
|
|
|
slot->metrics.width += xstr;
|
|
|
|
slot->metrics.height += ystr;
|
|
|
|
slot->metrics.horiBearingY += ystr;
|
|
|
|
slot->metrics.horiAdvance += xstr;
|
2005-05-26 23:02:25 +02:00
|
|
|
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;
|
2005-05-25 07:51:01 +02:00
|
|
|
}
|
2000-08-23 00:53:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
/* END */
|