[name] Make hb_name_id_t be the enum

This is like hb_script_t.

We had this exposed as unsigned int since 2.0.0 release in two APIs,
as well as hb_ot_layout_get_size_params() from earlier.
But since no one uses those (right?!), let's just fix this now.
This commit is contained in:
Behdad Esfahbod 2018-10-27 02:55:52 -07:00
parent 40496a54a0
commit d941f66c75
7 changed files with 27 additions and 30 deletions

View File

@ -76,11 +76,13 @@
<xi:include href="xml/hb-set.xml"/>
<xi:include href="xml/hb-ot.xml"/>
<xi:include href="xml/hb-ot-font.xml"/>
<xi:include href="xml/hb-ot-layout.xml"/>
<xi:include href="xml/hb-ot-tag.xml"/>
<xi:include href="xml/hb-ot-font.xml"/>
<xi:include href="xml/hb-ot-shape.xml"/>
<xi:include href="xml/hb-ot-color.xml"/>
<xi:include href="xml/hb-ot-name.xml"/>
<xi:include href="xml/hb-ot-math.xml"/>
<xi:include href="xml/hb-ot-shape.xml"/>
<xi:include href="xml/hb-shape-plan.xml"/>

View File

@ -360,6 +360,7 @@ HB_GOBJECT_TYPE_FONT_FUNCS
HB_GOBJECT_TYPE_GLYPH_FLAGS
HB_GOBJECT_TYPE_MAP
HB_GOBJECT_TYPE_MEMORY_MODE
HB_GOBJECT_TYPE_NAME_ID
HB_GOBJECT_TYPE_OT_COLOR_PALETTE_FLAGS
HB_GOBJECT_TYPE_OT_LAYOUT_GLYPH_CLASS
HB_GOBJECT_TYPE_OT_MATH_CONSTANT
@ -393,6 +394,7 @@ hb_gobject_font_get_type
hb_gobject_glyph_flags_get_type
hb_gobject_map_get_type
hb_gobject_memory_mode_get_type
hb_gobject_name_id_get_type
hb_gobject_ot_color_palette_flags_get_type
hb_gobject_ot_layout_glyph_class_get_type
hb_gobject_ot_math_constant_get_type
@ -489,7 +491,7 @@ hb_ot_font_set_funcs
<SECTION>
<FILE>hb-ot-name</FILE>
hb_name_id_t
HB_NAME_ID_INVALID
hb_ot_name_entry_t
hb_ot_name_list_names
hb_ot_name_get_utf16
hb_ot_name_get_utf32

View File

@ -58,22 +58,22 @@ struct CPALV1Tail
hb_array (base+paletteFlagsZ, palette_count)[palette_index];
}
inline unsigned int
inline hb_name_id_t
get_palette_name_id (const void *base,
unsigned int palette_index,
unsigned int palette_count) const
{
if (!paletteLabelsZ) return HB_NAME_ID_INVALID;
return hb_array (base+paletteLabelsZ, palette_count)[palette_index];
return (hb_name_id_t) (unsigned) hb_array (base+paletteLabelsZ, palette_count)[palette_index];
}
inline unsigned int
inline hb_name_id_t
get_color_name_id (const void *base,
unsigned int color_index,
unsigned int color_count) const
{
if (!colorLabelsZ) return HB_NAME_ID_INVALID;
return hb_array (base+colorLabelsZ, color_count)[color_index];
return (hb_name_id_t) (unsigned) hb_array (base+colorLabelsZ, color_count)[color_index];
}
public:
@ -123,10 +123,10 @@ struct CPAL
inline hb_ot_color_palette_flags_t get_palette_flags (unsigned int palette_index) const
{ return v1 ().get_palette_flags (this, palette_index, numPalettes); }
inline unsigned int get_palette_name_id (unsigned int palette_index) const
inline hb_name_id_t get_palette_name_id (unsigned int palette_index) const
{ return v1 ().get_palette_name_id (this, palette_index, numPalettes); }
inline unsigned int get_color_name_id (unsigned int color_index) const
inline hb_name_id_t get_color_name_id (unsigned int color_index) const
{ return v1 ().get_color_name_id (this, color_index, numColors); }
inline unsigned int get_palette_colors (unsigned int palette_index,

View File

@ -1050,7 +1050,7 @@ hb_bool_t
hb_ot_layout_get_size_params (hb_face_t *face,
unsigned int *design_size, /* OUT. May be NULL */
unsigned int *subfamily_id, /* OUT. May be NULL */
unsigned int *subfamily_name_id, /* OUT. May be NULL */
hb_name_id_t *subfamily_name_id, /* OUT. May be NULL */
unsigned int *range_start, /* OUT. May be NULL */
unsigned int *range_end /* OUT. May be NULL */)
{
@ -1069,7 +1069,7 @@ hb_ot_layout_get_size_params (hb_face_t *face,
{
if (design_size) *design_size = params.designSize;
if (subfamily_id) *subfamily_id = params.subfamilyID;
if (subfamily_name_id) *subfamily_name_id = params.subfamilyNameID;
if (subfamily_name_id) *subfamily_name_id = (hb_name_id_t) (unsigned) params.subfamilyNameID;
if (range_start) *range_start = params.rangeStart;
if (range_end) *range_end = params.rangeEnd;
@ -1080,7 +1080,7 @@ hb_ot_layout_get_size_params (hb_face_t *face,
if (design_size) *design_size = 0;
if (subfamily_id) *subfamily_id = 0;
if (subfamily_name_id) *subfamily_name_id = 0;
if (subfamily_name_id) *subfamily_name_id = HB_NAME_ID_INVALID;
if (range_start) *range_start = 0;
if (range_end) *range_end = 0;
@ -1133,7 +1133,7 @@ hb_ot_layout_feature_get_name_ids (hb_face_t *face,
feature_params.get_stylistic_set_params (feature_tag);
if (&ss_params != &Null (OT::FeatureParamsStylisticSet)) /* ssXX */
{
if (label_id) *label_id = ss_params.uiNameID;
if (label_id) *label_id = (hb_name_id_t) (unsigned) ss_params.uiNameID;
// ssXX features don't have the rest
if (tooltip_id) *tooltip_id = HB_NAME_ID_INVALID;
if (sample_id) *sample_id = HB_NAME_ID_INVALID;
@ -1145,11 +1145,11 @@ hb_ot_layout_feature_get_name_ids (hb_face_t *face,
feature_params.get_character_variants_params (feature_tag);
if (&cv_params != &Null (OT::FeatureParamsCharacterVariants)) /* cvXX */
{
if (label_id) *label_id = cv_params.featUILableNameID;
if (tooltip_id) *tooltip_id = cv_params.featUITooltipTextNameID;
if (sample_id) *sample_id = cv_params.sampleTextNameID;
if (label_id) *label_id = (hb_name_id_t) (unsigned) cv_params.featUILableNameID;
if (tooltip_id) *tooltip_id = (hb_name_id_t) (unsigned) cv_params.featUITooltipTextNameID;
if (sample_id) *sample_id = (hb_name_id_t) (unsigned) cv_params.sampleTextNameID;
if (num_named_parameters) *num_named_parameters = cv_params.numNamedParameters;
if (first_param_id) *first_param_id = cv_params.firstParamUILabelNameID;
if (first_param_id) *first_param_id = (hb_name_id_t) (unsigned) cv_params.firstParamUILabelNameID;
return true;
}
}

View File

@ -194,7 +194,7 @@ struct name
{
hb_ot_name_entry_t *entry = this->names.push ();
entry->name_id = all_names[i].nameID;
entry->name_id = (hb_name_id_t) (unsigned) all_names[i].nameID;
entry->language = all_names[i].language (face);
entry->entry_score = all_names[i].score ();
entry->entry_index = i;

View File

@ -36,23 +36,16 @@ HB_BEGIN_DECLS
/**
* hb_name_id_t:
* @HB_NAME_ID_INVALID: Value to represent a nonexistent name ID.
*
* An integral type representing an OpenType 'name' table name identifier.
* There are predefined name IDs, as well as name IDs return from other
* API. These can be used to fetch name strings from a font face.
*
* Since: 2.0.0
*/
typedef unsigned int hb_name_id_t;
/**
* HB_NAME_ID_INVALID
*
* Value to represent a nonexistent name ID.
*
* Since: 2.0.0
**/
enum {
typedef enum
{
HB_NAME_ID_COPYRIGHT = 0,
HB_NAME_ID_FONT_FAMILY = 1,
HB_NAME_ID_FONT_SUBFAMILY = 2,
@ -81,7 +74,7 @@ enum {
HB_NAME_ID_VARIATIONS_PS_PREFIX = 25,
HB_NAME_ID_INVALID = 0xFFFF
};
} hb_name_id_t ;
/**

View File

@ -46,7 +46,7 @@ main (int argc, char **argv)
blob = nullptr;
unsigned int p[5];
bool ret = hb_ot_layout_get_size_params (face, p, p+1, p+2, p+3, p+4);
bool ret = hb_ot_layout_get_size_params (face, p, p+1, (hb_name_id_t *) (p+2), p+3, p+4);
printf ("%g %u %u %g %g\n", p[0]/10., p[1], p[2], p[3]/10., p[4]/10.);