2018-06-03 09:01:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* ftsynth.c
|
|
|
|
*
|
|
|
|
* FreeType synthesizing code for emboldening and slanting (body).
|
|
|
|
*
|
2022-01-11 10:54:10 +01:00
|
|
|
* Copyright (C) 2000-2022 by
|
2018-06-03 09:01:17 +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-08-23 19:32:42 +02:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/ftsynth.h>
|
|
|
|
#include <freetype/internal/ftdebug.h>
|
|
|
|
#include <freetype/internal/ftobjs.h>
|
|
|
|
#include <freetype/ftoutln.h>
|
|
|
|
#include <freetype/ftbitmap.h>
|
2000-08-23 00:53:03 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* The macro FT_COMPONENT is used in trace mode. It is an implicit
|
|
|
|
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
|
|
|
|
* messages during execution.
|
|
|
|
*/
|
2009-07-31 17:32:06 +02:00
|
|
|
#undef FT_COMPONENT
|
2018-08-15 18:13:17 +02:00
|
|
|
#define FT_COMPONENT synth
|
2009-07-31 17:32:06 +02:00
|
|
|
|
2012-06-15 06:33:46 +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;
|
2014-11-26 21:59:21 +01:00
|
|
|
FT_Outline* outline;
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2002-07-26 11:09:10 +02:00
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
if ( !slot )
|
|
|
|
return;
|
|
|
|
|
|
|
|
outline = &slot->outline;
|
|
|
|
|
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
|
|
|
|
2012-08-17 09:28:28 +02:00
|
|
|
transform.xy = 0x0366AL;
|
2000-10-15 23:59:58 +02:00
|
|
|
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
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/**** ****/
|
2012-06-15 06:33:46 +02:00
|
|
|
/**** EXPERIMENTAL EMBOLDENING SUPPORT ****/
|
2000-08-23 00:53:03 +02:00
|
|
|
/**** ****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
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
|
|
|
{
|
2014-11-26 21:59:21 +01:00
|
|
|
FT_Library library;
|
|
|
|
FT_Face face;
|
2006-02-22 21:47:39 +01:00
|
|
|
FT_Error error;
|
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
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
if ( !slot )
|
|
|
|
return;
|
|
|
|
|
|
|
|
library = slot->library;
|
|
|
|
face = slot->face;
|
|
|
|
|
2006-02-22 21:47:39 +01:00
|
|
|
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
|
2010-09-13 07:32:22 +02:00
|
|
|
slot->format != FT_GLYPH_FORMAT_BITMAP )
|
2006-02-22 21:47:39 +01:00
|
|
|
return;
|
|
|
|
|
2005-05-25 07:51:01 +02:00
|
|
|
/* 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;
|
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 )
|
2014-11-25 08:30:49 +01:00
|
|
|
FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
|
|
|
|
|
2010-09-13 07:32:22 +02:00
|
|
|
else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
|
2005-05-25 07:51:01 +02:00
|
|
|
{
|
2008-12-17 12:03:26 +01:00
|
|
|
/* round to full pixels */
|
|
|
|
xstr &= ~63;
|
2005-05-25 07:51:01 +02:00
|
|
|
if ( xstr == 0 )
|
|
|
|
xstr = 1 << 6;
|
2008-12-17 12:03:26 +01:00
|
|
|
ystr &= ~63;
|
2000-08-23 00:53:03 +02:00
|
|
|
|
2009-07-31 17:32:06 +02:00
|
|
|
/*
|
|
|
|
* XXX: overflow check for 16-bit system, for compatibility
|
2017-09-08 04:36:02 +02:00
|
|
|
* with FT_GlyphSlot_Embolden() since FreeType 2.1.10.
|
2009-07-31 17:32:06 +02:00
|
|
|
* unfortunately, this function return no informations
|
|
|
|
* about the cause of error.
|
|
|
|
*/
|
|
|
|
if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN )
|
|
|
|
{
|
|
|
|
FT_TRACE1(( "FT_GlyphSlot_Embolden:" ));
|
2020-07-28 07:33:40 +02:00
|
|
|
FT_TRACE1(( "too strong emboldening parameter ystr=%ld\n", ystr ));
|
2009-07-31 17:32:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2006-02-24 12:18:40 +01:00
|
|
|
error = FT_GlyphSlot_Own_Bitmap( slot );
|
|
|
|
if ( error )
|
|
|
|
return;
|
2000-08-23 00:53:03 +02:00
|
|
|
|
2006-02-22 21:47:39 +01:00
|
|
|
error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
|
|
|
|
if ( error )
|
|
|
|
return;
|
2000-08-23 00:53:03 +02:00
|
|
|
}
|
|
|
|
|
2006-11-07 10:47:04 +01:00
|
|
|
if ( slot->advance.x )
|
2006-11-07 10:35:03 +01:00
|
|
|
slot->advance.x += xstr;
|
|
|
|
|
2006-11-07 10:47:04 +01:00
|
|
|
if ( slot->advance.y )
|
2006-11-07 10:35:03 +01:00
|
|
|
slot->advance.y += ystr;
|
2006-02-22 21:47:39 +01:00
|
|
|
|
2013-09-20 07:20:53 +02:00
|
|
|
slot->metrics.width += xstr;
|
|
|
|
slot->metrics.height += ystr;
|
|
|
|
slot->metrics.horiAdvance += xstr;
|
|
|
|
slot->metrics.vertAdvance += ystr;
|
|
|
|
slot->metrics.horiBearingY += ystr;
|
2006-02-22 21:47:39 +01:00
|
|
|
|
2009-07-31 17:32:06 +02:00
|
|
|
/* XXX: 16-bit overflow case must be excluded before here */
|
2006-02-22 21:47:39 +01:00
|
|
|
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
|
2009-07-31 17:32:06 +02:00
|
|
|
slot->bitmap_top += (FT_Int)( ystr >> 6 );
|
2000-08-23 00:53:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
/* END */
|