summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2018-11-30 01:09:56 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2018-11-30 01:09:56 +0000
commite2012ff38bc208db38b47955974acfb658dafa9e (patch)
tree442c6ab6fc137e3650ae5a969910c6f0d19aa0ea /Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh
parentbfc1ab8d60cc7919762bc4d066355b1928690a76 (diff)
harfbuzz-2.2.0
git-svn-id: svn://tug.org/texlive/trunk@49277 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh114
1 files changed, 106 insertions, 8 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh
index 87ab4abd3f0..4e63ec8e855 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh
@@ -39,6 +39,27 @@ namespace AAT {
struct SettingName
{
+ friend struct FeatureName;
+
+ int cmp (hb_aat_layout_feature_selector_t key) const
+ { return (int) key - (int) setting; }
+
+ inline hb_aat_layout_feature_selector_t get_selector (void) const
+ { return (hb_aat_layout_feature_selector_t) (unsigned) setting; }
+
+ inline void get_info (hb_aat_layout_feature_selector_info_t *s,
+ hb_aat_layout_feature_selector_t default_selector) const
+ {
+ s->name_id = nameIndex;
+
+ s->enable = (hb_aat_layout_feature_selector_t) (unsigned int) setting;
+ s->disable = default_selector == HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID ?
+ (hb_aat_layout_feature_selector_t) (s->enable + 1) :
+ default_selector;
+
+ s->reserved = 0;
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@@ -51,35 +72,76 @@ struct SettingName
public:
DEFINE_SIZE_STATIC (4);
};
+DECLARE_NULL_NAMESPACE_BYTES (AAT, SettingName);
+
+struct feat;
struct FeatureName
{
+ int cmp (hb_aat_layout_feature_type_t key) const
+ { return (int) key - (int) feature; }
+
enum {
- Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */
- NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in
+ Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */
+ NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in
* the setting name array for this feature should
* be taken as the default for the feature
* (if one is required). If set, then bits 0-15 of this
* featureFlags field contain the index of the setting
* which is to be taken as the default. */
- IndexMask = 0x00FF /* If bits 30 and 31 are set, then these sixteen bits
+ IndexMask = 0x00FF /* If bits 30 and 31 are set, then these sixteen bits
* indicate the index of the setting in the setting name
* array for this feature which should be taken
* as the default. */
};
+ inline unsigned int get_selector_infos (unsigned int start_offset,
+ unsigned int *selectors_count, /* IN/OUT. May be NULL. */
+ hb_aat_layout_feature_selector_info_t *selectors, /* OUT. May be NULL. */
+ unsigned int *pdefault_index, /* OUT. May be NULL. */
+ const void *base) const
+ {
+ hb_array_t< const SettingName> settings_table = (base+settingTableZ).as_array (nSettings);
+
+ static_assert (Index::NOT_FOUND_INDEX == HB_AAT_LAYOUT_NO_SELECTOR_INDEX, "");
+
+ hb_aat_layout_feature_selector_t default_selector = HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID;
+ unsigned int default_index = Index::NOT_FOUND_INDEX;
+ if (featureFlags & Exclusive)
+ {
+ default_index = (featureFlags & NotDefault) ? featureFlags & IndexMask : 0;
+ default_selector = settings_table[default_index].get_selector ();
+ }
+ if (pdefault_index)
+ *pdefault_index = default_index;
+
+ if (selectors_count)
+ {
+ hb_array_t<const SettingName> arr = settings_table.sub_array (start_offset, selectors_count);
+ unsigned int count = arr.len;
+ for (unsigned int i = 0; i < count; i++)
+ settings_table[start_offset + i].get_info (&selectors[i], default_selector);
+ }
+ return settings_table.len;
+ }
+
+ inline hb_aat_layout_feature_type_t get_feature_type () const
+ { return (hb_aat_layout_feature_type_t) (unsigned int) feature; }
+
+ inline hb_ot_name_id_t get_feature_name_id () const { return nameIndex; }
+
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
- (base+settingTable).sanitize (c, nSettings)));
+ (base+settingTableZ).sanitize (c, nSettings)));
}
protected:
HBUINT16 feature; /* Feature type. */
HBUINT16 nSettings; /* The number of records in the setting name array. */
LOffsetTo<UnsizedArrayOf<SettingName>, false>
- settingTable; /* Offset in bytes from the beginning of this table to
+ settingTableZ; /* Offset in bytes from the beginning of this table to
* this feature's setting name array. The actual type of
* record this offset refers to will depend on the
* exclusivity value, as described below. */
@@ -95,11 +157,47 @@ struct feat
{
static const hb_tag_t tableTag = HB_AAT_TAG_feat;
+ inline bool has_data (void) const { return version.to_int (); }
+
+ inline unsigned int get_feature_types (unsigned int start_offset,
+ unsigned int *count,
+ hb_aat_layout_feature_type_t *features) const
+ {
+ unsigned int feature_count = featureNameCount;
+ if (count && *count)
+ {
+ unsigned int len = MIN (feature_count - start_offset, *count);
+ for (unsigned int i = 0; i < len; i++)
+ features[i] = namesZ[i + start_offset].get_feature_type ();
+ *count = len;
+ }
+ return featureNameCount;
+ }
+
+ inline const FeatureName& get_feature (hb_aat_layout_feature_type_t feature_type) const
+ {
+ return namesZ.bsearch (featureNameCount, feature_type);
+ }
+
+ inline hb_ot_name_id_t get_feature_name_id (hb_aat_layout_feature_type_t feature) const
+ { return get_feature (feature).get_feature_name_id (); }
+
+ inline unsigned int get_selector_infos (hb_aat_layout_feature_type_t feature_type,
+ unsigned int start_offset,
+ unsigned int *selectors_count, /* IN/OUT. May be NULL. */
+ hb_aat_layout_feature_selector_info_t *selectors, /* OUT. May be NULL. */
+ unsigned int *default_index /* OUT. May be NULL. */) const
+ {
+ return get_feature (feature_type).get_selector_infos (start_offset, selectors_count, selectors,
+ default_index, this);
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
- names.sanitize (c, featureNameCount, this)));
+ version.major == 1 &&
+ namesZ.sanitize (c, featureNameCount, this)));
}
protected:
@@ -109,8 +207,8 @@ struct feat
/* The number of entries in the feature name array. */
HBUINT16 reserved1; /* Reserved (set to zero). */
HBUINT32 reserved2; /* Reserved (set to zero). */
- UnsizedArrayOf<FeatureName>
- names; /* The feature name array. */
+ SortedUnsizedArrayOf<FeatureName>
+ namesZ; /* The feature name array. */
public:
DEFINE_SIZE_STATIC (24);
};