2005-03-03 18:09:08 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* afhints.h */
|
|
|
|
/* */
|
|
|
|
/* Auto-fitter hinting routines (specification). */
|
|
|
|
/* */
|
2018-01-02 09:33:57 +01:00
|
|
|
/* Copyright 2003-2018 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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2016-01-12 21:37:13 +01:00
|
|
|
#ifndef AFHINTS_H_
|
|
|
|
#define AFHINTS_H_
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
#include "aftypes.h"
|
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
#define xxAF_SORT_SEGMENTS
|
2005-03-03 18:09:08 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_BEGIN_HEADER
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/*
|
|
|
|
* The definition of outline glyph hints. These are shared by all
|
[autofit] Introduce `styles'.
This is the new top-level structure for handling glyph input data;
scripts are now defined separately.
* src/autofit/aftypes.h (SCRIPT): Updated.
(AF_ScriptClassRec): Move `blue_stringset' and `writing_system'
members to ...
(AF_Style_ClassRec): ... this new structure.
(AF_Style): New enumeration.
(AF_StyleMetricsRec): Replace `script' enumeration with
`style_class' pointer.
(AF_DEFINE_SCRIPT_CLASS, AF_DECLARE_SCRIPT_CLASS): Updated.
(AF_DEFINE_STYLE_CLASS, AF_DECLARE_STYLE_CLASS): New macros.
* src/autofit/afstyles.h: New file, using data from `afscript.h'.
* src/autofit/afscript.h: Updated.
* src/autofit/afcjk.c (af_cjk_metrics_init_widths,
af_cjk_metrics_init_blues, af_cjk_hint_edges): Updated.
* src/autofit/afglobal.c (SCRIPT): Updated.
(STYLE): Redefine macro to load `afstyles.h'.
(af_script_names) [FT_DEBUG_LEVEL_TRACE]: Replace with...
(af_style_names): ... this array.
(af_face_globals_compute_script_coverage): Renamed to...
(af_face_globals_compute_style_coverage): ... this.
Updated.
(af_face_globals_new, af_face_globals_free,
af_face_globals_get_metrics): Updated.
* src/autofit/afglobal.h (SCRIPT): Updated.
(STYLE): Redefine macro to load `afstyles.h'.
(AF_SCRIPT_FALLBACK): Update definition. This will get more
refinements with later on.
(AF_SCRIPT_UNASSIGNED): Replace with...
(AF_STYLE_UNASSIGNED): ... this macro.
(AF_FaceGlobalsRec): Updated.
* src/autofit/aflatin.c (af_latin_metrics_init_widths,
af_latin_metrics_init_blues, af_latin_metrics_scale_dim,
af_latin_hint_edges): Updated.
* src/autofit/aflatin2.c (af_latin2_metrics_init_widths): Updated.
(af_ltn2_uniranges): Removed.
* src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph):
Updated.
* src/autofit/afpic.c (autofit_module_class_pic_init): Updated.
* src/autofit/afpic.h (AF_STYLE_CLASSES_GET): New macro.
(AFModulePIC): Add `af_style_classes' and `af_style_classes_rec'
members.
* src/autofit/afranges.h: Updated.
* src/autofit/rules.mk (AUTOF_DRV_H): Add `afstyles.h'.
2013-12-20 17:26:26 +01:00
|
|
|
* writing system analysis routines (until now).
|
2011-02-16 21:59:44 +01:00
|
|
|
*/
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2008-05-29 00:17:28 +02:00
|
|
|
typedef enum AF_Dimension_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_DIMENSION_HORZ = 0, /* x coordinates, */
|
|
|
|
/* i.e., vertical segments & edges */
|
|
|
|
AF_DIMENSION_VERT = 1, /* y coordinates, */
|
|
|
|
/* i.e., horizontal segments & edges */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
AF_DIMENSION_MAX /* do not remove */
|
|
|
|
|
|
|
|
} AF_Dimension;
|
|
|
|
|
|
|
|
|
|
|
|
/* hint directions -- the values are computed so that two vectors are */
|
2005-03-03 18:09:08 +01:00
|
|
|
/* in opposite directions iff `dir1 + dir2 == 0' */
|
2008-05-29 00:17:28 +02:00
|
|
|
typedef enum AF_Direction_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
|
|
|
AF_DIR_NONE = 4,
|
|
|
|
AF_DIR_RIGHT = 1,
|
|
|
|
AF_DIR_LEFT = -1,
|
|
|
|
AF_DIR_UP = 2,
|
|
|
|
AF_DIR_DOWN = -2
|
|
|
|
|
|
|
|
} AF_Direction;
|
|
|
|
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/*
|
|
|
|
* The following explanations are mostly taken from the article
|
|
|
|
*
|
|
|
|
* Real-Time Grid Fitting of Typographic Outlines
|
|
|
|
*
|
|
|
|
* by David Turner and Werner Lemberg
|
|
|
|
*
|
2017-12-04 20:43:30 +01:00
|
|
|
* https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf
|
2013-08-04 09:25:24 +02:00
|
|
|
*
|
|
|
|
* with appropriate updates.
|
2011-02-16 21:59:44 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Segments
|
|
|
|
*
|
|
|
|
* `af_{cjk,latin,...}_hints_compute_segments' are the functions to
|
2013-08-04 09:25:24 +02:00
|
|
|
* find segments in an outline.
|
|
|
|
*
|
2014-09-24 19:06:13 +02:00
|
|
|
* A segment is a series of at least two consecutive points that are
|
|
|
|
* approximately aligned along a coordinate axis. The analysis to do
|
|
|
|
* so is specific to a writing system.
|
2011-02-16 21:59:44 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Edges
|
|
|
|
*
|
2013-08-04 09:25:24 +02:00
|
|
|
* `af_{cjk,latin,...}_hints_compute_edges' are the functions to find
|
|
|
|
* edges.
|
|
|
|
*
|
2011-02-16 21:59:44 +01:00
|
|
|
* As soon as segments are defined, the auto-hinter groups them into
|
|
|
|
* edges. An edge corresponds to a single position on the main
|
|
|
|
* dimension that collects one or more segments (allowing for a small
|
|
|
|
* threshold).
|
|
|
|
*
|
2013-08-04 09:25:24 +02:00
|
|
|
* As an example, the `latin' writing system first tries to grid-fit
|
|
|
|
* edges, then to align segments on the edges unless it detects that
|
|
|
|
* they form a serif.
|
2011-02-16 21:59:44 +01:00
|
|
|
*
|
|
|
|
*
|
2011-02-22 10:29:30 +01:00
|
|
|
* A H
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* C | | F
|
|
|
|
* +------<-----+ +-----<------+
|
|
|
|
* | B G |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* +--------------->------------------+
|
|
|
|
* D E
|
|
|
|
*
|
|
|
|
*
|
2011-02-16 21:59:44 +01:00
|
|
|
* Stems
|
|
|
|
*
|
2013-08-04 09:25:24 +02:00
|
|
|
* Stems are detected by `af_{cjk,latin,...}_hint_edges'.
|
|
|
|
*
|
2011-02-16 21:59:44 +01:00
|
|
|
* Segments need to be `linked' to other ones in order to detect stems.
|
|
|
|
* A stem is made of two segments that face each other in opposite
|
|
|
|
* directions and that are sufficiently close to each other. Using
|
|
|
|
* vocabulary from the TrueType specification, stem segments form a
|
|
|
|
* `black distance'.
|
|
|
|
*
|
2011-02-22 10:29:30 +01:00
|
|
|
* In the above ASCII drawing, the horizontal segments are BC, DE, and
|
|
|
|
* FG; the vertical segments are AB, CD, EF, and GH.
|
|
|
|
*
|
2011-02-16 21:59:44 +01:00
|
|
|
* Each segment has at most one `best' candidate to form a black
|
|
|
|
* distance, or no candidate at all. Notice that two distinct segments
|
|
|
|
* can have the same candidate, which frequently means a serif.
|
|
|
|
*
|
|
|
|
* A stem is recognized by the following condition:
|
|
|
|
*
|
|
|
|
* best segment_1 = segment_2 && best segment_2 = segment_1
|
|
|
|
*
|
|
|
|
* The best candidate is stored in field `link' in structure
|
|
|
|
* `AF_Segment'.
|
|
|
|
*
|
2011-02-22 10:29:30 +01:00
|
|
|
* In the above ASCII drawing, the best candidate for both AB and CD is
|
|
|
|
* GH, while the best candidate for GH is AB. Similarly, the best
|
|
|
|
* candidate for EF and GH is AB, while the best candidate for AB is
|
|
|
|
* GH.
|
|
|
|
*
|
2013-08-04 09:25:24 +02:00
|
|
|
* The detection and handling of stems is dependent on the writing
|
|
|
|
* system.
|
|
|
|
*
|
2011-02-16 21:59:44 +01:00
|
|
|
*
|
|
|
|
* Serifs
|
|
|
|
*
|
2013-08-04 09:25:24 +02:00
|
|
|
* Serifs are detected by `af_{cjk,latin,...}_hint_edges'.
|
|
|
|
*
|
|
|
|
* In comparison to a stem, a serif (as handled by the auto-hinter
|
2014-09-24 19:06:13 +02:00
|
|
|
* module that takes care of the `latin' writing system) has
|
2011-02-16 21:59:44 +01:00
|
|
|
*
|
|
|
|
* best segment_1 = segment_2 && best segment_2 != segment_1
|
|
|
|
*
|
2011-02-22 10:29:30 +01:00
|
|
|
* where segment_1 corresponds to the serif segment (CD and EF in the
|
|
|
|
* above ASCII drawing).
|
2011-02-16 21:59:44 +01:00
|
|
|
*
|
|
|
|
* The best candidate is stored in field `serif' in structure
|
|
|
|
* `AF_Segment' (and `link' is set to NULL).
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Touched points
|
|
|
|
*
|
|
|
|
* A point is called `touched' if it has been processed somehow by the
|
|
|
|
* auto-hinter. It basically means that it shouldn't be moved again
|
|
|
|
* (or moved only under certain constraints to preserve the already
|
|
|
|
* applied processing).
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Flat and round segments
|
|
|
|
*
|
|
|
|
* Segments are `round' or `flat', depending on the series of points
|
|
|
|
* that define them. A segment is round if the next and previous point
|
|
|
|
* of an extremum (which can be either a single point or sequence of
|
|
|
|
* points) are both conic or cubic control points. Otherwise, a
|
|
|
|
* segment with an extremum is flat.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Strong Points
|
|
|
|
*
|
2014-09-24 19:06:13 +02:00
|
|
|
* Experience has shown that points not part of an edge need to be
|
|
|
|
* interpolated linearly between their two closest edges, even if these
|
|
|
|
* are not part of the contour of those particular points. Typical
|
|
|
|
* candidates for this are
|
2011-02-16 21:59:44 +01:00
|
|
|
*
|
|
|
|
* - angle points (i.e., points where the `in' and `out' direction
|
|
|
|
* differ greatly)
|
|
|
|
*
|
|
|
|
* - inflection points (i.e., where the `in' and `out' angles are the
|
2013-08-04 09:25:24 +02:00
|
|
|
* same, but the curvature changes sign) [currently, such points
|
2014-09-24 19:06:13 +02:00
|
|
|
* aren't handled specially in the auto-hinter]
|
2011-02-16 21:59:44 +01:00
|
|
|
*
|
2014-09-24 19:06:13 +02:00
|
|
|
* `af_glyph_hints_align_strong_points' is the function that takes
|
2011-02-16 21:59:44 +01:00
|
|
|
* care of such situations; it is equivalent to the TrueType `IP'
|
|
|
|
* hinting instruction.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Weak Points
|
|
|
|
*
|
|
|
|
* Other points in the outline must be interpolated using the
|
|
|
|
* coordinates of their previous and next unfitted contour neighbours.
|
|
|
|
* These are called `weak points' and are touched by the function
|
|
|
|
* `af_glyph_hints_align_weak_points', equivalent to the TrueType `IUP'
|
|
|
|
* hinting instruction. Typical candidates are control points and
|
|
|
|
* points on the contour without a major direction.
|
|
|
|
*
|
|
|
|
* The major effect is to reduce possible distortion caused by
|
|
|
|
* alignment of edges and strong points, thus weak points are processed
|
|
|
|
* after strong points.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
/* point hint flags */
|
2015-02-19 09:46:48 +01:00
|
|
|
#define AF_FLAG_NONE 0
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2015-02-19 09:46:48 +01:00
|
|
|
/* point type flags */
|
|
|
|
#define AF_FLAG_CONIC ( 1U << 0 )
|
|
|
|
#define AF_FLAG_CUBIC ( 1U << 1 )
|
|
|
|
#define AF_FLAG_CONTROL ( AF_FLAG_CONIC | AF_FLAG_CUBIC )
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2015-02-19 09:46:48 +01:00
|
|
|
/* point touch flags */
|
|
|
|
#define AF_FLAG_TOUCH_X ( 1U << 2 )
|
|
|
|
#define AF_FLAG_TOUCH_Y ( 1U << 3 )
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2015-02-19 09:46:48 +01:00
|
|
|
/* candidates for weak interpolation have this flag set */
|
2015-03-01 07:45:36 +01:00
|
|
|
#define AF_FLAG_WEAK_INTERPOLATION ( 1U << 4 )
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2016-03-20 22:20:32 +01:00
|
|
|
/* the distance to the next point is very small */
|
|
|
|
#define AF_FLAG_NEAR ( 1U << 5 )
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
/* edge hint flags */
|
2015-02-19 09:46:48 +01:00
|
|
|
#define AF_EDGE_NORMAL 0
|
|
|
|
#define AF_EDGE_ROUND ( 1U << 0 )
|
|
|
|
#define AF_EDGE_SERIF ( 1U << 1 )
|
|
|
|
#define AF_EDGE_DONE ( 1U << 2 )
|
|
|
|
#define AF_EDGE_NEUTRAL ( 1U << 3 ) /* edge aligns to a neutral blue zone */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct AF_PointRec_* AF_Point;
|
|
|
|
typedef struct AF_SegmentRec_* AF_Segment;
|
|
|
|
typedef struct AF_EdgeRec_* AF_Edge;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct AF_PointRec_
|
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_UShort flags; /* point flags used by hinter */
|
|
|
|
FT_Char in_dir; /* direction of inwards vector */
|
|
|
|
FT_Char out_dir; /* direction of outwards vector */
|
2005-03-01 16:48:29 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Pos ox, oy; /* original, scaled position */
|
2012-07-06 19:38:44 +02:00
|
|
|
FT_Short fx, fy; /* original, unscaled position (in font units) */
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Pos x, y; /* current position */
|
|
|
|
FT_Pos u, v; /* current (x,y) or (y,x) depending on context */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_Point next; /* next point in contour */
|
|
|
|
AF_Point prev; /* previous point in contour */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_PointRec;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct AF_SegmentRec_
|
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Byte flags; /* edge/segment flags for this segment */
|
|
|
|
FT_Char dir; /* segment direction */
|
|
|
|
FT_Short pos; /* position of segment */
|
2016-07-15 10:23:11 +02:00
|
|
|
FT_Short delta; /* deviation from segment position */
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Short min_coord; /* minimum coordinate of segment */
|
|
|
|
FT_Short max_coord; /* maximum coordinate of segment */
|
2006-12-01 09:20:47 +01:00
|
|
|
FT_Short height; /* the hinted segment height */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_Edge edge; /* the segment's parent edge */
|
|
|
|
AF_Segment edge_next; /* link to next segment in parent edge */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_Segment link; /* (stem) link segment */
|
|
|
|
AF_Segment serif; /* primary segment for serifs */
|
|
|
|
FT_Pos score; /* used during stem matching */
|
2006-02-09 15:17:04 +01:00
|
|
|
FT_Pos len; /* used during stem matching */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2011-06-08 09:32:56 +02:00
|
|
|
AF_Point first; /* first point in edge segment */
|
|
|
|
AF_Point last; /* last point in edge segment */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_SegmentRec;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct AF_EdgeRec_
|
|
|
|
{
|
2012-07-06 19:38:44 +02:00
|
|
|
FT_Short fpos; /* original, unscaled position (in font units) */
|
|
|
|
FT_Pos opos; /* original, scaled position */
|
|
|
|
FT_Pos pos; /* current position */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Byte flags; /* edge flags */
|
|
|
|
FT_Char dir; /* edge direction */
|
|
|
|
FT_Fixed scale; /* used to speed up interpolation between edges */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2012-07-06 19:38:44 +02:00
|
|
|
AF_Width blue_edge; /* non-NULL if this is a blue edge */
|
|
|
|
AF_Edge link; /* link edge */
|
|
|
|
AF_Edge serif; /* primary edge for serifs */
|
|
|
|
FT_Int score; /* used during stem matching */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
AF_Segment first; /* first segment in edge */
|
|
|
|
AF_Segment last; /* last segment in edge */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_EdgeRec;
|
|
|
|
|
2015-01-14 19:36:02 +01:00
|
|
|
#define AF_SEGMENTS_EMBEDDED 18 /* number of embedded segments */
|
|
|
|
#define AF_EDGES_EMBEDDED 12 /* number of embedded edges */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef struct AF_AxisHintsRec_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2011-02-16 21:59:44 +01:00
|
|
|
FT_Int num_segments; /* number of used segments */
|
|
|
|
FT_Int max_segments; /* number of allocated segments */
|
|
|
|
AF_Segment segments; /* segments array */
|
2007-06-11 07:37:35 +02:00
|
|
|
#ifdef AF_SORT_SEGMENTS
|
|
|
|
FT_Int mid_segments;
|
|
|
|
#endif
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
FT_Int num_edges; /* number of used edges */
|
|
|
|
FT_Int max_edges; /* number of allocated edges */
|
|
|
|
AF_Edge edges; /* edges array */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
AF_Direction major_dir; /* either vertical or horizontal */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2015-01-14 19:36:02 +01:00
|
|
|
/* two arrays to avoid allocation penalty */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
AF_SegmentRec segments[AF_SEGMENTS_EMBEDDED];
|
|
|
|
AF_EdgeRec edges[AF_EDGES_EMBEDDED];
|
|
|
|
} embedded;
|
|
|
|
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
} AF_AxisHintsRec, *AF_AxisHints;
|
|
|
|
|
|
|
|
|
2015-01-14 19:26:49 +01:00
|
|
|
#define AF_POINTS_EMBEDDED 96 /* number of embedded points */
|
|
|
|
#define AF_CONTOURS_EMBEDDED 8 /* number of embedded contours */
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef struct AF_GlyphHintsRec_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2013-12-18 12:59:35 +01:00
|
|
|
FT_Memory memory;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2013-12-18 12:59:35 +01:00
|
|
|
FT_Fixed x_scale;
|
|
|
|
FT_Pos x_delta;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2013-12-18 12:59:35 +01:00
|
|
|
FT_Fixed y_scale;
|
|
|
|
FT_Pos y_delta;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2013-12-18 12:59:35 +01:00
|
|
|
FT_Int max_points; /* number of allocated points */
|
|
|
|
FT_Int num_points; /* number of used points */
|
|
|
|
AF_Point points; /* points array */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2013-12-18 12:59:35 +01:00
|
|
|
FT_Int max_contours; /* number of allocated contours */
|
|
|
|
FT_Int num_contours; /* number of used contours */
|
|
|
|
AF_Point* contours; /* contours array */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2013-12-18 12:59:35 +01:00
|
|
|
AF_AxisHintsRec axis[AF_DIMENSION_MAX];
|
2005-02-28 23:09:07 +01:00
|
|
|
|
[autofit] Introduce `styles'.
This is the new top-level structure for handling glyph input data;
scripts are now defined separately.
* src/autofit/aftypes.h (SCRIPT): Updated.
(AF_ScriptClassRec): Move `blue_stringset' and `writing_system'
members to ...
(AF_Style_ClassRec): ... this new structure.
(AF_Style): New enumeration.
(AF_StyleMetricsRec): Replace `script' enumeration with
`style_class' pointer.
(AF_DEFINE_SCRIPT_CLASS, AF_DECLARE_SCRIPT_CLASS): Updated.
(AF_DEFINE_STYLE_CLASS, AF_DECLARE_STYLE_CLASS): New macros.
* src/autofit/afstyles.h: New file, using data from `afscript.h'.
* src/autofit/afscript.h: Updated.
* src/autofit/afcjk.c (af_cjk_metrics_init_widths,
af_cjk_metrics_init_blues, af_cjk_hint_edges): Updated.
* src/autofit/afglobal.c (SCRIPT): Updated.
(STYLE): Redefine macro to load `afstyles.h'.
(af_script_names) [FT_DEBUG_LEVEL_TRACE]: Replace with...
(af_style_names): ... this array.
(af_face_globals_compute_script_coverage): Renamed to...
(af_face_globals_compute_style_coverage): ... this.
Updated.
(af_face_globals_new, af_face_globals_free,
af_face_globals_get_metrics): Updated.
* src/autofit/afglobal.h (SCRIPT): Updated.
(STYLE): Redefine macro to load `afstyles.h'.
(AF_SCRIPT_FALLBACK): Update definition. This will get more
refinements with later on.
(AF_SCRIPT_UNASSIGNED): Replace with...
(AF_STYLE_UNASSIGNED): ... this macro.
(AF_FaceGlobalsRec): Updated.
* src/autofit/aflatin.c (af_latin_metrics_init_widths,
af_latin_metrics_init_blues, af_latin_metrics_scale_dim,
af_latin_hint_edges): Updated.
* src/autofit/aflatin2.c (af_latin2_metrics_init_widths): Updated.
(af_ltn2_uniranges): Removed.
* src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph):
Updated.
* src/autofit/afpic.c (autofit_module_class_pic_init): Updated.
* src/autofit/afpic.h (AF_STYLE_CLASSES_GET): New macro.
(AFModulePIC): Add `af_style_classes' and `af_style_classes_rec'
members.
* src/autofit/afranges.h: Updated.
* src/autofit/rules.mk (AUTOF_DRV_H): Add `afstyles.h'.
2013-12-20 17:26:26 +01:00
|
|
|
FT_UInt32 scaler_flags; /* copy of scaler flags */
|
|
|
|
FT_UInt32 other_flags; /* free for style-specific */
|
|
|
|
/* implementations */
|
2013-12-18 12:59:35 +01:00
|
|
|
AF_StyleMetrics metrics;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2013-12-18 12:59:35 +01:00
|
|
|
FT_Pos xmin_delta; /* used for warping */
|
|
|
|
FT_Pos xmax_delta;
|
2011-02-16 21:59:44 +01:00
|
|
|
|
2015-01-14 19:26:49 +01:00
|
|
|
/* Two arrays to avoid allocation penalty. */
|
|
|
|
/* The `embedded' structure must be the last element! */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
AF_Point contours[AF_CONTOURS_EMBEDDED];
|
|
|
|
AF_PointRec points[AF_POINTS_EMBEDDED];
|
|
|
|
} embedded;
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
} AF_GlyphHintsRec;
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
#define AF_HINTS_TEST_SCALER( h, f ) ( (h)->scaler_flags & (f) )
|
|
|
|
#define AF_HINTS_TEST_OTHER( h, f ) ( (h)->other_flags & (f) )
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2006-09-26 23:55:44 +02:00
|
|
|
|
2011-04-18 19:05:28 +02:00
|
|
|
#ifdef FT_DEBUG_AUTOFIT
|
2006-09-26 17:42:44 +02:00
|
|
|
|
2006-09-26 23:55:44 +02:00
|
|
|
#define AF_HINTS_DO_HORIZONTAL( h ) \
|
|
|
|
( !_af_debug_disable_horz_hints && \
|
|
|
|
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL ) )
|
|
|
|
|
|
|
|
#define AF_HINTS_DO_VERTICAL( h ) \
|
|
|
|
( !_af_debug_disable_vert_hints && \
|
|
|
|
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL ) )
|
2006-09-26 17:42:44 +02:00
|
|
|
|
2006-11-03 10:40:12 +01:00
|
|
|
#define AF_HINTS_DO_BLUES( h ) ( !_af_debug_disable_blue_hints )
|
2006-11-02 17:37:35 +01:00
|
|
|
|
2011-04-18 19:05:28 +02:00
|
|
|
#else /* !FT_DEBUG_AUTOFIT */
|
2006-09-26 23:55:44 +02:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
#define AF_HINTS_DO_HORIZONTAL( h ) \
|
|
|
|
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL )
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
#define AF_HINTS_DO_VERTICAL( h ) \
|
|
|
|
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL )
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2015-04-21 07:13:59 +02:00
|
|
|
#define AF_HINTS_DO_BLUES( h ) 1
|
|
|
|
|
|
|
|
#endif /* !FT_DEBUG_AUTOFIT */
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
#define AF_HINTS_DO_ADVANCE( h ) \
|
|
|
|
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2015-04-16 20:11:49 +02:00
|
|
|
#define AF_HINTS_DO_WARP( h ) \
|
|
|
|
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_WARPER )
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2006-09-26 23:55:44 +02:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL( AF_Direction )
|
|
|
|
af_direction_compute( FT_Pos dx,
|
|
|
|
FT_Pos dy );
|
|
|
|
|
|
|
|
|
2005-03-01 16:48:29 +01:00
|
|
|
FT_LOCAL( FT_Error )
|
|
|
|
af_axis_hints_new_segment( AF_AxisHints axis,
|
|
|
|
FT_Memory memory,
|
|
|
|
AF_Segment *asegment );
|
|
|
|
|
|
|
|
FT_LOCAL( FT_Error)
|
|
|
|
af_axis_hints_new_edge( AF_AxisHints axis,
|
|
|
|
FT_Int fpos,
|
2007-06-11 07:37:35 +02:00
|
|
|
AF_Direction dir,
|
2015-12-25 08:05:30 +01:00
|
|
|
FT_Bool top_to_bottom_hinting,
|
2005-03-01 16:48:29 +01:00
|
|
|
FT_Memory memory,
|
|
|
|
AF_Edge *edge );
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL( void )
|
|
|
|
af_glyph_hints_init( AF_GlyphHints hints,
|
|
|
|
FT_Memory memory );
|
|
|
|
|
2004-06-04 19:41:59 +02:00
|
|
|
FT_LOCAL( void )
|
2013-12-18 12:59:35 +01:00
|
|
|
af_glyph_hints_rescale( AF_GlyphHints hints,
|
|
|
|
AF_StyleMetrics metrics );
|
2004-06-04 19:41:59 +02:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL( FT_Error )
|
2005-03-03 18:09:08 +01:00
|
|
|
af_glyph_hints_reload( AF_GlyphHints hints,
|
2010-05-22 07:43:22 +02:00
|
|
|
FT_Outline* outline );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
FT_LOCAL( void )
|
2005-03-03 18:09:08 +01:00
|
|
|
af_glyph_hints_save( AF_GlyphHints hints,
|
|
|
|
FT_Outline* outline );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
FT_LOCAL( void )
|
|
|
|
af_glyph_hints_align_edge_points( AF_GlyphHints hints,
|
|
|
|
AF_Dimension dim );
|
|
|
|
|
|
|
|
FT_LOCAL( void )
|
|
|
|
af_glyph_hints_align_strong_points( AF_GlyphHints hints,
|
|
|
|
AF_Dimension dim );
|
|
|
|
|
|
|
|
FT_LOCAL( void )
|
|
|
|
af_glyph_hints_align_weak_points( AF_GlyphHints hints,
|
|
|
|
AF_Dimension dim );
|
|
|
|
|
2011-03-02 03:52:36 +01:00
|
|
|
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
2006-01-21 15:31:45 +01:00
|
|
|
FT_LOCAL( void )
|
|
|
|
af_glyph_hints_scale_dim( AF_GlyphHints hints,
|
|
|
|
AF_Dimension dim,
|
|
|
|
FT_Fixed scale,
|
|
|
|
FT_Pos delta );
|
|
|
|
#endif
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL( void )
|
|
|
|
af_glyph_hints_done( AF_GlyphHints hints );
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
2006-02-10 23:15:22 +01:00
|
|
|
#define AF_SEGMENT_LEN( seg ) ( (seg)->max_coord - (seg)->min_coord )
|
2006-02-09 15:17:04 +01:00
|
|
|
|
2006-02-10 23:15:22 +01:00
|
|
|
#define AF_SEGMENT_DIST( seg1, seg2 ) ( ( (seg1)->pos > (seg2)->pos ) \
|
|
|
|
? (seg1)->pos - (seg2)->pos \
|
|
|
|
: (seg2)->pos - (seg1)->pos )
|
2006-02-09 15:17:04 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_END_HEADER
|
|
|
|
|
2016-01-12 21:37:13 +01:00
|
|
|
#endif /* AFHINTS_H_ */
|
2005-03-03 18:09:08 +01:00
|
|
|
|
|
|
|
|
2005-03-04 00:05:29 +01:00
|
|
|
/* END */
|