Make string-array return hb_string_t
This commit is contained in:
parent
e1a37f3db4
commit
6c738f353e
|
@ -117,7 +117,7 @@ struct post
|
|||
if (glyph >= NUM_FORMAT1_NAMES)
|
||||
return hb_string_t ();
|
||||
|
||||
return hb_string_t (format1_names (glyph), strlen (format1_names (glyph)));
|
||||
return format1_names (glyph);
|
||||
}
|
||||
|
||||
if (version != 0x00020000 || glyph >= glyphNameIndex->len)
|
||||
|
@ -125,7 +125,7 @@ struct post
|
|||
|
||||
unsigned int index = glyphNameIndex->array[glyph];
|
||||
if (index < NUM_FORMAT1_NAMES)
|
||||
return hb_string_t (format1_names (index), strlen (format1_names (index)));
|
||||
return format1_names (index);
|
||||
index -= NUM_FORMAT1_NAMES;
|
||||
|
||||
if (index >= index_to_offset.len)
|
||||
|
@ -163,19 +163,6 @@ struct post
|
|||
if (unlikely (!len))
|
||||
return false;
|
||||
|
||||
if (version == 0x00010000)
|
||||
{
|
||||
for (int i = 0; i < NUM_FORMAT1_NAMES; i++)
|
||||
{
|
||||
if (strncmp (name, format1_names (i), len) == 0 && format1_names (i)[len] == '\0')
|
||||
{
|
||||
*glyph = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* TODO format2 */
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
|
||||
static const union HB_STRING_ARRAY_TYPE_NAME {
|
||||
struct {
|
||||
/* I like to avoid storing the nul-termination byte since we don't need it,
|
||||
* but C++ does not allow that.
|
||||
* https://stackoverflow.com/questions/28433862/why-initializer-string-for-array-of-chars-is-too-long-compiles-fine-in-c-not
|
||||
*/
|
||||
#define _S(s) char HB_PASTE (str, __LINE__)[sizeof (s)];
|
||||
#include HB_STRING_ARRAY_LIST
|
||||
#undef _S
|
||||
|
@ -59,12 +63,15 @@ static const unsigned int HB_STRING_ARRAY_OFFS_NAME[] =
|
|||
#define _S(s) offsetof (union HB_STRING_ARRAY_TYPE_NAME, st.HB_PASTE(str, __LINE__)),
|
||||
#include HB_STRING_ARRAY_LIST
|
||||
#undef _S
|
||||
sizeof (HB_STRING_ARRAY_TYPE_NAME)
|
||||
};
|
||||
|
||||
static inline const char *
|
||||
static inline hb_string_t
|
||||
HB_STRING_ARRAY_NAME (unsigned int i)
|
||||
{
|
||||
return HB_STRING_ARRAY_POOL_NAME.str + HB_STRING_ARRAY_OFFS_NAME[i];
|
||||
assert (i < ARRAY_LENGTH (HB_STRING_ARRAY_OFFS_NAME) - 1);
|
||||
return hb_string_t (HB_STRING_ARRAY_POOL_NAME.str + HB_STRING_ARRAY_OFFS_NAME[i],
|
||||
HB_STRING_ARRAY_OFFS_NAME[i + 1] - HB_STRING_ARRAY_OFFS_NAME[i] - 1);
|
||||
}
|
||||
|
||||
#undef HB_STRING_ARRAY_TYPE_NAME
|
||||
|
|
Loading…
Reference in New Issue