summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh73
1 files changed, 73 insertions, 0 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh
index 88135234db5..655064bdf70 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh
@@ -59,6 +59,9 @@ enum
struct AxisValueFormat1
{
+ unsigned int get_axis_index () const { return axisIndex; }
+ float get_value () const { return value.to_float (); }
+
hb_ot_name_id_t get_value_name_id () const { return valueNameID; }
bool sanitize (hb_sanitize_context_t *c) const
@@ -84,6 +87,9 @@ struct AxisValueFormat1
struct AxisValueFormat2
{
+ unsigned int get_axis_index () const { return axisIndex; }
+ float get_value () const { return nominalValue.to_float (); }
+
hb_ot_name_id_t get_value_name_id () const { return valueNameID; }
bool sanitize (hb_sanitize_context_t *c) const
@@ -113,6 +119,9 @@ struct AxisValueFormat2
struct AxisValueFormat3
{
+ unsigned int get_axis_index () const { return axisIndex; }
+ float get_value () const { return value.to_float (); }
+
hb_ot_name_id_t get_value_name_id () const { return valueNameID; }
bool sanitize (hb_sanitize_context_t *c) const
@@ -140,6 +149,9 @@ struct AxisValueFormat3
struct AxisValueRecord
{
+ unsigned int get_axis_index () const { return axisIndex; }
+ float get_value () const { return value.to_float (); }
+
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@@ -157,6 +169,9 @@ struct AxisValueRecord
struct AxisValueFormat4
{
+ const AxisValueRecord &get_axis_record (unsigned int axis_index) const
+ { return axisValues.as_array (axisCount)[axis_index]; }
+
hb_ot_name_id_t get_value_name_id () const { return valueNameID; }
bool sanitize (hb_sanitize_context_t *c) const
@@ -183,6 +198,30 @@ struct AxisValueFormat4
struct AxisValue
{
+ bool get_value (unsigned int axis_index) const
+ {
+ switch (u.format)
+ {
+ case 1: return u.format1.get_value ();
+ case 2: return u.format2.get_value ();
+ case 3: return u.format3.get_value ();
+ case 4: return u.format4.get_axis_record (axis_index).get_value ();
+ default:return 0;
+ }
+ }
+
+ unsigned int get_axis_index () const
+ {
+ switch (u.format)
+ {
+ case 1: return u.format1.get_axis_index ();
+ case 2: return u.format2.get_axis_index ();
+ case 3: return u.format3.get_axis_index ();
+ /* case 4: Makes more sense for variable fonts which are handled by fvar in hb-style */
+ default:return -1;
+ }
+ }
+
hb_ot_name_id_t get_value_name_id () const
{
switch (u.format)
@@ -226,6 +265,8 @@ struct AxisValue
struct StatAxisRecord
{
+ int cmp (hb_tag_t key) const { return tag.cmp (key); }
+
hb_ot_name_id_t get_name_id () const { return nameID; }
bool sanitize (hb_sanitize_context_t *c) const
@@ -251,6 +292,38 @@ struct STAT
bool has_data () const { return version.to_int (); }
+ bool find_axis_index (hb_tag_t tag, unsigned int *axis_index) const
+ {
+ hb_array_t<const StatAxisRecord> axes = get_design_axes ();
+ /* TODO: add lfind in hb_array_t and use it in here and fvar's find_axis_info */
+ for (unsigned int i = 0; i < axes.length; i++)
+ if (!axes[i].cmp (tag))
+ {
+ *axis_index = i;
+ return true;
+ }
+ return false;
+ }
+
+ bool get_value (hb_tag_t tag, float *value) const
+ {
+ unsigned int axis_index;
+ if (!find_axis_index (tag, &axis_index)) return false;
+
+ hb_array_t<const OffsetTo<AxisValue>> axis_values = get_axis_value_offsets ();
+ for (unsigned int i = 0; i < axis_values.length; i++)
+ {
+ const AxisValue& axis_value = (this + axis_values[i]);
+ if (axis_value.get_axis_index () == axis_index)
+ {
+ if (value)
+ *value = axis_value.get_value (axis_index);
+ return true;
+ }
+ }
+ return false;
+ }
+
unsigned get_design_axis_count () const { return designAxisCount; }
hb_ot_name_id_t get_axis_record_name_id (unsigned axis_record_index) const