diff --git a/src/OT/glyf/VarCompositeGlyph.hh b/src/OT/glyf/VarCompositeGlyph.hh index 2d62c357b..adb5c1e41 100644 --- a/src/OT/glyf/VarCompositeGlyph.hh +++ b/src/OT/glyf/VarCompositeGlyph.hh @@ -187,7 +187,7 @@ struct VarCompositeGlyphRecord if (flags & AXES_HAVE_VARIATION) { for (unsigned i = 0; i < count; i++) - rec_points[i].x = *q++; + rec_points[i].x = q++->to_int (); rec_points += count; } else @@ -197,11 +197,11 @@ struct VarCompositeGlyphRecord if (flags & HAVE_TRANSLATE_X) translateX = * (const FWORD *) p++; if (flags & HAVE_TRANSLATE_Y) translateY = * (const FWORD *) p++; - if (flags & HAVE_ROTATION) rotation = * (const F4DOT12 *) p++; - if (flags & HAVE_SCALE_X) scaleX = * (const F6DOT10 *) p++; - if (flags & HAVE_SCALE_Y) scaleY = * (const F6DOT10 *) p++; - if (flags & HAVE_SKEW_X) skewX = * (const F4DOT12 *) p++; - if (flags & HAVE_SKEW_Y) skewY = * (const F4DOT12 *) p++; + if (flags & HAVE_ROTATION) rotation = ((const F4DOT12 *) p++)->to_int (); + if (flags & HAVE_SCALE_X) scaleX = ((const F6DOT10 *) p++)->to_int (); + if (flags & HAVE_SCALE_Y) scaleY = ((const F6DOT10 *) p++)->to_int (); + if (flags & HAVE_SKEW_X) skewX = ((const F4DOT12 *) p++)->to_int (); + if (flags & HAVE_SKEW_Y) skewY = ((const F4DOT12 *) p++)->to_int (); if (flags & HAVE_TCENTER_X) tCenterX = * (const FWORD *) p++; if (flags & HAVE_TCENTER_Y) tCenterY = * (const FWORD *) p++; @@ -316,7 +316,7 @@ struct VarCompositeGlyphRecord { unsigned axis_index = axis_width == 1 ? (unsigned) *p++ : (unsigned) *q++; - signed v = have_variations ? rec_points[i].x : *a++; + signed v = have_variations ? rec_points[i].x : a++->to_int (); v = hb_clamp (v, -(1<<14), (1<<14)); setter[axis_index] = v; diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index a4eaa1fe2..72bd09640 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -148,6 +148,9 @@ struct HBFixed : Type static_assert (Type::static_size * 8 > fraction_bits, ""); HBFixed& operator = (typename Type::type i ) { Type::operator= (i); return *this; } + operator signed () const = delete; + operator unsigned () const = delete; + int32_t to_int () const { return Type::v; } float to_float (float offset = 0) const { return ((int32_t) Type::v + offset) / shift; } void set_float (float f) { Type::v = roundf (f * shift); } public: diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index e651db678..af66d6dd4 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -2233,7 +2233,7 @@ struct VarRegionAxis { float evaluate (int coord) const { - int start = startCoord, peak = peakCoord, end = endCoord; + int start = startCoord.to_int (), peak = peakCoord.to_int (), end = endCoord.to_int (); /* TODO Move these to sanitize(). */ if (unlikely (start > peak || peak > end)) @@ -2863,8 +2863,8 @@ struct ConditionFormat1 { // add axisIndex->value into the hashmap so we can check if the record is // unique with variations - int16_t min_val = filterRangeMinValue; - int16_t max_val = filterRangeMaxValue; + int16_t min_val = filterRangeMinValue.to_int (); + int16_t max_val = filterRangeMaxValue.to_int (); hb_codepoint_t val = (max_val << 16) + min_val; condition_map->set (axisIndex, val); @@ -2876,7 +2876,7 @@ struct ConditionFormat1 int v = c->axes_location->get (axis_tag); //condition not met, drop the entire record - if (v < filterRangeMinValue || v > filterRangeMaxValue) + if (v < filterRangeMinValue.to_int () || v > filterRangeMaxValue.to_int ()) return DROP_RECORD_WITH_VAR; //axis pinned and condition met, drop the condition @@ -2886,7 +2886,7 @@ struct ConditionFormat1 bool evaluate (const int *coords, unsigned int coord_len) const { int coord = axisIndex < coord_len ? coords[axisIndex] : 0; - return filterRangeMinValue <= coord && coord <= filterRangeMaxValue; + return filterRangeMinValue.to_int () <= coord && coord <= filterRangeMaxValue.to_int (); } bool sanitize (hb_sanitize_context_t *c) const diff --git a/src/hb-ot-var-avar-table.hh b/src/hb-ot-var-avar-table.hh index cc5c5c006..3449b3049 100644 --- a/src/hb-ot-var-avar-table.hh +++ b/src/hb-ot-var-avar-table.hh @@ -86,8 +86,8 @@ struct SegmentMaps : Array16Of { int map (int value, unsigned int from_offset = 0, unsigned int to_offset = 1) const { -#define fromCoord coords[from_offset] -#define toCoord coords[to_offset] +#define fromCoord coords[from_offset].to_int () +#define toCoord coords[to_offset].to_int () /* The following special-cases are not part of OpenType, which requires * that at least -1, 0, and +1 must be mapped. But we include these as * part of a better error recovery scheme. */ diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index c1d57a002..2c989e241 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -175,15 +175,15 @@ struct AxisRecord void get_coordinates (float &min, float &default_, float &max) const { - default_ = defaultValue / 65536.f; + default_ = defaultValue.to_float (); /* Ensure order, to simplify client math. */ - min = hb_min (default_, minValue / 65536.f); - max = hb_max (default_, maxValue / 65536.f); + min = hb_min (default_, minValue.to_float ()); + max = hb_max (default_, maxValue.to_float ()); } float get_default () const { - return defaultValue / 65536.f; + return defaultValue.to_float (); } public: diff --git a/src/hb-ot-var-gvar-table.hh b/src/hb-ot-var-gvar-table.hh index e02063ca4..1eae6a353 100644 --- a/src/hb-ot-var-gvar-table.hh +++ b/src/hb-ot-var-gvar-table.hh @@ -128,13 +128,13 @@ struct TupleVariationHeader for (unsigned int i = 0; i < coord_count; i++) { int v = coords[i]; - int peak = peak_tuple[i]; + int peak = peak_tuple[i].to_int (); if (!peak || v == peak) continue; if (has_intermediate ()) { - int start = start_tuple[i]; - int end = end_tuple[i]; + int start = start_tuple[i].to_int (); + int end = end_tuple[i].to_int (); if (unlikely (start > peak || peak > end || (start < 0 && end > 0 && peak))) continue; if (v < start || v > end) return 0.f;