[config] Add HB_NO_VAR to disable variations support, enabled by HB_TINY

Part of https://github.com/harfbuzz/harfbuzz/issues/1652
This commit is contained in:
Behdad Esfahbod 2019-06-19 19:26:22 -07:00
parent 230adf2c41
commit a849873124
7 changed files with 56 additions and 11 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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);

View File

@ -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<OffsetTo<TLookupList>> (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 <typename T>

View File

@ -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

View File

@ -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
}
/**