提交 19b60255 编写于 作者: E Ebrahim Byagowi 提交者: Behdad Esfahbod

[feat] Address @behdad comments

上级 9212ec20
...@@ -181,6 +181,7 @@ HB_OT_RAGEL_sources = \ ...@@ -181,6 +181,7 @@ HB_OT_RAGEL_sources = \
$(NULL) $(NULL)
HB_OT_headers = \ HB_OT_headers = \
hb-aat.h \
hb-ot.h \ hb-ot.h \
hb-ot-color.h \ hb-ot-color.h \
hb-ot-font.h \ hb-ot-font.h \
...@@ -189,7 +190,6 @@ HB_OT_headers = \ ...@@ -189,7 +190,6 @@ HB_OT_headers = \
hb-ot-name.h \ hb-ot-name.h \
hb-ot-shape.h \ hb-ot-shape.h \
hb-ot-var.h \ hb-ot-var.h \
hb-aat.h \
$(NULL) $(NULL)
# Optional Sources and Headers with external deps # Optional Sources and Headers with external deps
......
...@@ -45,7 +45,6 @@ struct SettingName ...@@ -45,7 +45,6 @@ struct SettingName
return_trace (likely (c->check_struct (this))); return_trace (likely (c->check_struct (this)));
} }
public:
HBUINT16 setting; /* The setting. */ HBUINT16 setting; /* The setting. */
NameID nameIndex; /* The name table index for the setting's name. */ NameID nameIndex; /* The name table index for the setting's name. */
public: public:
...@@ -56,18 +55,15 @@ struct feat; ...@@ -56,18 +55,15 @@ struct feat;
struct FeatureName struct FeatureName
{ {
<<<<<<< HEAD
=======
static int cmp (const void *key_, const void *entry_) static int cmp (const void *key_, const void *entry_)
{ {
hb_aat_layout_feature_type_t key = * (hb_aat_layout_feature_type_t *) key_; hb_aat_feature_type_t key = * (hb_aat_feature_type_t *) key_;
const FeatureName * entry = (const FeatureName *) entry_; const FeatureName * entry = (const FeatureName *) entry_;
return key < entry->feature ? -1 : return key < entry->feature ? -1 :
key > entry->feature ? 1 : key > entry->feature ? 1 :
0; 0;
} }
>>>>>>> 08982bb4... [feat] Expose public API
enum { enum {
Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */ Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */
NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in
...@@ -82,40 +78,36 @@ struct FeatureName ...@@ -82,40 +78,36 @@ struct FeatureName
* as the default. */ * as the default. */
}; };
<<<<<<< HEAD
=======
inline unsigned int get_settings (const feat *feat, inline unsigned int get_settings (const feat *feat,
hb_aat_layout_feature_setting_t *default_setting, hb_bool_t *is_exclusive,
unsigned int start_offset, unsigned int start_offset,
unsigned int *selectors_count, unsigned int *records_count,
hb_aat_layout_feature_type_selector_t *selectors_buffer) const hb_aat_feature_option_record_t *records_buffer) const
{ {
bool exclusive = featureFlags & Exclusive; bool exclusive = featureFlags & Exclusive;
bool not_default = featureFlags & NotDefault; bool not_default = featureFlags & NotDefault;
if (is_exclusive) *is_exclusive = exclusive;
const UnsizedArrayOf<SettingName>& settings = feat+settingTable; const UnsizedArrayOf<SettingName>& settings = feat+settingTable;
unsigned int len = 0; unsigned int len = 0;
unsigned int settings_count = nSettings; unsigned int settings_count = nSettings;
if (selectors_count && selectors_buffer) if (records_count && records_buffer)
{ {
len = MIN (settings_count - start_offset, *selectors_count); len = MIN (settings_count - start_offset, *records_count);
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < len; i++)
{ {
selectors_buffer[i].name_id = settings[start_offset + i].nameIndex; records_buffer[i].is_default = exclusive && not_default &&
selectors_buffer[i].setting = settings[start_offset + i].setting; i + start_offset == (featureFlags & IndexMask);
records_buffer[i].name_id = settings[start_offset + i].nameIndex;
records_buffer[i].setting = settings[start_offset + i].setting;
} }
if (exclusive && !not_default && start_offset == 0 && len != 0)
records_buffer[0].is_default = true;
} }
if (default_setting) if (is_exclusive) *is_exclusive = exclusive;
{ if (records_count) *records_count = len;
unsigned int index = not_default ? featureFlags & IndexMask : 0;
if (exclusive && index < settings_count)
*default_setting = settings[index].setting;
else *default_setting = HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED;
}
if (selectors_count) *selectors_count = len;
return settings_count; return settings_count;
} }
>>>>>>> 08982bb4... [feat] Expose public API
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
...@@ -123,11 +115,6 @@ struct FeatureName ...@@ -123,11 +115,6 @@ struct FeatureName
(base+settingTable).sanitize (c, nSettings))); (base+settingTable).sanitize (c, nSettings)));
} }
inline hb_aat_layout_feature_type_t get_feature () const
{ return (hb_aat_layout_feature_type_t) (unsigned int) feature; }
inline unsigned int get_name_id () const { return nameIndex; }
protected: protected:
HBUINT16 feature; /* Feature type. */ HBUINT16 feature; /* Feature type. */
HBUINT16 nSettings; /* The number of records in the setting name array. */ HBUINT16 nSettings; /* The number of records in the setting name array. */
...@@ -148,37 +135,24 @@ struct feat ...@@ -148,37 +135,24 @@ struct feat
{ {
static const hb_tag_t tableTag = HB_AAT_TAG_feat; static const hb_tag_t tableTag = HB_AAT_TAG_feat;
inline unsigned int get_features (unsigned int start_offset, inline const FeatureName& get_feature (hb_aat_feature_type_t key) const
unsigned int *record_count,
hb_aat_layout_feature_record_t *record_buffer) const
{ {
unsigned int feature_count = featureNameCount; const FeatureName* feature = (FeatureName*) hb_bsearch (&key, &names,
if (record_count)
{
unsigned int len = MIN (feature_count - start_offset, *record_count);
for (unsigned int i = 0; i < len; i++)
{
record_buffer[i].feature = names[i + start_offset].get_feature ();
record_buffer[i].name_id = names[i + start_offset].get_name_id ();
}
}
return featureNameCount;
}
inline unsigned int get_settings (hb_aat_layout_feature_type_t type,
hb_aat_layout_feature_setting_t *default_setting, /* OUT. May be NULL. */
unsigned int start_offset,
unsigned int *selectors_count, /* IN/OUT. May be NULL. */
hb_aat_layout_feature_type_selector_t *selectors_buffer /* OUT. May be NULL. */) const
{
const FeatureName* feature = (FeatureName*) hb_bsearch (&type, &names,
FeatureName::static_size, FeatureName::static_size,
sizeof (FeatureName), sizeof (FeatureName),
FeatureName::cmp); FeatureName::cmp);
return (feature ? *feature : Null (FeatureName)).get_settings (this, default_setting, return feature ? *feature : Null (FeatureName);
start_offset, selectors_count, }
selectors_buffer);
inline unsigned int get_settings (hb_aat_feature_type_t key,
hb_bool_t *is_exclusive,
unsigned int start_offset,
unsigned int *records_count,
hb_aat_feature_option_record_t *records_buffer) const
{
return get_feature (key).get_settings (this, is_exclusive, start_offset,
records_count, records_buffer);
} }
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
......
...@@ -959,7 +959,7 @@ struct Chain ...@@ -959,7 +959,7 @@ struct Chain
{ {
const Feature &feature = featureZ[i]; const Feature &feature = featureZ[i];
hb_aat_layout_feature_type_t type = (hb_aat_layout_feature_type_t) (unsigned int) feature.featureType; hb_aat_layout_feature_type_t type = (hb_aat_layout_feature_type_t) (unsigned int) feature.featureType;
hb_aat_layout_feature_setting_t setting = feature.featureSetting; hb_aat_layout_feature_setting_t setting = (hb_aat_layout_feature_setting_t) (unsigned int) feature.featureSetting;
retry: retry:
const hb_aat_map_builder_t::feature_info_t *info = map->features.bsearch ((uint16_t) type); const hb_aat_map_builder_t::feature_info_t *info = map->features.bsearch ((uint16_t) type);
if (info && info->setting == setting) if (info && info->setting == setting)
......
...@@ -53,37 +53,37 @@ static const hb_aat_feature_mapping_t feature_mappings[] = ...@@ -53,37 +53,37 @@ static const hb_aat_feature_mapping_t feature_mappings[] =
{HB_TAG ('c','p','s','p'), HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT, HB_AAT_LAYOUT_SELECTOR_CASE_SENSITIVE_SPACING_ON, HB_AAT_LAYOUT_SELECTOR_CASE_SENSITIVE_SPACING_OFF}, {HB_TAG ('c','p','s','p'), HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT, HB_AAT_LAYOUT_SELECTOR_CASE_SENSITIVE_SPACING_ON, HB_AAT_LAYOUT_SELECTOR_CASE_SENSITIVE_SPACING_OFF},
{HB_TAG ('c','s','w','h'), HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES, HB_AAT_LAYOUT_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_ON, HB_AAT_LAYOUT_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_OFF}, {HB_TAG ('c','s','w','h'), HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES, HB_AAT_LAYOUT_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_ON, HB_AAT_LAYOUT_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_OFF},
{HB_TAG ('d','l','i','g'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_SELECTOR_RARE_LIGATURES_ON, HB_AAT_LAYOUT_SELECTOR_RARE_LIGATURES_OFF}, {HB_TAG ('d','l','i','g'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_SELECTOR_RARE_LIGATURES_ON, HB_AAT_LAYOUT_SELECTOR_RARE_LIGATURES_OFF},
{HB_TAG ('e','x','p','t'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_EXPERT_CHARACTERS, 16}, {HB_TAG ('e','x','p','t'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_EXPERT_CHARACTERS, (hb_aat_layout_feature_setting_t) 16},
{HB_TAG ('f','r','a','c'), HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS, HB_AAT_LAYOUT_SELECTOR_DIAGONAL_FRACTIONS, HB_AAT_LAYOUT_SELECTOR_NO_FRACTIONS}, {HB_TAG ('f','r','a','c'), HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS, HB_AAT_LAYOUT_SELECTOR_DIAGONAL_FRACTIONS, HB_AAT_LAYOUT_SELECTOR_NO_FRACTIONS},
{HB_TAG ('f','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_MONOSPACED_TEXT, 7}, {HB_TAG ('f','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_MONOSPACED_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('h','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_ALT_HALF_WIDTH_TEXT, 7}, {HB_TAG ('h','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_ALT_HALF_WIDTH_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('h','i','s','t'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_SELECTOR_HISTORICAL_LIGATURES_ON, HB_AAT_LAYOUT_SELECTOR_HISTORICAL_LIGATURES_OFF}, {HB_TAG ('h','i','s','t'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_SELECTOR_HISTORICAL_LIGATURES_ON, HB_AAT_LAYOUT_SELECTOR_HISTORICAL_LIGATURES_OFF},
{HB_TAG ('h','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA, HB_AAT_LAYOUT_SELECTOR_ALTERNATE_HORIZ_KANA_ON, HB_AAT_LAYOUT_SELECTOR_ALTERNATE_HORIZ_KANA_OFF}, {HB_TAG ('h','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA, HB_AAT_LAYOUT_SELECTOR_ALTERNATE_HORIZ_KANA_ON, HB_AAT_LAYOUT_SELECTOR_ALTERNATE_HORIZ_KANA_OFF},
{HB_TAG ('h','l','i','g'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_SELECTOR_HISTORICAL_LIGATURES_ON, HB_AAT_LAYOUT_SELECTOR_HISTORICAL_LIGATURES_OFF}, {HB_TAG ('h','l','i','g'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_SELECTOR_HISTORICAL_LIGATURES_ON, HB_AAT_LAYOUT_SELECTOR_HISTORICAL_LIGATURES_OFF},
{HB_TAG ('h','n','g','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION, HB_AAT_LAYOUT_SELECTOR_HANJA_TO_HANGUL, HB_AAT_LAYOUT_SELECTOR_NO_TRANSLITERATION}, {HB_TAG ('h','n','g','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION, HB_AAT_LAYOUT_SELECTOR_HANJA_TO_HANGUL, HB_AAT_LAYOUT_SELECTOR_NO_TRANSLITERATION},
{HB_TAG ('h','o','j','o'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_HOJO_CHARACTERS, 16}, {HB_TAG ('h','o','j','o'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_HOJO_CHARACTERS, (hb_aat_layout_feature_setting_t) 16},
{HB_TAG ('h','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_HALF_WIDTH_TEXT, 7}, {HB_TAG ('h','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_HALF_WIDTH_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('i','t','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN, HB_AAT_LAYOUT_SELECTOR_CJK_ITALIC_ROMAN_ON, HB_AAT_LAYOUT_SELECTOR_CJK_ITALIC_ROMAN_OFF}, {HB_TAG ('i','t','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN, HB_AAT_LAYOUT_SELECTOR_CJK_ITALIC_ROMAN_ON, HB_AAT_LAYOUT_SELECTOR_CJK_ITALIC_ROMAN_OFF},
{HB_TAG ('j','p','0','4'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_JIS2004_CHARACTERS, 16}, {HB_TAG ('j','p','0','4'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_JIS2004_CHARACTERS, (hb_aat_layout_feature_setting_t) 16},
{HB_TAG ('j','p','7','8'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_JIS1978_CHARACTERS, 16}, {HB_TAG ('j','p','7','8'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_JIS1978_CHARACTERS, (hb_aat_layout_feature_setting_t) 16},
{HB_TAG ('j','p','8','3'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_JIS1983_CHARACTERS, 16}, {HB_TAG ('j','p','8','3'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_JIS1983_CHARACTERS, (hb_aat_layout_feature_setting_t) 16},
{HB_TAG ('j','p','9','0'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_JIS1990_CHARACTERS, 16}, {HB_TAG ('j','p','9','0'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_JIS1990_CHARACTERS, (hb_aat_layout_feature_setting_t) 16},
{HB_TAG ('l','i','g','a'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_SELECTOR_COMMON_LIGATURES_ON, HB_AAT_LAYOUT_SELECTOR_COMMON_LIGATURES_OFF}, {HB_TAG ('l','i','g','a'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_SELECTOR_COMMON_LIGATURES_ON, HB_AAT_LAYOUT_SELECTOR_COMMON_LIGATURES_OFF},
{HB_TAG ('l','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE, HB_AAT_LAYOUT_SELECTOR_UPPER_CASE_NUMBERS, 2}, {HB_TAG ('l','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE, HB_AAT_LAYOUT_SELECTOR_UPPER_CASE_NUMBERS, (hb_aat_layout_feature_setting_t) 2},
{HB_TAG ('m','g','r','k'), HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS, HB_AAT_LAYOUT_SELECTOR_MATHEMATICAL_GREEK_ON, HB_AAT_LAYOUT_SELECTOR_MATHEMATICAL_GREEK_OFF}, {HB_TAG ('m','g','r','k'), HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS, HB_AAT_LAYOUT_SELECTOR_MATHEMATICAL_GREEK_ON, HB_AAT_LAYOUT_SELECTOR_MATHEMATICAL_GREEK_OFF},
{HB_TAG ('n','l','c','k'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_NLCCHARACTERS, 16}, {HB_TAG ('n','l','c','k'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_NLCCHARACTERS, (hb_aat_layout_feature_setting_t) 16},
{HB_TAG ('o','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE, HB_AAT_LAYOUT_SELECTOR_LOWER_CASE_NUMBERS, 2}, {HB_TAG ('o','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE, HB_AAT_LAYOUT_SELECTOR_LOWER_CASE_NUMBERS, (hb_aat_layout_feature_setting_t) 2},
{HB_TAG ('o','r','d','n'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_SELECTOR_ORDINALS, HB_AAT_LAYOUT_SELECTOR_NORMAL_POSITION}, {HB_TAG ('o','r','d','n'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_SELECTOR_ORDINALS, HB_AAT_LAYOUT_SELECTOR_NORMAL_POSITION},
{HB_TAG ('p','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_ALT_PROPORTIONAL_TEXT, 7}, {HB_TAG ('p','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_ALT_PROPORTIONAL_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('p','c','a','p'), HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE, HB_AAT_LAYOUT_SELECTOR_LOWER_CASE_PETITE_CAPS, HB_AAT_LAYOUT_SELECTOR_DEFAULT_LOWER_CASE}, {HB_TAG ('p','c','a','p'), HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE, HB_AAT_LAYOUT_SELECTOR_LOWER_CASE_PETITE_CAPS, HB_AAT_LAYOUT_SELECTOR_DEFAULT_LOWER_CASE},
{HB_TAG ('p','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_PROPORTIONAL_TEXT, 7}, {HB_TAG ('p','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_PROPORTIONAL_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('p','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING, HB_AAT_LAYOUT_SELECTOR_PROPORTIONAL_NUMBERS, 4}, {HB_TAG ('p','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING, HB_AAT_LAYOUT_SELECTOR_PROPORTIONAL_NUMBERS, (hb_aat_layout_feature_setting_t) 4},
{HB_TAG ('p','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_PROPORTIONAL_TEXT, 7}, {HB_TAG ('p','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_PROPORTIONAL_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('q','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_QUARTER_WIDTH_TEXT, 7}, {HB_TAG ('q','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_QUARTER_WIDTH_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('r','u','b','y'), HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA, HB_AAT_LAYOUT_SELECTOR_RUBY_KANA_ON, HB_AAT_LAYOUT_SELECTOR_RUBY_KANA_OFF}, {HB_TAG ('r','u','b','y'), HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA, HB_AAT_LAYOUT_SELECTOR_RUBY_KANA_ON, HB_AAT_LAYOUT_SELECTOR_RUBY_KANA_OFF},
{HB_TAG ('s','i','n','f'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_SELECTOR_SCIENTIFIC_INFERIORS, HB_AAT_LAYOUT_SELECTOR_NORMAL_POSITION}, {HB_TAG ('s','i','n','f'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_SELECTOR_SCIENTIFIC_INFERIORS, HB_AAT_LAYOUT_SELECTOR_NORMAL_POSITION},
{HB_TAG ('s','m','c','p'), HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE, HB_AAT_LAYOUT_SELECTOR_LOWER_CASE_SMALL_CAPS, HB_AAT_LAYOUT_SELECTOR_DEFAULT_LOWER_CASE}, {HB_TAG ('s','m','c','p'), HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE, HB_AAT_LAYOUT_SELECTOR_LOWER_CASE_SMALL_CAPS, HB_AAT_LAYOUT_SELECTOR_DEFAULT_LOWER_CASE},
{HB_TAG ('s','m','p','l'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_SIMPLIFIED_CHARACTERS, 16}, {HB_TAG ('s','m','p','l'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_SIMPLIFIED_CHARACTERS, (hb_aat_layout_feature_setting_t) 16},
{HB_TAG ('s','s','0','1'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_ONE_ON, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_ONE_OFF}, {HB_TAG ('s','s','0','1'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_ONE_ON, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_ONE_OFF},
{HB_TAG ('s','s','0','2'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_TWO_ON, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_TWO_OFF}, {HB_TAG ('s','s','0','2'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_TWO_ON, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_TWO_OFF},
{HB_TAG ('s','s','0','3'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_THREE_ON, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_THREE_OFF}, {HB_TAG ('s','s','0','3'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_THREE_ON, HB_AAT_LAYOUT_SELECTOR_STYLISTIC_ALT_THREE_OFF},
...@@ -108,16 +108,16 @@ static const hb_aat_feature_mapping_t feature_mappings[] = ...@@ -108,16 +108,16 @@ static const hb_aat_feature_mapping_t feature_mappings[] =
{HB_TAG ('s','u','p','s'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_SELECTOR_SUPERIORS, HB_AAT_LAYOUT_SELECTOR_NORMAL_POSITION}, {HB_TAG ('s','u','p','s'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_SELECTOR_SUPERIORS, HB_AAT_LAYOUT_SELECTOR_NORMAL_POSITION},
{HB_TAG ('s','w','s','h'), HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES, HB_AAT_LAYOUT_SELECTOR_SWASH_ALTERNATES_ON, HB_AAT_LAYOUT_SELECTOR_SWASH_ALTERNATES_OFF}, {HB_TAG ('s','w','s','h'), HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES, HB_AAT_LAYOUT_SELECTOR_SWASH_ALTERNATES_ON, HB_AAT_LAYOUT_SELECTOR_SWASH_ALTERNATES_OFF},
{HB_TAG ('t','i','t','l'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS, HB_AAT_LAYOUT_SELECTOR_TITLING_CAPS, HB_AAT_LAYOUT_SELECTOR_NO_STYLE_OPTIONS}, {HB_TAG ('t','i','t','l'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS, HB_AAT_LAYOUT_SELECTOR_TITLING_CAPS, HB_AAT_LAYOUT_SELECTOR_NO_STYLE_OPTIONS},
{HB_TAG ('t','n','a','m'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_TRADITIONAL_NAMES_CHARACTERS, 16}, {HB_TAG ('t','n','a','m'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_TRADITIONAL_NAMES_CHARACTERS, (hb_aat_layout_feature_setting_t) 16},
{HB_TAG ('t','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING, HB_AAT_LAYOUT_SELECTOR_MONOSPACED_NUMBERS, 4}, {HB_TAG ('t','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING, HB_AAT_LAYOUT_SELECTOR_MONOSPACED_NUMBERS, (hb_aat_layout_feature_setting_t) 4},
{HB_TAG ('t','r','a','d'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_TRADITIONAL_CHARACTERS, 16}, {HB_TAG ('t','r','a','d'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_SELECTOR_TRADITIONAL_CHARACTERS, (hb_aat_layout_feature_setting_t) 16},
{HB_TAG ('t','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_THIRD_WIDTH_TEXT, 7}, {HB_TAG ('t','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_THIRD_WIDTH_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('u','n','i','c'), HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE, 14, 15}, {HB_TAG ('u','n','i','c'), HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE, (hb_aat_layout_feature_setting_t) 14, (hb_aat_layout_feature_setting_t) 15},
{HB_TAG ('v','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_ALT_PROPORTIONAL_TEXT, 7}, {HB_TAG ('v','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_ALT_PROPORTIONAL_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('v','e','r','t'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION, HB_AAT_LAYOUT_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON, HB_AAT_LAYOUT_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF}, {HB_TAG ('v','e','r','t'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION, HB_AAT_LAYOUT_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON, HB_AAT_LAYOUT_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF},
{HB_TAG ('v','h','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_ALT_HALF_WIDTH_TEXT, 7}, {HB_TAG ('v','h','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_ALT_HALF_WIDTH_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('v','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA, HB_AAT_LAYOUT_SELECTOR_ALTERNATE_VERT_KANA_ON, HB_AAT_LAYOUT_SELECTOR_ALTERNATE_VERT_KANA_OFF}, {HB_TAG ('v','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA, HB_AAT_LAYOUT_SELECTOR_ALTERNATE_VERT_KANA_ON, HB_AAT_LAYOUT_SELECTOR_ALTERNATE_VERT_KANA_OFF},
{HB_TAG ('v','p','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_ALT_PROPORTIONAL_TEXT, 7}, {HB_TAG ('v','p','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_SELECTOR_ALT_PROPORTIONAL_TEXT, (hb_aat_layout_feature_setting_t) 7},
{HB_TAG ('v','r','t','2'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION, HB_AAT_LAYOUT_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON, HB_AAT_LAYOUT_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF}, {HB_TAG ('v','r','t','2'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION, HB_AAT_LAYOUT_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON, HB_AAT_LAYOUT_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF},
{HB_TAG ('z','e','r','o'), HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS, HB_AAT_LAYOUT_SELECTOR_SLASHED_ZERO_ON, HB_AAT_LAYOUT_SELECTOR_SLASHED_ZERO_OFF}, {HB_TAG ('z','e','r','o'), HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS, HB_AAT_LAYOUT_SELECTOR_SLASHED_ZERO_ON, HB_AAT_LAYOUT_SELECTOR_SLASHED_ZERO_OFF},
}; };
...@@ -301,37 +301,43 @@ _hb_aat_language_get (hb_face_t *face, ...@@ -301,37 +301,43 @@ _hb_aat_language_get (hb_face_t *face,
} }
/** /**
* hb_aat_layout_get_feature_settings: * hb_aat_layout_get_features:
* @face: a font face.
* @feature: AAT feature id you are querying.
* @default_setting: (out): default value for the type. If it is HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED
* means none is selected as default and the feature is not exclusive.
* @start_offset: start offset, if you are iterating
* @selectors_count: (inout): gets input buffer size, puts number of filled one
* @selectors_buffer: (out): buffer of records
*
* Returns: Total number of feature selector records available for the feature.
* *
* Since: REPLACEME * Since: REPLACEME
*/ */
unsigned int unsigned int
hb_aat_layout_get_feature_settings (hb_face_t *face, hb_aat_layout_get_features (hb_face_t *face,
hb_aat_layout_feature_type_t feature, unsigned int start_offset,
hb_aat_layout_feature_setting_t *default_setting, /* OUT. May be NULL. */ unsigned int *count, /* IN/OUT. May be NULL. */
unsigned int start_offset, hb_aat_layout_feature_type_t *features /* OUT. May be NULL. */)
unsigned int *selectors_count, /* IN/OUT. May be NULL. */
hb_aat_layout_feature_type_selector_t *selectors_buffer /* OUT. May be NULL. */)
{ {
return face->table.feat->get_settings (feature, default_setting, return face->table.feat->get_features (start_offset, count, features);
start_offset, selectors_count, selectors_buffer);
} }
hb_ot_name_id_t
hb_aat_layout_get_feature_name_id (hb_face_t *face,
hb_aat_layout_feature_type_t feature)
{ return HB_OT_NAME_ID_INVALID; }
/**
* hb_aat_layout_get_feature_settings:
*
* Since: REPLACEME
*/
unsigned int unsigned int
hb_aat_layout_get_features (hb_face_t *face, hb_aat_layout_get_feature_settings (hb_face_t *face,
unsigned int start_offset, hb_aat_layout_feature_type_t feature,
unsigned int *record_count, /* IN/OUT. May be NULL. */ hb_aat_layout_feature_setting_t *default_setting, /* OUT. May be NULL. */
hb_aat_layout_feature_record_t *record_buffer /* OUT. May be NULL. */) unsigned int start_offset,
unsigned int *count, /* IN/OUT. May be NULL. */
hb_aat_layout_feature_setting_t *settings /* OUT. May be NULL. */)
{ {
return face->table.feat->get_features (start_offset, record_count, record_buffer); return face->table.feat->get_settings (feature, default_setting,
start_offset, count, settings);
} }
hb_ot_name_id_t
hb_aat_layout_get_feature_setting_name_id (hb_face_t *face,
hb_aat_layout_feature_type_t feature,
hb_aat_layout_feature_setting_t setting)
{ return HB_OT_NAME_ID_INVALID; }
...@@ -38,7 +38,7 @@ void hb_aat_map_builder_t::add_feature (hb_tag_t tag, ...@@ -38,7 +38,7 @@ void hb_aat_map_builder_t::add_feature (hb_tag_t tag,
{ {
feature_info_t *info = features.push(); feature_info_t *info = features.push();
info->type = HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES; info->type = HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES;
info->setting = value; info->setting = (hb_aat_layout_feature_setting_t) value;
return; return;
} }
......
此差异已折叠。
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "hb-ot-name.h" #include "hb-ot-name.h"
#include "hb-ot-shape.h" #include "hb-ot-shape.h"
#include "hb-ot-var.h" #include "hb-ot-var.h"
#include "hb-aat.h"
HB_BEGIN_DECLS HB_BEGIN_DECLS
......
...@@ -36,65 +36,65 @@ static hb_face_t *sbix; ...@@ -36,65 +36,65 @@ static hb_face_t *sbix;
static void static void
test_aat_get_features (void) test_aat_get_features (void)
{ {
hb_aat_layout_feature_record_t records[3]; // hb_aat_layout_feature_record_t records[3];
unsigned int record_count = 3; // unsigned int record_count = 3;
g_assert_cmpuint (11, ==, hb_aat_layout_get_features (face, 0, &record_count, records)); // g_assert_cmpuint (11, ==, hb_aat_layout_get_features (face, 0, &record_count, records));
g_assert_cmpuint (1, ==, records[0].feature); // g_assert_cmpuint (1, ==, records[0].feature);
g_assert_cmpuint (258, ==, records[0].name_id); // g_assert_cmpuint (258, ==, records[0].name_id);
g_assert_cmpuint (3, ==, records[1].feature); // g_assert_cmpuint (3, ==, records[1].feature);
g_assert_cmpuint (261, ==, records[1].name_id); // g_assert_cmpuint (261, ==, records[1].name_id);
g_assert_cmpuint (6, ==, records[2].feature); // g_assert_cmpuint (6, ==, records[2].feature);
g_assert_cmpuint (265, ==, records[2].name_id); // g_assert_cmpuint (265, ==, records[2].name_id);
} }
static void static void
test_aat_get_feature_settings (void) test_aat_get_feature_settings (void)
{ {
hb_aat_layout_feature_setting_t default_setting; // hb_aat_layout_feature_setting_t default_setting;
hb_aat_layout_feature_type_selector_t records[3]; // hb_aat_layout_feature_type_selector_t records[3];
unsigned int count = 3; // unsigned int count = 3;
g_assert_cmpuint (4, ==, hb_aat_layout_get_feature_settings (face, (hb_aat_layout_feature_type_t) 18, // g_assert_cmpuint (4, ==, hb_aat_layout_get_feature_settings (face, (hb_aat_layout_feature_type_t) 18,
&default_setting, 0, &count, records)); // &default_setting, 0, &count, records));
g_assert_cmpuint (3, ==, count); // g_assert_cmpuint (3, ==, count);
g_assert_cmpuint (0, ==, default_setting); // g_assert_cmpuint (0, ==, default_setting);
g_assert_cmpuint (0, ==, records[0].setting); // g_assert_cmpuint (0, ==, records[0].setting);
g_assert_cmpuint (294, ==, records[0].name_id); // g_assert_cmpuint (294, ==, records[0].name_id);
g_assert_cmpuint (1, ==, records[1].setting); // g_assert_cmpuint (1, ==, records[1].setting);
g_assert_cmpuint (295, ==, records[1].name_id); // g_assert_cmpuint (295, ==, records[1].name_id);
g_assert_cmpuint (2, ==, records[2].setting); // g_assert_cmpuint (2, ==, records[2].setting);
g_assert_cmpuint (296, ==, records[2].name_id); // g_assert_cmpuint (296, ==, records[2].name_id);
count = 3; // count = 3;
g_assert_cmpuint (4, ==, hb_aat_layout_get_feature_settings (face, (hb_aat_layout_feature_type_t) 18, // g_assert_cmpuint (4, ==, hb_aat_layout_get_feature_settings (face, (hb_aat_layout_feature_type_t) 18,
&default_setting, 3, &count, records)); // &default_setting, 3, &count, records));
g_assert_cmpuint (1, ==, count); // g_assert_cmpuint (1, ==, count);
g_assert_cmpuint (0, ==, default_setting); // g_assert_cmpuint (0, ==, default_setting);
g_assert_cmpuint (3, ==, records[0].setting); // g_assert_cmpuint (3, ==, records[0].setting);
g_assert_cmpuint (297, ==, records[0].name_id); // g_assert_cmpuint (297, ==, records[0].name_id);
count = 1; // count = 1;
g_assert_cmpuint (1, ==, hb_aat_layout_get_feature_settings (face, HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS, // g_assert_cmpuint (1, ==, hb_aat_layout_get_feature_settings (face, HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS,
&default_setting, 0, &count, records)); // &default_setting, 0, &count, records));
g_assert_cmpuint (1, ==, count); // g_assert_cmpuint (1, ==, count);
g_assert_cmpuint (HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED, ==, default_setting); // g_assert_cmpuint (HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED, ==, default_setting);
g_assert_cmpuint (8, ==, records[0].setting); // g_assert_cmpuint (8, ==, records[0].setting);
g_assert_cmpuint (308, ==, records[0].name_id); // g_assert_cmpuint (308, ==, records[0].name_id);
count = 100; // count = 100;
g_assert_cmpuint (0, ==, hb_aat_layout_get_feature_settings (face, HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED, // g_assert_cmpuint (0, ==, hb_aat_layout_get_feature_settings (face, HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED,
NULL, 0, &count, records)); // NULL, 0, &count, records));
g_assert_cmpuint (0, ==, count); // g_assert_cmpuint (0, ==, count);
g_assert_cmpuint (0, ==, hb_aat_layout_get_feature_settings (sbix, HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED, NULL, // g_assert_cmpuint (0, ==, hb_aat_layout_get_feature_settings (sbix, HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED, NULL,
0, &count, records)); // 0, &count, records));
} }
int int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册