Skip to content

Commit d941f66

Browse files
committed
[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.
1 parent 40496a5 commit d941f66

File tree

7 files changed

+27
-30
lines changed

7 files changed

+27
-30
lines changed

docs/harfbuzz-docs.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,13 @@
7676
<xi:include href="xml/hb-set.xml"/>
7777

7878
<xi:include href="xml/hb-ot.xml"/>
79+
<xi:include href="xml/hb-ot-font.xml"/>
7980
<xi:include href="xml/hb-ot-layout.xml"/>
8081
<xi:include href="xml/hb-ot-tag.xml"/>
81-
<xi:include href="xml/hb-ot-font.xml"/>
82-
<xi:include href="xml/hb-ot-shape.xml"/>
82+
<xi:include href="xml/hb-ot-color.xml"/>
83+
<xi:include href="xml/hb-ot-name.xml"/>
8384
<xi:include href="xml/hb-ot-math.xml"/>
85+
<xi:include href="xml/hb-ot-shape.xml"/>
8486

8587
<xi:include href="xml/hb-shape-plan.xml"/>
8688

docs/harfbuzz-sections.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ HB_GOBJECT_TYPE_FONT_FUNCS
360360
HB_GOBJECT_TYPE_GLYPH_FLAGS
361361
HB_GOBJECT_TYPE_MAP
362362
HB_GOBJECT_TYPE_MEMORY_MODE
363+
HB_GOBJECT_TYPE_NAME_ID
363364
HB_GOBJECT_TYPE_OT_COLOR_PALETTE_FLAGS
364365
HB_GOBJECT_TYPE_OT_LAYOUT_GLYPH_CLASS
365366
HB_GOBJECT_TYPE_OT_MATH_CONSTANT
@@ -393,6 +394,7 @@ hb_gobject_font_get_type
393394
hb_gobject_glyph_flags_get_type
394395
hb_gobject_map_get_type
395396
hb_gobject_memory_mode_get_type
397+
hb_gobject_name_id_get_type
396398
hb_gobject_ot_color_palette_flags_get_type
397399
hb_gobject_ot_layout_glyph_class_get_type
398400
hb_gobject_ot_math_constant_get_type
@@ -489,7 +491,7 @@ hb_ot_font_set_funcs
489491
<SECTION>
490492
<FILE>hb-ot-name</FILE>
491493
hb_name_id_t
492-
HB_NAME_ID_INVALID
494+
hb_ot_name_entry_t
493495
hb_ot_name_list_names
494496
hb_ot_name_get_utf16
495497
hb_ot_name_get_utf32

src/hb-ot-color-cpal-table.hh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,22 @@ struct CPALV1Tail
5858
hb_array (base+paletteFlagsZ, palette_count)[palette_index];
5959
}
6060

61-
inline unsigned int
61+
inline hb_name_id_t
6262
get_palette_name_id (const void *base,
6363
unsigned int palette_index,
6464
unsigned int palette_count) const
6565
{
6666
if (!paletteLabelsZ) return HB_NAME_ID_INVALID;
67-
return hb_array (base+paletteLabelsZ, palette_count)[palette_index];
67+
return (hb_name_id_t) (unsigned) hb_array (base+paletteLabelsZ, palette_count)[palette_index];
6868
}
6969

70-
inline unsigned int
70+
inline hb_name_id_t
7171
get_color_name_id (const void *base,
7272
unsigned int color_index,
7373
unsigned int color_count) const
7474
{
7575
if (!colorLabelsZ) return HB_NAME_ID_INVALID;
76-
return hb_array (base+colorLabelsZ, color_count)[color_index];
76+
return (hb_name_id_t) (unsigned) hb_array (base+colorLabelsZ, color_count)[color_index];
7777
}
7878

7979
public:
@@ -123,10 +123,10 @@ struct CPAL
123123
inline hb_ot_color_palette_flags_t get_palette_flags (unsigned int palette_index) const
124124
{ return v1 ().get_palette_flags (this, palette_index, numPalettes); }
125125

126-
inline unsigned int get_palette_name_id (unsigned int palette_index) const
126+
inline hb_name_id_t get_palette_name_id (unsigned int palette_index) const
127127
{ return v1 ().get_palette_name_id (this, palette_index, numPalettes); }
128128

129-
inline unsigned int get_color_name_id (unsigned int color_index) const
129+
inline hb_name_id_t get_color_name_id (unsigned int color_index) const
130130
{ return v1 ().get_color_name_id (this, color_index, numColors); }
131131

132132
inline unsigned int get_palette_colors (unsigned int palette_index,

src/hb-ot-layout.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ hb_bool_t
10501050
hb_ot_layout_get_size_params (hb_face_t *face,
10511051
unsigned int *design_size, /* OUT. May be NULL */
10521052
unsigned int *subfamily_id, /* OUT. May be NULL */
1053-
unsigned int *subfamily_name_id, /* OUT. May be NULL */
1053+
hb_name_id_t *subfamily_name_id, /* OUT. May be NULL */
10541054
unsigned int *range_start, /* OUT. May be NULL */
10551055
unsigned int *range_end /* OUT. May be NULL */)
10561056
{
@@ -1069,7 +1069,7 @@ hb_ot_layout_get_size_params (hb_face_t *face,
10691069
{
10701070
if (design_size) *design_size = params.designSize;
10711071
if (subfamily_id) *subfamily_id = params.subfamilyID;
1072-
if (subfamily_name_id) *subfamily_name_id = params.subfamilyNameID;
1072+
if (subfamily_name_id) *subfamily_name_id = (hb_name_id_t) (unsigned) params.subfamilyNameID;
10731073
if (range_start) *range_start = params.rangeStart;
10741074
if (range_end) *range_end = params.rangeEnd;
10751075

@@ -1080,7 +1080,7 @@ hb_ot_layout_get_size_params (hb_face_t *face,
10801080

10811081
if (design_size) *design_size = 0;
10821082
if (subfamily_id) *subfamily_id = 0;
1083-
if (subfamily_name_id) *subfamily_name_id = 0;
1083+
if (subfamily_name_id) *subfamily_name_id = HB_NAME_ID_INVALID;
10841084
if (range_start) *range_start = 0;
10851085
if (range_end) *range_end = 0;
10861086

@@ -1133,7 +1133,7 @@ hb_ot_layout_feature_get_name_ids (hb_face_t *face,
11331133
feature_params.get_stylistic_set_params (feature_tag);
11341134
if (&ss_params != &Null (OT::FeatureParamsStylisticSet)) /* ssXX */
11351135
{
1136-
if (label_id) *label_id = ss_params.uiNameID;
1136+
if (label_id) *label_id = (hb_name_id_t) (unsigned) ss_params.uiNameID;
11371137
// ssXX features don't have the rest
11381138
if (tooltip_id) *tooltip_id = HB_NAME_ID_INVALID;
11391139
if (sample_id) *sample_id = HB_NAME_ID_INVALID;
@@ -1145,11 +1145,11 @@ hb_ot_layout_feature_get_name_ids (hb_face_t *face,
11451145
feature_params.get_character_variants_params (feature_tag);
11461146
if (&cv_params != &Null (OT::FeatureParamsCharacterVariants)) /* cvXX */
11471147
{
1148-
if (label_id) *label_id = cv_params.featUILableNameID;
1149-
if (tooltip_id) *tooltip_id = cv_params.featUITooltipTextNameID;
1150-
if (sample_id) *sample_id = cv_params.sampleTextNameID;
1148+
if (label_id) *label_id = (hb_name_id_t) (unsigned) cv_params.featUILableNameID;
1149+
if (tooltip_id) *tooltip_id = (hb_name_id_t) (unsigned) cv_params.featUITooltipTextNameID;
1150+
if (sample_id) *sample_id = (hb_name_id_t) (unsigned) cv_params.sampleTextNameID;
11511151
if (num_named_parameters) *num_named_parameters = cv_params.numNamedParameters;
1152-
if (first_param_id) *first_param_id = cv_params.firstParamUILabelNameID;
1152+
if (first_param_id) *first_param_id = (hb_name_id_t) (unsigned) cv_params.firstParamUILabelNameID;
11531153
return true;
11541154
}
11551155
}

src/hb-ot-name-table.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ struct name
194194
{
195195
hb_ot_name_entry_t *entry = this->names.push ();
196196

197-
entry->name_id = all_names[i].nameID;
197+
entry->name_id = (hb_name_id_t) (unsigned) all_names[i].nameID;
198198
entry->language = all_names[i].language (face);
199199
entry->entry_score = all_names[i].score ();
200200
entry->entry_index = i;

src/hb-ot-name.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,16 @@ HB_BEGIN_DECLS
3636

3737
/**
3838
* hb_name_id_t:
39+
* @HB_NAME_ID_INVALID: Value to represent a nonexistent name ID.
3940
*
4041
* An integral type representing an OpenType 'name' table name identifier.
4142
* There are predefined name IDs, as well as name IDs return from other
4243
* API. These can be used to fetch name strings from a font face.
4344
*
4445
* Since: 2.0.0
45-
*/
46-
typedef unsigned int hb_name_id_t;
47-
48-
/**
49-
* HB_NAME_ID_INVALID
50-
*
51-
* Value to represent a nonexistent name ID.
52-
*
53-
* Since: 2.0.0
5446
**/
55-
enum {
47+
typedef enum
48+
{
5649
HB_NAME_ID_COPYRIGHT = 0,
5750
HB_NAME_ID_FONT_FAMILY = 1,
5851
HB_NAME_ID_FONT_SUBFAMILY = 2,
@@ -81,7 +74,7 @@ enum {
8174
HB_NAME_ID_VARIATIONS_PS_PREFIX = 25,
8275

8376
HB_NAME_ID_INVALID = 0xFFFF
84-
};
77+
} hb_name_id_t ;
8578

8679

8780
/**

src/test-size-params.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ main (int argc, char **argv)
4646
blob = nullptr;
4747

4848
unsigned int p[5];
49-
bool ret = hb_ot_layout_get_size_params (face, p, p+1, p+2, p+3, p+4);
49+
bool ret = hb_ot_layout_get_size_params (face, p, p+1, (hb_name_id_t *) (p+2), p+3, p+4);
5050

5151
printf ("%g %u %u %g %g\n", p[0]/10., p[1], p[2], p[3]/10., p[4]/10.);
5252

0 commit comments

Comments
 (0)