From 7208dbd7e38d10ef1fd298ce082d9800529ae71f Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 2 Mar 2015 06:57:36 +0100 Subject: [PATCH] Synchronize with FreeType. This corresponds to commits 6f325c2 New `TYPEOF' macro. 3cfa4d1 Various minor signedness fixes. 0a33a39 [truetype] Various signedness fixes. 81e5ff5 [autofit] Use macros for (unsigned) flags, not enumerations. b57bb11 [autofit] Fix signedness issues. bd133c3 Minor typo. 851e815 Various compiler warning fixes for `make multi'. a07029e Simplify `TYPEOF' macro. --- lib/tablue.hin | 8 ++++---- lib/tagloadr.c | 16 +++++++++------- lib/tagloadr.h | 18 +++++++++++------- lib/taglobal.c | 5 +++-- lib/tahints.c | 12 ++++++------ lib/tahints.h | 18 +++++++++--------- lib/talatin.c | 12 ++++++------ lib/talatin.h | 20 ++++++++++---------- lib/tasort.c | 2 +- lib/tatypes.h | 21 ++++++++++++++++----- 10 files changed, 75 insertions(+), 57 deletions(-) diff --git a/lib/tablue.hin b/lib/tablue.hin index 9929d90..9d644cc 100644 --- a/lib/tablue.hin +++ b/lib/tablue.hin @@ -87,10 +87,10 @@ extern const char ta_blue_strings[]; /* 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 TA_BLUE_PROPERTY_LATIN_TOP (1 << 0) /* must have value 1 */ -#define TA_BLUE_PROPERTY_LATIN_NEUTRAL (1 << 1) -#define TA_BLUE_PROPERTY_LATIN_X_HEIGHT (1 << 2) -#define TA_BLUE_PROPERTY_LATIN_LONG (1 << 3) +#define TA_BLUE_PROPERTY_LATIN_TOP (1U << 0) /* must have value 1 */ +#define TA_BLUE_PROPERTY_LATIN_NEUTRAL (1U << 1) +#define TA_BLUE_PROPERTY_LATIN_X_HEIGHT (1U << 2) +#define TA_BLUE_PROPERTY_LATIN_LONG (1U << 3) #define TA_BLUE_STRINGSET_MAX_LEN @TA_BLUE_STRINGSET_MAX_LEN@ diff --git a/lib/tagloadr.c b/lib/tagloadr.c index 5fc2e30..edca2ca 100644 --- a/lib/tagloadr.c +++ b/lib/tagloadr.c @@ -189,7 +189,8 @@ TA_GlyphLoader_CheckPoints(TA_GlyphLoader loader, /* check points & tags */ - new_max = base->n_points + current->n_points + n_points; + new_max = (FT_UInt)base->n_points + (FT_UInt)current->n_points + + n_points; old_max = loader->max_points; if (new_max > old_max) @@ -240,7 +241,8 @@ TA_GlyphLoader_CheckPoints(TA_GlyphLoader loader, /* check contours */ old_max = loader->max_contours; - new_max = base->n_contours + current->n_contours + n_contours; + new_max = (FT_UInt)base->n_contours + (FT_UInt)current->n_contours + + n_contours; if (new_max > old_max) { short* contours_new; @@ -327,9 +329,9 @@ TA_GlyphLoader_Add(TA_GlyphLoader loader) TA_GlyphLoad base; TA_GlyphLoad current; - FT_UInt n_curr_contours; - FT_UInt n_base_points; - FT_UInt n; + FT_Int n_curr_contours; + FT_Int n_base_points; + FT_Int n; if (!loader) @@ -363,8 +365,8 @@ TA_GlyphLoader_CopyPoints(TA_GlyphLoader target, TA_GlyphLoader source) { FT_Error error; - FT_UInt num_points = source->base.outline.n_points; - FT_UInt num_contours = source->base.outline.n_contours; + FT_UInt num_points = (FT_UInt)source->base.outline.n_points; + FT_UInt num_contours = (FT_UInt)source->base.outline.n_contours; error = TA_GlyphLoader_CheckPoints(target, num_points, num_contours); diff --git a/lib/tagloadr.h b/lib/tagloadr.h index f355d8b..a9e8ee9 100644 --- a/lib/tagloadr.h +++ b/lib/tagloadr.h @@ -93,20 +93,24 @@ TA_GlyphLoader_CheckPoints(TA_GlyphLoader loader, #define TA_GLYPHLOADER_CHECK_P(_loader, _count) \ - ((_count) == 0 || ((_loader)->base.outline.n_points \ - + (_loader)->current.outline.n_points \ - + (unsigned long)(_count)) <= (_loader)->max_points) + ((_count) == 0 \ + || ((FT_UInt)(_loader)->base.outline.n_points \ + + (FT_UInt)(_loader)->current.outline.n_points \ + + (FT_UInt)(_count)) <= (_loader)->max_points) #define TA_GLYPHLOADER_CHECK_C(_loader, _count) \ - ((_count) == 0 || ((_loader)->base.outline.n_contours \ - + (_loader)->current.outline.n_contours \ - + (unsigned long)(_count)) <= (_loader)->max_contours) + ((_count) == 0 \ + || ((FT_UInt)(_loader)->base.outline.n_contours \ + + (FT_UInt)(_loader)->current.outline.n_contours \ + + (FT_UInt)(_count)) <= (_loader)->max_contours) #define TA_GLYPHLOADER_CHECK_POINTS(_loader, _points, _contours) \ ((TA_GLYPHLOADER_CHECK_P(_loader, _points) \ && TA_GLYPHLOADER_CHECK_C(_loader, _contours)) \ ? 0 \ - : TA_GlyphLoader_CheckPoints((_loader), (_points), (_contours))) + : TA_GlyphLoader_CheckPoints((_loader), \ + (FT_UInt)(_points), \ + (FT_UInt)(_contours))) /* check that there is enough space to add */ diff --git a/lib/taglobal.c b/lib/taglobal.c index 3683ddc..1c6ff58 100644 --- a/lib/taglobal.c +++ b/lib/taglobal.c @@ -403,8 +403,9 @@ ta_face_globals_new(FT_Face face, TA_FaceGlobals globals; - globals = (TA_FaceGlobals)calloc(1, sizeof (TA_FaceGlobalsRec) + - face->num_glyphs * sizeof (FT_Byte)); + globals = (TA_FaceGlobals)calloc( + 1, sizeof (TA_FaceGlobalsRec) + + (FT_ULong)face->num_glyphs * sizeof (FT_Byte)); if (!globals) { error = FT_Err_Out_Of_Memory; diff --git a/lib/tahints.c b/lib/tahints.c index 0f1a27a..06c58bc 100644 --- a/lib/tahints.c +++ b/lib/tahints.c @@ -575,7 +575,7 @@ ta_glyph_hints_reload(TA_GlyphHints hints, /* first of all, reallocate the contours array if necessary */ new_max = (FT_UInt)outline->n_contours; - old_max = hints->max_contours; + old_max = (FT_UInt)hints->max_contours; if (new_max <= TA_CONTOURS_EMBEDDED) { @@ -593,7 +593,7 @@ ta_glyph_hints_reload(TA_GlyphHints hints, if (hints->contours == hints->embedded.contours) hints->contours = NULL; - new_max = (new_max + 3) & ~3; /* round up to a multiple of 4 */ + new_max = (new_max + 3) & ~3U; /* round up to a multiple of 4 */ contours_new = (TA_Point*)realloc(hints->contours, new_max * sizeof (TA_Point)); @@ -601,13 +601,13 @@ ta_glyph_hints_reload(TA_GlyphHints hints, return FT_Err_Out_Of_Memory; hints->contours = contours_new; - hints->max_contours = new_max; + hints->max_contours = (FT_Int)new_max; } /* reallocate the points arrays if necessary -- we reserve */ /* two additional point positions, used to hint metrics appropriately */ new_max = (FT_UInt)(outline->n_points + 2); - old_max = hints->max_points; + old_max = (FT_UInt)hints->max_points; if (new_max <= TA_POINTS_EMBEDDED) { @@ -625,7 +625,7 @@ ta_glyph_hints_reload(TA_GlyphHints hints, if (hints->points == hints->embedded.points) hints->points = NULL; - new_max = (new_max + 2 + 7) & ~7; /* round up to a multiple of 8 */ + new_max = (new_max + 2 + 7) & ~7U; /* round up to a multiple of 8 */ points_new = (TA_Point)realloc(hints->points, new_max * sizeof (TA_PointRec)); @@ -633,7 +633,7 @@ ta_glyph_hints_reload(TA_GlyphHints hints, return FT_Err_Out_Of_Memory; hints->points = points_new; - hints->max_points = new_max; + hints->max_points = (FT_Int)new_max; } hints->num_points = outline->n_points; diff --git a/lib/tahints.h b/lib/tahints.h index 084072e..2911308 100644 --- a/lib/tahints.h +++ b/lib/tahints.h @@ -208,24 +208,24 @@ typedef enum TA_Direction_ #define TA_FLAG_NONE 0 /* point type flags */ -#define TA_FLAG_CONIC (1 << 0) -#define TA_FLAG_CUBIC (1 << 1) +#define TA_FLAG_CONIC (1U << 0) +#define TA_FLAG_CUBIC (1U << 1) #define TA_FLAG_CONTROL (TA_FLAG_CONIC | TA_FLAG_CUBIC) /* point touch flags */ -#define TA_FLAG_TOUCH_X (1 << 2) -#define TA_FLAG_TOUCH_Y (1 << 3) +#define TA_FLAG_TOUCH_X (1U << 2) +#define TA_FLAG_TOUCH_Y (1U << 3) /* candidates for weak interpolation have this flag set */ -#define TA_FLAG_WEAK_INTERPOLATION (1 << 4) +#define TA_FLAG_WEAK_INTERPOLATION (1U << 4) /* edge hint flags */ #define TA_EDGE_NORMAL 0 -#define TA_EDGE_ROUND (1 << 0) -#define TA_EDGE_SERIF (1 << 1) -#define TA_EDGE_DONE (1 << 2) -#define TA_EDGE_NEUTRAL (1 << 3) +#define TA_EDGE_ROUND (1U << 0) +#define TA_EDGE_SERIF (1U << 1) +#define TA_EDGE_DONE (1U << 2) +#define TA_EDGE_NEUTRAL (1U << 3) typedef struct TA_PointRec_* TA_Point; diff --git a/lib/talatin.c b/lib/talatin.c index 123eddb..3950710 100644 --- a/lib/talatin.c +++ b/lib/talatin.c @@ -259,8 +259,8 @@ ta_latin_metrics_init_blues(TA_LatinMetrics metrics, { FT_Pos flats[TA_BLUE_STRING_MAX_LEN]; FT_Pos rounds[TA_BLUE_STRING_MAX_LEN]; - FT_Int num_flats; - FT_Int num_rounds; + FT_UInt num_flats; + FT_UInt num_rounds; TA_LatinBlue blue; FT_Error error; @@ -1912,7 +1912,7 @@ ta_latin_hints_detect_features(TA_GlyphHints hints, /* compute all edges which lie within blue zones */ -void +static void ta_latin_hints_compute_blue_edges(TA_GlyphHints hints, TA_LatinMetrics metrics) { @@ -2108,10 +2108,10 @@ ta_latin_hints_init(TA_GlyphHints hints, static FT_Pos ta_latin_snap_width(TA_Width widths, - FT_Int count, + FT_UInt count, FT_Pos width) { - int n; + FT_UInt n; FT_Pos best = 64 + 32 + 2; FT_Pos reference = width; FT_Pos scaled; @@ -2360,7 +2360,7 @@ ta_latin_align_serif_edge(TA_GlyphHints hints, /* the main grid-fitting routine */ -void +static void ta_latin_hint_edges(TA_GlyphHints hints, TA_Dimension dim) { diff --git a/lib/talatin.h b/lib/talatin.h index 250bd03..d647c97 100644 --- a/lib/talatin.h +++ b/lib/talatin.h @@ -48,11 +48,11 @@ extern const TA_WritingSystemClassRec ta_latin_writing_system_class; #define TA_LATIN_MAX_WIDTHS 16 -#define TA_LATIN_BLUE_ACTIVE (1 << 0) /* set if zone height is <= 3/4px */ -#define TA_LATIN_BLUE_TOP (1 << 1) /* set if we have a top blue zone */ -#define TA_LATIN_BLUE_NEUTRAL (1 << 2) /* set if we have neutral blue zone */ -#define TA_LATIN_BLUE_ADJUSTMENT (1 << 3) /* used for scale adjustment */ - /* optimization */ +#define TA_LATIN_BLUE_ACTIVE (1U << 0) /* set if zone height is <= 3/4px */ +#define TA_LATIN_BLUE_TOP (1U << 1) /* set if we have a top blue zone */ +#define TA_LATIN_BLUE_NEUTRAL (1U << 2) /* set if we have neutral blue zone */ +#define TA_LATIN_BLUE_ADJUSTMENT (1U << 3) /* used for scale adjustment */ + /* optimization */ typedef struct TA_LatinBlueRec_ @@ -110,11 +110,11 @@ ta_latin_metrics_check_digits(TA_LatinMetrics metrics, FT_Face face); -#define TA_LATIN_HINTS_HORZ_SNAP (1 << 0) /* enable stem width snapping */ -#define TA_LATIN_HINTS_VERT_SNAP (1 << 1) /* enable stem height snapping */ -#define TA_LATIN_HINTS_STEM_ADJUST (1 << 2) /* enable stem width/height */ - /* adjustment */ -#define TA_LATIN_HINTS_MONO (1 << 3) /* indicate monochrome rendering */ +#define TA_LATIN_HINTS_HORZ_SNAP (1U << 0) /* enable stem width snapping */ +#define TA_LATIN_HINTS_VERT_SNAP (1U << 1) /* enable stem height snapping */ +#define TA_LATIN_HINTS_STEM_ADJUST (1U << 2) /* enable stem width/height */ + /* adjustment */ +#define TA_LATIN_HINTS_MONO (1U << 3) /* indicate monochrome rendering */ #define TA_LATIN_HINTS_DO_HORZ_SNAP(h) \ diff --git a/lib/tasort.c b/lib/tasort.c index 6d04e44..35cace1 100644 --- a/lib/tasort.c +++ b/lib/tasort.c @@ -101,7 +101,7 @@ ta_sort_and_quantize_widths(FT_UInt* count, sum += table[j].org; table[j].org = 0; } - table[cur_idx].org = sum / j; + table[cur_idx].org = sum / (FT_Pos)j; if (i < *count - 1) { diff --git a/lib/tatypes.h b/lib/tatypes.h index fe267f1..11e0b47 100644 --- a/lib/tatypes.h +++ b/lib/tatypes.h @@ -90,12 +90,23 @@ extern void* _ta_debug_hints; #define TA_ABS(a) ((a) < 0 ? -(a) : (a)) +/* from file `ftconfig.h' (2015-03-02) from FreeType */ +/* typeof condition taken from gnulib's `intprops.h' header file */ +#if (__GNUC__ >= 2 \ + || defined(__IBM__TYPEOF__) \ + || (__SUNPRO_C >= 0x5110 && !__STDC__)) +#define TYPEOF(type) (__typeof__ (type)) +#else +#define TYPEOF(type) /* empty */ +#endif + /* from file `ftobjs.h' from FreeType */ -#define TA_PAD_FLOOR(x, n) ((x) & ~((n) - 1)) +/* we use the TYPEOF macro to suppress signedness compilation warnings */ +#define TA_PAD_FLOOR(x, n) ((x) & ~TYPEOF(x)((n) - 1)) #define TA_PAD_ROUND(x, n) TA_PAD_FLOOR((x) + ((n) / 2), n) #define TA_PAD_CEIL(x, n) TA_PAD_FLOOR((x) + ((n) - 1), n) -#define TA_PIX_FLOOR(x) ((x) & ~63) +#define TA_PIX_FLOOR(x) ((x) & ~TYPEOF(x)63) #define TA_PIX_ROUND(x) TA_PIX_FLOOR((x) + 32) #define TA_PIX_CEIL(x) TA_PIX_FLOOR((x) + 63) @@ -140,9 +151,9 @@ typedef struct TA_GlyphHintsRec_* TA_GlyphHints; /* a scaler models the target pixel device that will receive */ /* the auto-hinted glyph image */ -#define TA_SCALER_FLAG_NO_HORIZONTAL 0x01 /* disable horizontal hinting */ -#define TA_SCALER_FLAG_NO_VERTICAL 0x02 /* disable vertical hinting */ -#define TA_SCALER_FLAG_NO_ADVANCE 0x04 /* disable advance hinting */ +#define TA_SCALER_FLAG_NO_HORIZONTAL 0x01U /* disable horizontal hinting */ +#define TA_SCALER_FLAG_NO_VERTICAL 0x02U /* disable vertical hinting */ +#define TA_SCALER_FLAG_NO_ADVANCE 0x04U /* disable advance hinting */ typedef struct TA_ScalerRec_ { -- 2.11.4.GIT