Add hb_face_get_table_tags()
New API: hb_face_get_table_tags() Fixes https://github.com/behdad/harfbuzz/issues/560
This commit is contained in:
parent
e1b6d92302
commit
94b3cafc3a
|
@ -474,4 +474,33 @@ hb_face_t::load_num_glyphs (void) const
|
||||||
hb_blob_destroy (maxp_blob);
|
hb_blob_destroy (maxp_blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hb_face_get_table_tags:
|
||||||
|
* @face: a face.
|
||||||
|
*
|
||||||
|
* Retrieves table tags for a face, if possible.
|
||||||
|
*
|
||||||
|
* Return value: total number of tables, or 0 if not possible to list.
|
||||||
|
*
|
||||||
|
* Since: 1.6.0
|
||||||
|
**/
|
||||||
|
unsigned int
|
||||||
|
hb_face_get_table_tags (hb_face_t *face,
|
||||||
|
unsigned int start_offset,
|
||||||
|
unsigned int *table_count, /* IN/OUT */
|
||||||
|
hb_tag_t *table_tags /* OUT */)
|
||||||
|
{
|
||||||
|
if (face->destroy != _hb_face_for_data_closure_destroy)
|
||||||
|
{
|
||||||
|
if (table_count)
|
||||||
|
*table_count = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hb_face_for_data_closure_t *data = (hb_face_for_data_closure_t *) face->user_data;
|
||||||
|
|
||||||
|
const OT::OpenTypeFontFile &ot_file = *OT::Sanitizer<OT::OpenTypeFontFile>::lock_instance (data->blob);
|
||||||
|
const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index);
|
||||||
|
|
||||||
|
return ot_face.get_table_tags (start_offset, table_count, table_tags);
|
||||||
|
}
|
||||||
|
|
|
@ -111,6 +111,11 @@ hb_face_set_glyph_count (hb_face_t *face,
|
||||||
HB_EXTERN unsigned int
|
HB_EXTERN unsigned int
|
||||||
hb_face_get_glyph_count (hb_face_t *face);
|
hb_face_get_glyph_count (hb_face_t *face);
|
||||||
|
|
||||||
|
HB_EXTERN unsigned int
|
||||||
|
hb_face_get_table_tags (hb_face_t *face,
|
||||||
|
unsigned int start_offset,
|
||||||
|
unsigned int *table_count, /* IN/OUT */
|
||||||
|
hb_tag_t *table_tags /* OUT */);
|
||||||
|
|
||||||
HB_END_DECLS
|
HB_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,24 @@ typedef struct OffsetTable
|
||||||
if (unlikely (i >= numTables)) return Null(TableRecord);
|
if (unlikely (i >= numTables)) return Null(TableRecord);
|
||||||
return tables[i];
|
return tables[i];
|
||||||
}
|
}
|
||||||
|
inline unsigned int get_table_tags (unsigned int start_offset,
|
||||||
|
unsigned int *table_count, /* IN/OUT */
|
||||||
|
hb_tag_t *table_tags /* OUT */) const
|
||||||
|
{
|
||||||
|
if (table_count)
|
||||||
|
{
|
||||||
|
if (start_offset >= numTables)
|
||||||
|
*table_count = 0;
|
||||||
|
else
|
||||||
|
*table_count = MIN (*table_count, numTables - start_offset);
|
||||||
|
|
||||||
|
const TableRecord *sub_tables = tables + start_offset;
|
||||||
|
unsigned int count = *table_count;
|
||||||
|
for (unsigned int i = 0; i < count; i++)
|
||||||
|
table_tags[i] = sub_tables[i].tag;
|
||||||
|
}
|
||||||
|
return numTables;
|
||||||
|
}
|
||||||
inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const
|
inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const
|
||||||
{
|
{
|
||||||
Tag t;
|
Tag t;
|
||||||
|
|
Loading…
Reference in New Issue