2005-03-03 18:09:08 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* aftypes.h */
|
|
|
|
/* */
|
|
|
|
/* Auto-fitter types (specification only). */
|
|
|
|
/* */
|
2008-05-29 00:17:28 +02:00
|
|
|
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */
|
2005-03-03 18:09:08 +01: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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2006-02-10 23:15:22 +01:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* The auto-fitter is a complete rewrite of the old auto-hinter.
|
|
|
|
* Its main feature is the ability to differentiate between different
|
|
|
|
* scripts in order to apply language-specific rules.
|
|
|
|
*
|
2007-01-31 00:08:50 +01:00
|
|
|
* The code has also been compartmentized into several entities that
|
2006-02-10 23:15:22 +01:00
|
|
|
* should make algorithmic experimentation easier than with the old
|
|
|
|
* code.
|
|
|
|
*
|
|
|
|
* Finally, we get rid of the Catharon license, since this code is
|
|
|
|
* released under the FreeType one.
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
2005-03-03 18:09:08 +01:00
|
|
|
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
#ifndef __AFTYPES_H__
|
|
|
|
#define __AFTYPES_H__
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
2005-03-03 18:09:08 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
#include FT_FREETYPE_H
|
|
|
|
#include FT_OUTLINE_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_BEGIN_HEADER
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** D E B U G G I N G *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-01-30 11:33:53 +01:00
|
|
|
#define xxAF_USE_WARPER /* only define to use warp hinting */
|
2007-01-15 07:42:40 +01:00
|
|
|
#define xxAF_DEBUG
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
#ifdef AF_DEBUG
|
|
|
|
|
2006-11-03 10:40:12 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#define AF_LOG( x ) do { if ( _af_debug ) printf x; } while ( 0 )
|
2005-03-03 18:09:08 +01:00
|
|
|
|
2006-11-03 10:40:12 +01:00
|
|
|
extern int _af_debug;
|
|
|
|
extern int _af_debug_disable_horz_hints;
|
|
|
|
extern int _af_debug_disable_vert_hints;
|
|
|
|
extern int _af_debug_disable_blue_hints;
|
2006-11-02 17:37:35 +01:00
|
|
|
extern void* _af_debug_hints;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2006-09-26 17:42:44 +02:00
|
|
|
#else /* !AF_DEBUG */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2006-11-03 10:40:12 +01:00
|
|
|
#define AF_LOG( x ) do ; while ( 0 ) /* nothing */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2006-09-26 17:42:44 +02:00
|
|
|
#endif /* !AF_DEBUG */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** U T I L I T Y S T U F F *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
typedef struct AF_WidthRec_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
|
|
|
FT_Pos org; /* original position/width in font units */
|
|
|
|
FT_Pos cur; /* current/scaled position/width in device sub-pixels */
|
|
|
|
FT_Pos fit; /* current/fitted position/width in device sub-pixels */
|
|
|
|
|
|
|
|
} AF_WidthRec, *AF_Width;
|
|
|
|
|
|
|
|
|
|
|
|
FT_LOCAL( void )
|
2005-03-03 18:09:08 +01:00
|
|
|
af_sort_pos( FT_UInt count,
|
|
|
|
FT_Pos* table );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
FT_LOCAL( void )
|
|
|
|
af_sort_widths( FT_UInt count,
|
|
|
|
AF_Width widths );
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** A N G L E T Y P E S *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The auto-fitter doesn't need a very high angular accuracy;
|
|
|
|
* this allows us to speed up some computations considerably with a
|
|
|
|
* light Cordic algorithm (see afangles.c).
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef FT_Int AF_Angle;
|
|
|
|
|
|
|
|
|
|
|
|
#define AF_ANGLE_PI 256
|
|
|
|
#define AF_ANGLE_2PI ( AF_ANGLE_PI * 2 )
|
|
|
|
#define AF_ANGLE_PI2 ( AF_ANGLE_PI / 2 )
|
|
|
|
#define AF_ANGLE_PI4 ( AF_ANGLE_PI / 4 )
|
|
|
|
|
|
|
|
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
#if 0
|
2005-03-03 18:09:08 +01:00
|
|
|
/*
|
|
|
|
* compute the angle of a given 2-D vector
|
|
|
|
*/
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL( AF_Angle )
|
|
|
|
af_angle_atan( FT_Pos dx,
|
|
|
|
FT_Pos dy );
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/*
|
|
|
|
* compute `angle2 - angle1'; the result is always within
|
|
|
|
* the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1]
|
|
|
|
*/
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL( AF_Angle )
|
|
|
|
af_angle_diff( AF_Angle angle1,
|
|
|
|
AF_Angle angle2 );
|
2005-11-11 16:49:14 +01:00
|
|
|
#endif /* 0 */
|
|
|
|
|
|
|
|
|
|
|
|
#define AF_ANGLE_DIFF( result, angle1, angle2 ) \
|
|
|
|
FT_BEGIN_STMNT \
|
|
|
|
AF_Angle _delta = (angle2) - (angle1); \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
_delta %= AF_ANGLE_2PI; \
|
|
|
|
if ( _delta < 0 ) \
|
|
|
|
_delta += AF_ANGLE_2PI; \
|
|
|
|
\
|
|
|
|
if ( _delta > AF_ANGLE_PI ) \
|
|
|
|
_delta -= AF_ANGLE_2PI; \
|
|
|
|
\
|
|
|
|
result = _delta; \
|
2005-10-28 18:14:14 +02:00
|
|
|
FT_END_STMNT
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-11-11 16:49:14 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** O U T L I N E S *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
/* opaque handle to glyph-specific hints -- see `afhints.h' for more
|
|
|
|
* details
|
|
|
|
*/
|
|
|
|
typedef struct AF_GlyphHintsRec_* AF_GlyphHints;
|
|
|
|
|
|
|
|
/* This structure is used to model an input glyph outline to
|
|
|
|
* the auto-hinter. The latter will set the `hints' field
|
|
|
|
* depending on the glyph's script.
|
|
|
|
*/
|
|
|
|
typedef struct AF_OutlineRec_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Face face;
|
|
|
|
FT_Outline outline;
|
|
|
|
FT_UInt outline_resolution;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Int advance;
|
|
|
|
FT_UInt metrics_resolution;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_GlyphHints hints;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_OutlineRec;
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** S C A L E R S *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/*
|
|
|
|
* A scaler models the target pixel device that will receive the
|
|
|
|
* auto-hinted glyph image.
|
|
|
|
*/
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2008-05-29 00:17:28 +02:00
|
|
|
typedef enum AF_ScalerFlags_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
|
|
|
AF_SCALER_FLAG_NO_HORIZONTAL = 1, /* disable horizontal hinting */
|
|
|
|
AF_SCALER_FLAG_NO_VERTICAL = 2, /* disable vertical hinting */
|
|
|
|
AF_SCALER_FLAG_NO_ADVANCE = 4 /* disable advance hinting */
|
|
|
|
|
|
|
|
} AF_ScalerFlags;
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef struct AF_ScalerRec_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Face face; /* source font face */
|
|
|
|
FT_Fixed x_scale; /* from font units to 1/64th device pixels */
|
|
|
|
FT_Fixed y_scale; /* from font units to 1/64th device pixels */
|
|
|
|
FT_Pos x_delta; /* in 1/64th device pixels */
|
|
|
|
FT_Pos y_delta; /* in 1/64th device pixels */
|
|
|
|
FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc. */
|
|
|
|
FT_UInt32 flags; /* additional control flags, see above */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_ScalerRec, *AF_Scaler;
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
#define AF_SCALER_EQUAL_SCALES( a, b ) \
|
|
|
|
( (a)->x_scale == (b)->x_scale && \
|
|
|
|
(a)->y_scale == (b)->y_scale && \
|
|
|
|
(a)->x_delta == (b)->x_delta && \
|
|
|
|
(a)->y_delta == (b)->y_delta )
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** S C R I P T S *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The list of know scripts. Each different script corresponds to the
|
|
|
|
* following information:
|
|
|
|
*
|
|
|
|
* - A set of Unicode ranges to test whether the face supports the
|
|
|
|
* script.
|
|
|
|
*
|
|
|
|
* - A specific global analyzer that will compute global metrics
|
|
|
|
* specific to the script.
|
|
|
|
*
|
|
|
|
* - A specific glyph analyzer that will compute segments and
|
|
|
|
* edges for each glyph covered by the script.
|
|
|
|
*
|
|
|
|
* - A specific grid-fitting algorithm that will distort the
|
|
|
|
* scaled glyph outline according to the results of the glyph
|
|
|
|
* analyzer.
|
|
|
|
*
|
|
|
|
* Note that a given analyzer and/or grid-fitting algorithm can be
|
|
|
|
* used by more than one script.
|
|
|
|
*/
|
|
|
|
|
2008-05-29 00:17:28 +02:00
|
|
|
typedef enum AF_Script_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
|
|
|
AF_SCRIPT_NONE = 0,
|
|
|
|
AF_SCRIPT_LATIN = 1,
|
2006-02-09 15:17:04 +01:00
|
|
|
AF_SCRIPT_CJK = 2,
|
2007-06-26 06:44:35 +02:00
|
|
|
AF_SCRIPT_INDIC = 3,
|
2007-06-11 07:37:35 +02:00
|
|
|
#ifdef FT_OPTION_AUTOFIT2
|
|
|
|
AF_SCRIPT_LATIN2,
|
|
|
|
#endif
|
2007-06-26 06:44:35 +02:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/* add new scripts here. Don't forget to update the list in */
|
|
|
|
/* `afglobal.c'. */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
AF_SCRIPT_MAX /* do not remove */
|
|
|
|
|
|
|
|
} AF_Script;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct AF_ScriptClassRec_ const* AF_ScriptClass;
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef struct AF_ScriptMetricsRec_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_ScriptClass clazz;
|
|
|
|
AF_ScalerRec scaler;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_ScriptMetricsRec, *AF_ScriptMetrics;
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/* This function parses an FT_Face to compute global metrics for
|
|
|
|
* a specific script.
|
|
|
|
*/
|
|
|
|
typedef FT_Error
|
|
|
|
(*AF_Script_InitMetricsFunc)( AF_ScriptMetrics metrics,
|
|
|
|
FT_Face face );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef void
|
|
|
|
(*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics metrics,
|
|
|
|
AF_Scaler scaler );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef void
|
|
|
|
(*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics metrics );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef FT_Error
|
|
|
|
(*AF_Script_InitHintsFunc)( AF_GlyphHints hints,
|
|
|
|
AF_ScriptMetrics metrics );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef void
|
|
|
|
(*AF_Script_ApplyHintsFunc)( AF_GlyphHints hints,
|
|
|
|
FT_Outline* outline,
|
|
|
|
AF_ScriptMetrics metrics );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef struct AF_Script_UniRangeRec_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_UInt32 first;
|
|
|
|
FT_UInt32 last;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_Script_UniRangeRec;
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef const AF_Script_UniRangeRec *AF_Script_UniRange;
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef struct AF_ScriptClassRec_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
|
|
|
AF_Script script;
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
FT_UInt script_metrics_size;
|
|
|
|
AF_Script_InitMetricsFunc script_metrics_init;
|
|
|
|
AF_Script_ScaleMetricsFunc script_metrics_scale;
|
|
|
|
AF_Script_DoneMetricsFunc script_metrics_done;
|
|
|
|
|
|
|
|
AF_Script_InitHintsFunc script_hints_init;
|
|
|
|
AF_Script_ApplyHintsFunc script_hints_apply;
|
|
|
|
|
|
|
|
} AF_ScriptClassRec;
|
|
|
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
FT_END_HEADER
|
|
|
|
|
|
|
|
#endif /* __AFTYPES_H__ */
|
2005-03-03 18:09:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* END */
|