diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2018-10-15 23:00:27 -0700 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2018-10-15 23:00:27 -0700 |
commit | 7742644191752b6599837ca2e5009e5d89978747 (patch) | |
tree | 4448dff7144a9efa0ad893fcab9f7f1ddd84ef63 | |
parent | d48cbd70176125fe8f904a7bb0f3efadb3e1fbbb (diff) |
[name] Implement hb_bytes_t get_name()
-rw-r--r-- | src/hb-ot-name-table.hh | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh index 5625ab2c..37a2d42f 100644 --- a/src/hb-ot-name-table.hh +++ b/src/hb-ot-name-table.hh @@ -131,26 +131,11 @@ struct name { static const hb_tag_t tableTag = HB_OT_TAG_name; - inline unsigned int get_name (unsigned int platform_id, - unsigned int encoding_id, - unsigned int language_id, - unsigned int name_id, - void *buffer, - unsigned int buffer_length) const + inline hb_bytes_t get_name (unsigned int idx) const { - NameRecord key; - key.platformID.set (platform_id); - key.encodingID.set (encoding_id); - key.languageID.set (language_id); - key.nameID.set (name_id); - NameRecord *match = (NameRecord *) bsearch (&key, nameRecordZ.arrayZ, count, sizeof (nameRecordZ[0]), NameRecord::cmp); - - if (!match) - return 0; - - unsigned int length = MIN (buffer_length, (unsigned int) match->length); - memcpy (buffer, (char *) this + stringOffset + match->offset, length); - return length; + const hb_array_t<NameRecord> &all_names = hb_array_t<NameRecord> (nameRecordZ.arrayZ, count); + const NameRecord &record = all_names[idx]; + return hb_bytes_t ((char *) this + stringOffset + record.offset, record.length); } inline unsigned int get_size (void) const @@ -160,6 +145,7 @@ struct name TRACE_SANITIZE (this); char *string_pool = (char *) this + stringOffset; unsigned int _count = count; + /* Move to run-time?! */ for (unsigned int i = 0; i < _count; i++) if (!nameRecordZ[i].sanitize (c, string_pool)) return_trace (false); return_trace (true); |