diff --git a/src/hb-config.hh b/src/hb-config.hh index 3f9a9ca6f..8f78ede21 100644 --- a/src/hb-config.hh +++ b/src/hb-config.hh @@ -69,6 +69,7 @@ #define HB_NO_OT_SHAPE_FRACTIONS #define HB_NO_STAT #define HB_NO_SUBSET_LAYOUT +#define HB_NO_VAR #endif #ifdef HB_MINI diff --git a/src/hb-font.cc b/src/hb-font.cc index 7eee284e6..f450d8889 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -1824,6 +1824,7 @@ _hb_font_adopt_var_coords_normalized (hb_font_t *font, font->num_coords = coords_length; } +#ifndef HB_NO_VAR /** * hb_font_set_variations: * @@ -1854,7 +1855,6 @@ hb_font_set_variations (hb_font_t *font, normalized, coords_length); _hb_font_adopt_var_coords_normalized (font, normalized, coords_length); } - /** * hb_font_set_var_coords_design: * @@ -1875,6 +1875,7 @@ hb_font_set_var_coords_design (hb_font_t *font, hb_ot_var_normalize_coords (font->face, coords_length, coords, normalized); _hb_font_adopt_var_coords_normalized (font, normalized, coords_length); } +#endif /** * hb_font_set_var_coords_normalized: diff --git a/src/hb-ot-face-table-list.hh b/src/hb-ot-face-table-list.hh index 348c3b299..e4ed6b07d 100644 --- a/src/hb-ot-face-table-list.hh +++ b/src/hb-ot-face-table-list.hh @@ -74,9 +74,11 @@ HB_OT_TABLE (OT, VORG) #endif /* OpenType variations. */ +#ifndef HB_NO_VAR HB_OT_TABLE (OT, fvar) HB_OT_TABLE (OT, avar) HB_OT_TABLE (OT, MVAR) +#endif /* Legacy kern. */ #ifndef HB_NO_OT_KERN diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index f801f5af8..c332e2815 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1747,11 +1747,11 @@ struct VarData float *scalars /*OUT */, unsigned int num_scalars) const { - assert (num_scalars == regionIndices.len); - for (unsigned int i = 0; i < num_scalars; i++) - { - scalars[i] = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count); - } + unsigned count = hb_min (num_scalars, regionIndices.len); + for (unsigned int i = 0; i < count; i++) + scalars[i] = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count); + for (unsigned int i = count; i < num_scalars; i++) + scalars[i] = 0.f; } bool sanitize (hb_sanitize_context_t *c) const @@ -1779,8 +1779,12 @@ struct VariationStore float get_delta (unsigned int outer, unsigned int inner, const int *coords, unsigned int coord_count) const { +#ifdef HB_NO_VAR + return 0.f; +#endif + if (unlikely (outer >= dataSets.len)) - return 0.; + return 0.f; return (this+dataSets[outer]).get_delta (inner, coords, coord_count, @@ -1797,6 +1801,10 @@ struct VariationStore bool sanitize (hb_sanitize_context_t *c) const { +#ifdef HB_NO_VAR + return true; +#endif + TRACE_SANITIZE (this); return_trace (c->check_struct (this) && format == 1 && @@ -1812,6 +1820,12 @@ struct VariationStore float *scalars /*OUT*/, unsigned int num_scalars) const { +#ifdef HB_NO_VAR + for (unsigned i = 0; i < num_scalars; i++) + scalars[i] = 0.f; + return; +#endif + (this+dataSets[ivs]).get_scalars (coords, coord_count, this+regions, &scalars[0], num_scalars); } @@ -2154,8 +2168,10 @@ struct Device { case 1: case 2: case 3: return u.hinting.get_x_delta (font); +#ifndef HB_NO_VAR case 0x8000: return u.variation.get_x_delta (font, store); +#endif default: return 0; } @@ -2166,8 +2182,10 @@ struct Device { case 1: case 2: case 3: return u.hinting.get_y_delta (font); +#ifndef HB_NO_VAR case 0x8000: return u.variation.get_y_delta (font, store); +#endif default: return 0; } @@ -2180,8 +2198,10 @@ struct Device switch (u.b.format) { case 1: case 2: case 3: return_trace (u.hinting.sanitize (c)); +#ifndef HB_NO_VAR case 0x8000: return_trace (u.variation.sanitize (c)); +#endif default: return_trace (true); } @@ -2191,7 +2211,9 @@ struct Device union { DeviceHeader b; HintingDevice hinting; +#ifndef HB_NO_VAR VariationDevice variation; +#endif } u; public: DEFINE_SIZE_UNION (6, b); diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 4bc3d7e15..dd54c9b34 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -2661,11 +2661,17 @@ struct GSUBGPOS bool find_variations_index (const int *coords, unsigned int num_coords, unsigned int *index) const - { return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations)) - .find_index (coords, num_coords, index); } + { +#ifdef HB_NOVAR + return false; +#endif + return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations)) + .find_index (coords, num_coords, index); + } const Feature& get_feature_variation (unsigned int feature_index, unsigned int variations_index) const { +#ifndef HB_NO_VAR if (FeatureVariations::NOT_FOUND_INDEX != variations_index && version.to_int () >= 0x00010001u) { @@ -2674,6 +2680,7 @@ struct GSUBGPOS if (feature) return *feature; } +#endif return get_feature (feature_index); } @@ -2695,8 +2702,10 @@ struct GSUBGPOS this, out); +#ifndef HB_NO_VAR if (version.to_int () >= 0x00010001u) out->featureVars.serialize_copy (c->serializer, featureVars, this, out); +#endif return_trace (true); } @@ -2717,7 +2726,10 @@ struct GSUBGPOS scriptList.sanitize (c, this) && featureList.sanitize (c, this) && CastR> (lookupList).sanitize (c, this) && - (version.to_int () < 0x00010001u || featureVars.sanitize (c, this))); +#ifndef HB_NO_VAR + (version.to_int () < 0x00010001u || featureVars.sanitize (c, this)) && +#endif + true); } template diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc index 5eea90d25..6b8b09b6b 100644 --- a/src/hb-ot-var.cc +++ b/src/hb-ot-var.cc @@ -24,7 +24,9 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-open-type.hh" +#include "hb.hh" + +#ifndef HB_NO_VAR #include "hb-ot-var.h" @@ -213,3 +215,6 @@ hb_ot_var_normalize_coords (hb_face_t *face, face->table.avar->map_coords (normalized_coords, coords_length); } + + +#endif diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index f4877332b..6b33c17b6 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -197,7 +197,9 @@ _nameid_closure (hb_face_t *face, #ifndef HB_NO_STAT face->table.STAT->collect_name_ids (nameids); #endif +#ifndef HB_NO_VAR face->table.fvar->collect_name_ids (nameids); +#endif } /**