2005-03-03 18:09:08 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* afhints.h */
|
|
|
|
/* */
|
|
|
|
/* Auto-fitter hinting routines (specification). */
|
|
|
|
/* */
|
2006-01-22 07:58:16 +01:00
|
|
|
/* Copyright 2003, 2004, 2005, 2006 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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
#ifndef __AFHINTS_H__
|
|
|
|
#define __AFHINTS_H__
|
|
|
|
|
|
|
|
#include "aftypes.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
|
|
|
* The definition of outline glyph hints. These are shared by all
|
|
|
|
* script analysis routines (until now).
|
2004-03-27 09:43:17 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
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' */
|
2004-03-27 09:43:17 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
AF_DIR_NONE = 4,
|
|
|
|
AF_DIR_RIGHT = 1,
|
|
|
|
AF_DIR_LEFT = -1,
|
|
|
|
AF_DIR_UP = 2,
|
|
|
|
AF_DIR_DOWN = -2
|
|
|
|
|
|
|
|
} AF_Direction;
|
|
|
|
|
|
|
|
|
|
|
|
/* point hint flags */
|
|
|
|
typedef enum
|
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_FLAG_NONE = 0,
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/* point type flags */
|
|
|
|
AF_FLAG_CONIC = 1 << 0,
|
|
|
|
AF_FLAG_CUBIC = 1 << 1,
|
2004-03-27 09:43:17 +01:00
|
|
|
AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC,
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/* point extremum flags */
|
|
|
|
AF_FLAG_EXTREMA_X = 1 << 2,
|
|
|
|
AF_FLAG_EXTREMA_Y = 1 << 3,
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/* point roundness flags */
|
|
|
|
AF_FLAG_ROUND_X = 1 << 4,
|
|
|
|
AF_FLAG_ROUND_Y = 1 << 5,
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/* point touch flags */
|
|
|
|
AF_FLAG_TOUCH_X = 1 << 6,
|
|
|
|
AF_FLAG_TOUCH_Y = 1 << 7,
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/* candidates for weak interpolation have this flag set */
|
|
|
|
AF_FLAG_WEAK_INTERPOLATION = 1 << 8,
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/* all inflection points in the outline have this flag set */
|
|
|
|
AF_FLAG_INFLECTION = 1 << 9
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_Flags;
|
|
|
|
|
|
|
|
|
|
|
|
/* edge hint flags */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
AF_EDGE_NORMAL = 0,
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_EDGE_ROUND = 1 << 0,
|
|
|
|
AF_EDGE_SERIF = 1 << 1,
|
|
|
|
AF_EDGE_DONE = 1 << 2
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_Edge_Flags;
|
|
|
|
|
|
|
|
|
|
|
|
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 */
|
|
|
|
FT_Short fx, fy; /* original, unscaled position (font units) */
|
|
|
|
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 */
|
|
|
|
FT_Short min_coord; /* minimum coordinate of segment */
|
|
|
|
FT_Short max_coord; /* maximum coordinate of segment */
|
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 num_linked; /* number of linked segments */
|
|
|
|
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
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_Point first; /* first point in edge segment */
|
|
|
|
AF_Point last; /* last point in edge segment */
|
|
|
|
AF_Point* contour; /* ptr to first point of segment's contour */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_SegmentRec;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct AF_EdgeRec_
|
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Short fpos; /* original, unscaled position (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 */
|
|
|
|
AF_Width blue_edge; /* non-NULL if this is a blue edge */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_Edge link;
|
|
|
|
AF_Edge serif;
|
|
|
|
FT_Short num_linked;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Int score;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_Segment first;
|
|
|
|
AF_Segment last;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
} AF_EdgeRec;
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef struct AF_AxisHintsRec_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
|
|
|
FT_Int num_segments;
|
2005-03-01 16:48:29 +01:00
|
|
|
FT_Int max_segments;
|
2004-03-27 09:43:17 +01:00
|
|
|
AF_Segment segments;
|
|
|
|
|
|
|
|
FT_Int num_edges;
|
2005-03-01 16:48:29 +01:00
|
|
|
FT_Int max_edges;
|
2004-03-27 09:43:17 +01:00
|
|
|
AF_Edge edges;
|
|
|
|
|
|
|
|
AF_Direction major_dir;
|
|
|
|
|
|
|
|
} AF_AxisHintsRec, *AF_AxisHints;
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
typedef struct AF_GlyphHintsRec_
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Memory memory;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Fixed x_scale;
|
|
|
|
FT_Pos x_delta;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Fixed y_scale;
|
|
|
|
FT_Pos y_delta;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Pos edge_distance_threshold;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Int max_points;
|
|
|
|
FT_Int num_points;
|
|
|
|
AF_Point points;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Int max_contours;
|
|
|
|
FT_Int num_contours;
|
|
|
|
AF_Point* contours;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_AxisHintsRec axis[AF_DIMENSION_MAX];
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_UInt32 scaler_flags; /* copy of scaler flags */
|
|
|
|
FT_UInt32 other_flags; /* free for script-specific */
|
|
|
|
/* implementations */
|
2004-03-27 09:43:17 +01:00
|
|
|
AF_ScriptMetrics metrics;
|
|
|
|
|
|
|
|
} 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
|
|
|
|
2006-09-26 17:42:44 +02:00
|
|
|
#ifdef AF_DEBUG
|
|
|
|
|
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
|
|
|
|
|
|
|
#define AF_HINTS_DO_ADVANCE( h ) \
|
|
|
|
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
|
|
|
|
|
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
|
|
|
|
2006-09-26 17:42:44 +02:00
|
|
|
#else /* !AF_DEBUG */
|
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
|
|
|
|
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
|
|
|
|
2006-11-03 10:40:12 +01:00
|
|
|
#define AF_HINTS_DO_BLUES( h ) 1
|
2006-11-02 17:37:35 +01:00
|
|
|
|
2006-09-26 17:42:44 +02:00
|
|
|
#endif /* !AF_DEBUG */
|
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,
|
|
|
|
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 );
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
/*
|
|
|
|
* recompute all AF_Point in a AF_GlyphHints from the definitions
|
|
|
|
* in a source outline
|
|
|
|
*/
|
2004-06-04 19:41:59 +02:00
|
|
|
FT_LOCAL( void )
|
|
|
|
af_glyph_hints_rescale( AF_GlyphHints hints,
|
|
|
|
AF_ScriptMetrics metrics );
|
|
|
|
|
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,
|
|
|
|
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 );
|
|
|
|
|
2006-01-21 15:31:45 +01:00
|
|
|
#ifdef AF_USE_WARPER
|
|
|
|
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
|
|
|
|
|
|
|
|
#endif /* __AFHINTS_H__ */
|
2005-03-03 18:09:08 +01:00
|
|
|
|
|
|
|
|
2005-03-04 00:05:29 +01:00
|
|
|
/* END */
|