From 3aff3f822f0d7bf7a2b5160ad93df3fe413c7c47 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Thu, 1 Nov 2018 19:20:20 +0330 Subject: [PATCH] [feat] Apply @drott and @jfkthame comments --- src/hb-aat-layout-feat-table.hh | 14 ++++++-------- src/hb-aat-layout.cc | 12 +++++++----- src/hb-aat-layout.h | 10 +++++----- test/api/test-aat-layout.c | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/hb-aat-layout-feat-table.hh b/src/hb-aat-layout-feat-table.hh index f151d7146..37c35af71 100644 --- a/src/hb-aat-layout-feat-table.hh +++ b/src/hb-aat-layout-feat-table.hh @@ -87,7 +87,7 @@ struct FeatureName hb_aat_feature_setting_t *default_setting, unsigned int start_offset, unsigned int *records_count, - hb_aat_feature_option_record_t *records_buffer) const + hb_aat_feature_type_selector_t *records_buffer) const { bool exclusive = featureFlags & Exclusive; bool not_default = featureFlags & NotDefault; @@ -105,12 +105,10 @@ struct FeatureName } if (default_setting) { - if (exclusive) - { - if (settings_count && !not_default) *default_setting = settings[0].setting; - else if (not_default) *default_setting = featureFlags & IndexMask; - } - else *default_setting = HB_AAT_FEATURE_NO_DEFAULT_INDEX; + unsigned int index = not_default ? featureFlags & IndexMask : 0; + if (exclusive && index < settings_count) + *default_setting = settings[index].setting; + else *default_setting = HB_AAT_FEATURE_NO_DEFAULT_SETTING; } if (records_count) *records_count = len; return settings_count; @@ -158,7 +156,7 @@ struct feat hb_aat_feature_setting_t *default_setting, /* OUT. May be NULL. */ unsigned int start_offset, unsigned int *records_count, /* IN/OUT. May be NULL. */ - hb_aat_feature_option_record_t *records_buffer) const + hb_aat_feature_type_selector_t *records_buffer) const { return get_feature (type).get_settings (this, default_setting, start_offset, records_count, records_buffer); diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index d9c336b7d..5b72e2d6e 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -309,14 +309,16 @@ _hb_aat_language_get (hb_face_t *face, /** * hb_aat_get_feature_settings: * @face: a font face. - * @identifier: aat feature id you are querying. - * @default_setting: (out): default value for the type. If it is HB_AAT_FEATURE_NO_DEFAULT_INDEX - * means non is default and it is not exclusive also. + * @identifier: AAT feature id you are querying, for example 1 for + * "Ligatures" feature, 37 for the "Lower Case" feature, + * 38 for the "Upper Case" feature, etc. + * @default_setting: (out): default value for the type. If it is HB_AAT_FEATURE_NO_DEFAULT_SETTING + * means none is selected as default and the feature is not exclusive. * @start_offset: start offset, if you are iterating * @records_count: (inout): gets input buffer size, puts number of filled one * @records_buffer: (out): buffer of records * - * Returns: Total number of records available for the feature. + * Returns: Total number of feature selector records available for the feature. * * Since: REPLACEME */ @@ -326,7 +328,7 @@ hb_aat_get_feature_settings (hb_face_t *face, hb_aat_feature_setting_t *default_setting, /* OUT. May be NULL. */ unsigned int start_offset, unsigned int *records_count, /* IN/OUT. May be NULL. */ - hb_aat_feature_option_record_t *records_buffer /* OUT. May be NULL. */) + hb_aat_feature_type_selector_t *records_buffer /* OUT. May be NULL. */) { return _get_feat (face).get_settings (identifier, default_setting, start_offset, records_count, records_buffer); diff --git a/src/hb-aat-layout.h b/src/hb-aat-layout.h index 1ca9af728..83517e584 100644 --- a/src/hb-aat-layout.h +++ b/src/hb-aat-layout.h @@ -49,22 +49,22 @@ typedef uint16_t hb_aat_feature_type_t; typedef uint16_t hb_aat_feature_setting_t; /** - * hb_aat_feature_option_record_t: + * hb_aat_feature_type_selector_t: * * Feature type record * * Since: REPLACEME **/ -typedef struct hb_aat_feature_option_record_t +typedef struct hb_aat_feature_type_selector_t { hb_aat_feature_setting_t setting; hb_ot_name_id_t name_id; -} hb_aat_feature_option_record_t; +} hb_aat_feature_type_selector_t; /* * Since: REPLACEME */ -#define HB_AAT_FEATURE_NO_DEFAULT_INDEX ((hb_aat_feature_setting_t) -1) +#define HB_AAT_FEATURE_NO_DEFAULT_SETTING ((hb_aat_feature_setting_t) -1) HB_EXTERN unsigned int hb_aat_get_feature_settings (hb_face_t *face, @@ -72,7 +72,7 @@ hb_aat_get_feature_settings (hb_face_t *face, hb_aat_feature_setting_t *default_setting, /* OUT. May be NULL. */ unsigned int start_offset, unsigned int *records_count, /* IN/OUT. May be NULL. */ - hb_aat_feature_option_record_t *records_buffer /* OUT. May be NULL. */); + hb_aat_feature_type_selector_t *records_buffer /* OUT. May be NULL. */); HB_END_DECLS diff --git a/test/api/test-aat-layout.c b/test/api/test-aat-layout.c index e6af36562..1d6b775fb 100644 --- a/test/api/test-aat-layout.c +++ b/test/api/test-aat-layout.c @@ -32,7 +32,7 @@ static void test_aat_get_feature_settings (void) { hb_aat_feature_setting_t default_setting; - hb_aat_feature_option_record_t records[3]; + hb_aat_feature_type_selector_t records[3]; unsigned int count = 3; hb_face_t *face = hb_test_open_font_file ("fonts/aat-feat.ttf"); @@ -65,7 +65,7 @@ test_aat_get_feature_settings (void) g_assert_cmpuint (1, ==, hb_aat_get_feature_settings (face, 14, &default_setting, 0, &count, records)); g_assert_cmpuint (1, ==, count); - g_assert_cmpuint (HB_AAT_FEATURE_NO_DEFAULT_INDEX, ==, default_setting); + g_assert_cmpuint (HB_AAT_FEATURE_NO_DEFAULT_SETTING, ==, default_setting); g_assert_cmpuint (8, ==, records[0].setting); g_assert_cmpuint (308, ==, records[0].name_id);