[name] Implement hb_bytes_t get_name()
This commit is contained in:
parent
c3425f2401
commit
740cde8991
@ -131,26 +131,11 @@ struct name
|
|||||||
{
|
{
|
||||||
static const hb_tag_t tableTag = HB_OT_TAG_name;
|
static const hb_tag_t tableTag = HB_OT_TAG_name;
|
||||||
|
|
||||||
inline unsigned int get_name (unsigned int platform_id,
|
inline hb_bytes_t get_name (unsigned int idx) const
|
||||||
unsigned int encoding_id,
|
|
||||||
unsigned int language_id,
|
|
||||||
unsigned int name_id,
|
|
||||||
void *buffer,
|
|
||||||
unsigned int buffer_length) const
|
|
||||||
{
|
{
|
||||||
NameRecord key;
|
const hb_array_t<NameRecord> &all_names = hb_array_t<NameRecord> (nameRecordZ.arrayZ, count);
|
||||||
key.platformID.set (platform_id);
|
const NameRecord &record = all_names[idx];
|
||||||
key.encodingID.set (encoding_id);
|
return hb_bytes_t ((char *) this + stringOffset + record.offset, record.length);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int get_size (void) const
|
inline unsigned int get_size (void) const
|
||||||
@ -160,6 +145,7 @@ struct name
|
|||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
char *string_pool = (char *) this + stringOffset;
|
char *string_pool = (char *) this + stringOffset;
|
||||||
unsigned int _count = count;
|
unsigned int _count = count;
|
||||||
|
/* Move to run-time?! */
|
||||||
for (unsigned int i = 0; i < _count; i++)
|
for (unsigned int i = 0; i < _count; i++)
|
||||||
if (!nameRecordZ[i].sanitize (c, string_pool)) return_trace (false);
|
if (!nameRecordZ[i].sanitize (c, string_pool)) return_trace (false);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
|
Loading…
Reference in New Issue
Block a user