[autofit] Use macros for (unsigned) flags, not enumerations.

This harmonizes with other code in FreeType (and reduces the number
of necessary casts to avoid compiler warnings).

* src/autofit/afblue.hin: Make flag macros unsigned.
* src/autofit/afblue.h: Regenerated.

* src/autofit/afcjk.h: Replace flag enumeration with macros.
* src/autofit/afcjk.c: Updated.

* src/autofit/afhints.h (AF_Flags, AF_Edge_Flags): Replace with
macros.
* src/autofit/afhints.c: Updated.

* src/autofit/aflatin.h: Replace flag enumerations with macros.
* src/autofit/aflatin.c, src/autofit/aflatin2.c: Updated.

* src/autofit/aftypes.h (AF_ScalerFlags): Replace with macros.
This commit is contained in:
Werner Lemberg 2015-02-19 09:46:48 +01:00
parent d217950f82
commit 81e5ff53a8
11 changed files with 109 additions and 119 deletions

View File

@ -1,3 +1,25 @@
2015-02-19 Werner Lemberg <wl@gnu.org>
[autofit] Use macros for (unsigned) flags, not enumerations.
This harmonizes with other code in FreeType (and reduces the number
of necessary casts to avoid compiler warnings).
* src/autofit/afblue.hin: Make flag macros unsigned.
* src/autofit/afblue.h: Regenerated.
* src/autofit/afcjk.h: Replace flag enumeration with macros.
* src/autofit/afcjk.c: Updated.
* src/autofit/afhints.h (AF_Flags, AF_Edge_Flags): Replace with
macros.
* src/autofit/afhints.c: Updated.
* src/autofit/aflatin.h: Replace flag enumerations with macros.
* src/autofit/aflatin.c, src/autofit/aflatin2.c: Updated.
* src/autofit/aftypes.h (AF_ScalerFlags): Replace with macros.
2015-02-18 Werner Lemberg <wl@gnu.org>
[type1] Fix signedness issues.

View File

@ -145,13 +145,13 @@ FT_BEGIN_HEADER
/* Properties are specific to a writing system. We assume that a given */
/* blue string can't be used in more than a single writing system, which */
/* is a safe bet. */
#define AF_BLUE_PROPERTY_LATIN_TOP ( 1 << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1 << 1 )
#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1 << 2 )
#define AF_BLUE_PROPERTY_LATIN_LONG ( 1 << 3 )
#define AF_BLUE_PROPERTY_LATIN_TOP ( 1U << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1U << 1 )
#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1U << 2 )
#define AF_BLUE_PROPERTY_LATIN_LONG ( 1U << 3 )
#define AF_BLUE_PROPERTY_CJK_TOP ( 1 << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1 << 1 ) /* must have value 2 */
#define AF_BLUE_PROPERTY_CJK_TOP ( 1U << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1U << 1 ) /* must have value 2 */
#define AF_BLUE_PROPERTY_CJK_RIGHT AF_BLUE_PROPERTY_CJK_TOP

View File

@ -96,13 +96,13 @@ FT_BEGIN_HEADER
/* Properties are specific to a writing system. We assume that a given */
/* blue string can't be used in more than a single writing system, which */
/* is a safe bet. */
#define AF_BLUE_PROPERTY_LATIN_TOP ( 1 << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1 << 1 )
#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1 << 2 )
#define AF_BLUE_PROPERTY_LATIN_LONG ( 1 << 3 )
#define AF_BLUE_PROPERTY_LATIN_TOP ( 1U << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1U << 1 )
#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1U << 2 )
#define AF_BLUE_PROPERTY_LATIN_LONG ( 1U << 3 )
#define AF_BLUE_PROPERTY_CJK_TOP ( 1 << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1 << 1 ) /* must have value 2 */
#define AF_BLUE_PROPERTY_CJK_TOP ( 1U << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1U << 1 ) /* must have value 2 */
#define AF_BLUE_PROPERTY_CJK_RIGHT AF_BLUE_PROPERTY_CJK_TOP

View File

@ -720,8 +720,8 @@
{
AF_Point pt = seg->first;
AF_Point last = seg->last;
AF_Flags f0 = (AF_Flags)( pt->flags & AF_FLAG_CONTROL );
AF_Flags f1;
FT_UInt f0 = pt->flags & AF_FLAG_CONTROL;
FT_UInt f1;
seg->flags &= ~AF_EDGE_ROUND;
@ -729,7 +729,7 @@
for ( ; pt != last; f0 = f1 )
{
pt = pt->next;
f1 = (AF_Flags)( pt->flags & AF_FLAG_CONTROL );
f1 = pt->flags & AF_FLAG_CONTROL;
if ( !f0 && !f1 )
break;
@ -1405,8 +1405,8 @@
af_cjk_compute_stem_width( AF_GlyphHints hints,
AF_Dimension dim,
FT_Pos width,
AF_Edge_Flags base_flags,
AF_Edge_Flags stem_flags )
FT_UInt base_flags,
FT_UInt stem_flags )
{
AF_CJKMetrics metrics = (AF_CJKMetrics)hints->metrics;
AF_CJKAxis axis = &metrics->axis[dim];
@ -1530,10 +1530,9 @@
{
FT_Pos dist = stem_edge->opos - base_edge->opos;
FT_Pos fitted_width = af_cjk_compute_stem_width(
hints, dim, dist,
(AF_Edge_Flags)base_edge->flags,
(AF_Edge_Flags)stem_edge->flags );
FT_Pos fitted_width = af_cjk_compute_stem_width( hints, dim, dist,
base_edge->flags,
stem_edge->flags );
stem_edge->pos = base_edge->pos + fitted_width;
@ -1611,8 +1610,8 @@
org_len = edge2->opos - edge->opos;
cur_len = af_cjk_compute_stem_width( hints, dim, org_len,
(AF_Edge_Flags)edge->flags,
(AF_Edge_Flags)edge2->flags );
edge->flags,
edge2->flags );
org_center = ( edge->opos + edge2->opos ) / 2 + anchor;
cur_pos1 = org_center - cur_len / 2;

View File

@ -55,14 +55,10 @@ FT_BEGIN_HEADER
#define AF_CJK_MAX_WIDTHS 16
enum
{
AF_CJK_BLUE_ACTIVE = 1 << 0, /* set if zone height is <= 3/4px */
AF_CJK_BLUE_TOP = 1 << 1, /* result of AF_CJK_IS_TOP_BLUE */
AF_CJK_BLUE_ADJUSTMENT = 1 << 2, /* used for scale adjustment */
/* optimization */
AF_CJK_BLUE_FLAG_MAX
};
#define AF_CJK_BLUE_ACTIVE ( 1U << 0 ) /* zone height is <= 3/4px */
#define AF_CJK_BLUE_TOP ( 1U << 1 ) /* result of AF_CJK_IS_TOP_BLUE */
#define AF_CJK_BLUE_ADJUSTMENT ( 1U << 2 ) /* used for scale adjustment */
/* optimization */
typedef struct AF_CJKBlueRec_

View File

@ -254,7 +254,7 @@
static const char*
af_edge_flags_to_string( AF_Edge_Flags flags )
af_edge_flags_to_string( FT_UInt flags )
{
static char temp[32];
int pos = 0;
@ -329,7 +329,7 @@
AF_INDEX_NUM( seg->edge, edges ),
seg->height,
seg->height - ( seg->max_coord - seg->min_coord ),
af_edge_flags_to_string( (AF_Edge_Flags)seg->flags ) ));
af_edge_flags_to_string( seg->flags ) ));
AF_DUMP(( "\n" ));
}
}
@ -456,7 +456,7 @@
edge->blue_edge ? 'y' : 'n',
edge->opos / 64.0,
edge->pos / 64.0,
af_edge_flags_to_string( (AF_Edge_Flags)edge->flags ) ));
af_edge_flags_to_string( edge->flags ) ));
AF_DUMP(( "\n" ));
}
}
@ -1110,7 +1110,7 @@
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges;
AF_Flags touch_flag;
FT_UInt touch_flag;
if ( dim == AF_DIMENSION_HORZ )
@ -1363,7 +1363,7 @@
AF_Point point_limit = points + hints->num_points;
AF_Point* contour = hints->contours;
AF_Point* contour_limit = contour + hints->num_contours;
AF_Flags touch_flag;
FT_UInt touch_flag;
AF_Point point;
AF_Point end_point;
AF_Point first_point;

View File

@ -207,35 +207,27 @@ FT_BEGIN_HEADER
/* point hint flags */
typedef enum AF_Flags_
{
AF_FLAG_NONE = 0,
#define AF_FLAG_NONE 0
/* point type flags */
AF_FLAG_CONIC = 1 << 0,
AF_FLAG_CUBIC = 1 << 1,
AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC,
/* 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 )
/* point touch flags */
AF_FLAG_TOUCH_X = 1 << 2,
AF_FLAG_TOUCH_Y = 1 << 3,
/* point touch flags */
#define AF_FLAG_TOUCH_X ( 1U << 2 )
#define AF_FLAG_TOUCH_Y ( 1U << 3 )
/* candidates for weak interpolation have this flag set */
AF_FLAG_WEAK_INTERPOLATION = 1 << 4
} AF_Flags;
/* candidates for weak interpolation have this flag set */
#define AF_FLAG_WEAK_INTERPOLATION ( 1 << 4 )
/* edge hint flags */
typedef enum AF_Edge_Flags_
{
AF_EDGE_NORMAL = 0,
AF_EDGE_ROUND = 1 << 0,
AF_EDGE_SERIF = 1 << 1,
AF_EDGE_DONE = 1 << 2,
AF_EDGE_NEUTRAL = 1 << 3 /* set if edge aligns to a neutral blue zone */
} AF_Edge_Flags;
#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 */
typedef struct AF_PointRec_* AF_Point;

View File

@ -2071,8 +2071,8 @@
af_latin_compute_stem_width( AF_GlyphHints hints,
AF_Dimension dim,
FT_Pos width,
AF_Edge_Flags base_flags,
AF_Edge_Flags stem_flags )
FT_UInt base_flags,
FT_UInt stem_flags )
{
AF_LatinMetrics metrics = (AF_LatinMetrics)hints->metrics;
AF_LatinAxis axis = &metrics->axis[dim];
@ -2239,10 +2239,9 @@
{
FT_Pos dist = stem_edge->opos - base_edge->opos;
FT_Pos fitted_width = af_latin_compute_stem_width(
hints, dim, dist,
(AF_Edge_Flags)base_edge->flags,
(AF_Edge_Flags)stem_edge->flags );
FT_Pos fitted_width = af_latin_compute_stem_width( hints, dim, dist,
base_edge->flags,
stem_edge->flags );
stem_edge->pos = base_edge->pos + fitted_width;
@ -2437,10 +2436,9 @@
org_len = edge2->opos - edge->opos;
cur_len = af_latin_compute_stem_width(
hints, dim, org_len,
(AF_Edge_Flags)edge->flags,
(AF_Edge_Flags)edge2->flags );
cur_len = af_latin_compute_stem_width( hints, dim, org_len,
edge->flags,
edge2->flags );
/* some voodoo to specially round edges for small stem widths; */
/* the idea is to align the center of a stem, then shifting */
@ -2507,10 +2505,9 @@
org_len = edge2->opos - edge->opos;
org_center = org_pos + ( org_len >> 1 );
cur_len = af_latin_compute_stem_width(
hints, dim, org_len,
(AF_Edge_Flags)edge->flags,
(AF_Edge_Flags)edge2->flags );
cur_len = af_latin_compute_stem_width( hints, dim, org_len,
edge->flags,
edge2->flags );
if ( edge2->flags & AF_EDGE_DONE )
{
@ -2568,10 +2565,9 @@
org_len = edge2->opos - edge->opos;
org_center = org_pos + ( org_len >> 1 );
cur_len = af_latin_compute_stem_width(
hints, dim, org_len,
(AF_Edge_Flags)edge->flags,
(AF_Edge_Flags)edge2->flags );
cur_len = af_latin_compute_stem_width( hints, dim, org_len,
edge->flags,
edge2->flags );
cur_pos1 = FT_PIX_ROUND( org_pos );
delta1 = cur_pos1 + ( cur_len >> 1 ) - org_center;

View File

@ -63,15 +63,11 @@ FT_BEGIN_HEADER
#define AF_LATIN_MAX_WIDTHS 16
enum
{
AF_LATIN_BLUE_ACTIVE = 1 << 0, /* set if zone height is <= 3/4px */
AF_LATIN_BLUE_TOP = 1 << 1, /* set if we have a top blue zone */
AF_LATIN_BLUE_NEUTRAL = 1 << 2, /* set if we have neutral blue zone */
AF_LATIN_BLUE_ADJUSTMENT = 1 << 3, /* used for scale adjustment */
/* optimization */
AF_LATIN_BLUE_FLAG_MAX
};
#define AF_LATIN_BLUE_ACTIVE ( 1U << 0 ) /* zone height is <= 3/4px */
#define AF_LATIN_BLUE_TOP ( 1U << 1 ) /* we have a top blue zone */
#define AF_LATIN_BLUE_NEUTRAL ( 1U << 2 ) /* we have neutral blue zone */
#define AF_LATIN_BLUE_ADJUSTMENT ( 1U << 3 ) /* used for scale adjustment */
/* optimization */
typedef struct AF_LatinBlueRec_
@ -138,15 +134,11 @@ FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
enum
{
AF_LATIN_HINTS_HORZ_SNAP = 1 << 0, /* enable stem width snapping */
AF_LATIN_HINTS_VERT_SNAP = 1 << 1, /* enable stem height snapping */
AF_LATIN_HINTS_STEM_ADJUST = 1 << 2, /* enable stem width/height */
/* adjustment */
AF_LATIN_HINTS_MONO = 1 << 3 /* indicate monochrome */
/* rendering */
};
#define AF_LATIN_HINTS_HORZ_SNAP ( 1U << 0 ) /* stem width snapping */
#define AF_LATIN_HINTS_VERT_SNAP ( 1U << 1 ) /* stem height snapping */
#define AF_LATIN_HINTS_STEM_ADJUST ( 1U << 2 ) /* stem width/height */
/* adjustment */
#define AF_LATIN_HINTS_MONO ( 1U << 3 ) /* monochrome rendering */
#define AF_LATIN_HINTS_DO_HORZ_SNAP( h ) \

View File

@ -835,8 +835,8 @@
{
AF_Point pt = first;
AF_Point last = point;
AF_Flags f0 = (AF_Flags)( pt->flags & AF_FLAG_CONTROL );
AF_Flags f1;
FT_UInt f0 = pt->flags & AF_FLAG_CONTROL;
FT_UInt f1;
segment->flags &= ~AF_EDGE_ROUND;
@ -844,7 +844,7 @@
for ( ; pt != last; f0 = f1 )
{
pt = pt->next;
f1 = (AF_Flags)( pt->flags & AF_FLAG_CONTROL );
f1 = pt->flags & AF_FLAG_CONTROL;
if ( !f0 && !f1 )
break;
@ -1621,8 +1621,8 @@
af_latin2_compute_stem_width( AF_GlyphHints hints,
AF_Dimension dim,
FT_Pos width,
AF_Edge_Flags base_flags,
AF_Edge_Flags stem_flags )
FT_UInt base_flags,
FT_UInt stem_flags )
{
AF_LatinMetrics metrics = (AF_LatinMetrics) hints->metrics;
AF_LatinAxis axis = & metrics->axis[dim];
@ -1793,10 +1793,9 @@
{
FT_Pos dist = stem_edge->opos - base_edge->opos;
FT_Pos fitted_width = af_latin2_compute_stem_width(
hints, dim, dist,
(AF_Edge_Flags)base_edge->flags,
(AF_Edge_Flags)stem_edge->flags );
FT_Pos fitted_width = af_latin2_compute_stem_width( hints, dim, dist,
base_edge->flags,
stem_edge->flags );
stem_edge->pos = base_edge->pos + fitted_width;
@ -1942,10 +1941,9 @@
org_len = edge2->opos - edge->opos;
cur_len = af_latin2_compute_stem_width(
hints, dim, org_len,
(AF_Edge_Flags)edge->flags,
(AF_Edge_Flags)edge2->flags );
cur_len = af_latin2_compute_stem_width( hints, dim, org_len,
edge->flags,
edge2->flags );
if ( cur_len <= 64 )
u_off = d_off = 32;
else
@ -2007,10 +2005,9 @@
org_len = edge2->opos - edge->opos;
org_center = org_pos + ( org_len >> 1 );
cur_len = af_latin2_compute_stem_width(
hints, dim, org_len,
(AF_Edge_Flags)edge->flags,
(AF_Edge_Flags)edge2->flags );
cur_len = af_latin2_compute_stem_width( hints, dim, org_len,
edge->flags,
edge2->flags );
org_left = org_pos + ( ( org_len - cur_len ) >> 1 );
org_right = org_pos + ( ( org_len + cur_len ) >> 1 );

View File

@ -168,13 +168,9 @@ extern void* _af_debug_hints;
* auto-hinted glyph image.
*/
typedef enum AF_ScalerFlags_
{
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;
#define AF_SCALER_FLAG_NO_HORIZONTAL 1U /* disable horizontal hinting */
#define AF_SCALER_FLAG_NO_VERTICAL 2U /* disable vertical hinting */
#define AF_SCALER_FLAG_NO_ADVANCE 4U /* disable advance hinting */
typedef struct AF_ScalerRec_