提交 7a0471aa 编写于 作者: E Ebrahim Byagowi 提交者: Behdad Esfahbod

[feat] Turn AAT feature id into enum

上级 b233fa4b
......@@ -60,7 +60,7 @@ struct FeatureName
=======
static int cmp (const void *key_, const void *entry_)
{
hb_aat_feature_type_t key = * (hb_aat_feature_type_t *) key_;
hb_aat_layout_feature_type_t key = * (hb_aat_layout_feature_type_t *) key_;
const FeatureName * entry = (const FeatureName *) entry_;
return key < entry->feature ? -1 :
key > entry->feature ? 1 :
......@@ -85,10 +85,10 @@ struct FeatureName
<<<<<<< HEAD
=======
inline unsigned int get_settings (const feat *feat,
hb_aat_feature_setting_t *default_setting,
hb_aat_layout_feature_setting_t *default_setting,
unsigned int start_offset,
unsigned int *selectors_count,
hb_aat_feature_type_selector_t *selectors_buffer) const
hb_aat_layout_feature_type_selector_t *selectors_buffer) const
{
bool exclusive = featureFlags & Exclusive;
bool not_default = featureFlags & NotDefault;
......@@ -109,7 +109,7 @@ struct FeatureName
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;
else *default_setting = HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED;
}
if (selectors_count) *selectors_count = len;
return settings_count;
......@@ -143,7 +143,7 @@ struct feat
{
static const hb_tag_t tableTag = HB_AAT_TAG_feat;
inline const FeatureName& get_feature (hb_aat_feature_type_t key) const
inline const FeatureName& get_feature (hb_aat_layout_feature_type_t key) const
{
const FeatureName* feature = (FeatureName*) hb_bsearch (&key, &names,
FeatureName::static_size,
......@@ -153,11 +153,11 @@ struct feat
return feature ? *feature : Null (FeatureName);
}
inline unsigned int get_settings (hb_aat_feature_type_t type,
hb_aat_feature_setting_t *default_setting, /* OUT. May be NULL. */
unsigned int start_offset,
unsigned int *selectors_count, /* IN/OUT. May be NULL. */
hb_aat_feature_type_selector_t *selectors_buffer /* OUT. May be NULL. */) const
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
{
return get_feature (type).get_settings (this, default_setting,
start_offset, selectors_count, selectors_buffer);
......
......@@ -958,19 +958,19 @@ struct Chain
for (unsigned i = 0; i < count; i++)
{
const Feature &feature = featureZ[i];
hb_aat_feature_type_t type = feature.featureType;
hb_aat_feature_setting_t setting = feature.featureSetting;
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;
retry:
const hb_aat_map_builder_t::feature_info_t *info = map->features.bsearch (type);
const hb_aat_map_builder_t::feature_info_t *info = map->features.bsearch ((uint16_t) type);
if (info && info->setting == setting)
{
flags &= feature.disableFlags;
flags |= feature.enableFlags;
}
else if (type == 3/*kLetterCaseType*/ && setting == 3/*kSmallCapsSelector*/)
else if (type == HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE && setting == 3/*kSmallCapsSelector*/)
{
/* Deprecated. https://github.com/harfbuzz/harfbuzz/issues/1342 */
type = 37/*kLowerCaseType*/;
type = HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE;
setting = 1/*kLowerCaseSmallCapsSelector*/;
goto retry;
}
......
此差异已折叠。
......@@ -36,9 +36,9 @@
struct hb_aat_feature_mapping_t
{
hb_tag_t otFeatureTag;
hb_aat_feature_type_t aatFeatureType;
hb_aat_feature_setting_t selectorToEnable;
hb_aat_feature_setting_t selectorToDisable;
hb_aat_layout_feature_type_t aatFeatureType;
hb_aat_layout_feature_setting_t selectorToEnable;
hb_aat_layout_feature_setting_t selectorToDisable;
static inline int cmp (const void *key_, const void *entry_)
{
......
......@@ -37,7 +37,7 @@ void hb_aat_map_builder_t::add_feature (hb_tag_t tag,
if (tag == HB_TAG ('a','a','l','t'))
{
feature_info_t *info = features.push();
info->type = 17/*kCharacterAlternativesType*/;
info->type = HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES;
info->setting = value;
return;
}
......
......@@ -66,8 +66,8 @@ struct hb_aat_map_builder_t
public:
struct feature_info_t
{
hb_aat_feature_type_t type;
hb_aat_feature_setting_t setting;
hb_aat_layout_feature_type_t type;
hb_aat_layout_feature_setting_t setting;
unsigned seq; /* For stable sorting only. */
static int cmp (const void *pa, const void *pb)
......
......@@ -22,10 +22,6 @@
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
#ifndef HB_OT_H_IN
#error "Include <hb-ot.h> instead."
#endif
#ifndef HB_AAT_H
#define HB_AAT_H
......@@ -34,14 +30,35 @@
HB_BEGIN_DECLS
/**
* hb_aat_type_t:
*
* Feature identifier
*
/*
* Since: REPLACEME
*/
typedef uint16_t hb_aat_feature_type_t;
typedef enum
{
HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES = 1,
HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE = 3,
HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION = 4,
HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING = 6,
HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION = 10,
HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS = 11,
HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS = 14,
HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES = 17,
HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS = 15,
HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS = 19,
HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE = 20,
HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE = 21,
HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING = 22,
HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION = 23,
HB_AAT_LAYOUT_FEATURE_TYPE_RUBYKANA = 28,
HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN = 32,
HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT = 33,
HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA = 34,
HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES = 35,
HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES = 36,
HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE = 37,
HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE = 38,
HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED = 0xFFFF
} hb_aat_layout_feature_type_t;
/**
* hb_aat_feature_t:
......@@ -50,33 +67,28 @@ typedef uint16_t hb_aat_feature_type_t;
*
* Since: REPLACEME
*/
typedef uint16_t hb_aat_feature_setting_t;
typedef unsigned int hb_aat_layout_feature_setting_t;
/**
* hb_aat_feature_type_selector_t:
* hb_aat_layout_feature_type_selector_t:
*
* Feature type record
*
* Since: REPLACEME
**/
typedef struct hb_aat_feature_type_selector_t
typedef struct hb_aat_layout_feature_type_selector_t
{
hb_aat_feature_setting_t setting;
hb_aat_layout_feature_setting_t setting;
hb_ot_name_id_t name_id;
} hb_aat_feature_type_selector_t;
/*
* Since: REPLACEME
*/
#define HB_AAT_FEATURE_NO_DEFAULT_SETTING ((hb_aat_feature_setting_t) -1)
} hb_aat_layout_feature_type_selector_t;
HB_EXTERN unsigned int
hb_aat_layout_get_feature_settings (hb_face_t *face,
hb_aat_feature_type_t type,
hb_aat_feature_setting_t *default_setting, /* OUT. May be NULL. */
unsigned int start_offset,
unsigned int *selectors_count, /* IN/OUT. May be NULL. */
hb_aat_feature_type_selector_t *selectors_buffer /* OUT. May be NULL. */);
hb_aat_layout_get_feature_settings (hb_face_t *face,
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. */);
HB_END_DECLS
......
......@@ -24,15 +24,17 @@
#include "hb-test.h"
#include <hb.h>
#include <hb-ot.h>
#include <hb-aat.h>
/* Unit tests for hb-aat.h */
static void
test_aat_get_feature_settings (void)
{
hb_aat_feature_setting_t default_setting;
hb_aat_feature_type_selector_t records[3];
hb_aat_layout_feature_setting_t default_setting;
hb_aat_layout_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 +67,7 @@ test_aat_get_feature_settings (void)
g_assert_cmpuint (1, ==, hb_aat_layout_get_feature_settings (face, 14, &default_setting,
0, &count, records));
g_assert_cmpuint (1, ==, count);
g_assert_cmpuint (HB_AAT_FEATURE_NO_DEFAULT_SETTING, ==, default_setting);
g_assert_cmpuint (HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED, ==, default_setting);
g_assert_cmpuint (8, ==, records[0].setting);
g_assert_cmpuint (308, ==, records[0].name_id);
......
......@@ -33,6 +33,7 @@
#include <hb.h>
#include <hb-ot.h>
#include <hb-aat.h>
#ifdef HAVE_GLIB
#include <hb-glib.h>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册