[cmap] Simplify collect_unicodes()
Don't use accelerator (almost). Hooks up Format13 as well.
This commit is contained in:
parent
d60c465627
commit
bd0e542525
|
@ -283,17 +283,6 @@ struct CmapSubtableFormat4
|
||||||
return *glyph != 0;
|
return *glyph != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void collect_unicodes_func (const void *obj, hb_set_t *out)
|
|
||||||
{
|
|
||||||
const accelerator_t *thiz = (const accelerator_t *) obj;
|
|
||||||
for (unsigned int i = 0; i < thiz->segCount; i++)
|
|
||||||
{
|
|
||||||
if (thiz->startCount[i] != 0xFFFFu
|
|
||||||
|| thiz->endCount[i] != 0xFFFFu) // Skip the last segment (0xFFFF)
|
|
||||||
hb_set_add_range (out, thiz->startCount[i], thiz->endCount[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const HBUINT16 *endCount;
|
const HBUINT16 *endCount;
|
||||||
const HBUINT16 *startCount;
|
const HBUINT16 *startCount;
|
||||||
const HBUINT16 *idDelta;
|
const HBUINT16 *idDelta;
|
||||||
|
@ -309,6 +298,18 @@ struct CmapSubtableFormat4
|
||||||
accel.init (this);
|
accel.init (this);
|
||||||
return accel.get_glyph_func (&accel, codepoint, glyph);
|
return accel.get_glyph_func (&accel, codepoint, glyph);
|
||||||
}
|
}
|
||||||
|
inline void collect_unicodes (hb_set_t *out) const
|
||||||
|
{
|
||||||
|
unsigned int segCount = this->segCountX2 / 2;
|
||||||
|
const HBUINT16 *endCount = this->values;
|
||||||
|
const HBUINT16 *startCount = endCount + segCount + 1;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < segCount; i++)
|
||||||
|
{
|
||||||
|
if (startCount[i] != 0xFFFFu || endCount[i] != 0xFFFFu) // Skip the last segment (0xFFFF)
|
||||||
|
hb_set_add_range (out, startCount[i], endCount[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
|
@ -690,6 +691,19 @@ struct CmapSubtable
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
inline void collect_unicodes (hb_set_t *out) const
|
||||||
|
{
|
||||||
|
switch (u.format) {
|
||||||
|
// case 0: u.format0 .collect_unicodes (out); return;
|
||||||
|
case 4: u.format4 .collect_unicodes (out); return;
|
||||||
|
// case 6: u.format6 .collect_unicodes (out); return;
|
||||||
|
// case 10: u.format10.collect_unicodes (out); return;
|
||||||
|
case 12: u.format12.collect_unicodes (out); return;
|
||||||
|
case 13: u.format13.collect_unicodes (out); return;
|
||||||
|
case 14:
|
||||||
|
default: return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
|
@ -901,9 +915,10 @@ struct cmap
|
||||||
{
|
{
|
||||||
this->blob = hb_sanitize_context_t().reference_table<cmap> (face);
|
this->blob = hb_sanitize_context_t().reference_table<cmap> (face);
|
||||||
const cmap *table = this->blob->as<cmap> ();
|
const cmap *table = this->blob->as<cmap> ();
|
||||||
const CmapSubtable *subtable = nullptr;
|
|
||||||
const CmapSubtableFormat14 *subtable_uvs = nullptr;
|
const CmapSubtableFormat14 *subtable_uvs = nullptr;
|
||||||
|
|
||||||
|
subtable = nullptr;
|
||||||
|
|
||||||
bool symbol = false;
|
bool symbol = false;
|
||||||
/* 32-bit subtables. */
|
/* 32-bit subtables. */
|
||||||
if (!subtable) subtable = table->find_subtable (3, 10);
|
if (!subtable) subtable = table->find_subtable (3, 10);
|
||||||
|
@ -939,24 +954,20 @@ struct cmap
|
||||||
if (unlikely (symbol))
|
if (unlikely (symbol))
|
||||||
{
|
{
|
||||||
this->get_glyph_func = get_glyph_from_symbol<CmapSubtable>;
|
this->get_glyph_func = get_glyph_from_symbol<CmapSubtable>;
|
||||||
this->collect_unicodes_func = collect_unicodes_func_nil;
|
|
||||||
} else {
|
} else {
|
||||||
switch (subtable->u.format) {
|
switch (subtable->u.format) {
|
||||||
/* Accelerate format 4 and format 12. */
|
/* Accelerate format 4 and format 12. */
|
||||||
default:
|
default:
|
||||||
this->get_glyph_func = get_glyph_from<CmapSubtable>;
|
this->get_glyph_func = get_glyph_from<CmapSubtable>;
|
||||||
this->collect_unicodes_func = collect_unicodes_func_nil;
|
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
this->get_glyph_func = get_glyph_from<CmapSubtableFormat12>;
|
this->get_glyph_func = get_glyph_from<CmapSubtableFormat12>;
|
||||||
this->collect_unicodes_func = collect_unicodes_from<CmapSubtableFormat12>;
|
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
this->format4_accel.init (&subtable->u.format4);
|
this->format4_accel.init (&subtable->u.format4);
|
||||||
this->get_glyph_data = &this->format4_accel;
|
this->get_glyph_data = &this->format4_accel;
|
||||||
this->get_glyph_func = this->format4_accel.get_glyph_func;
|
this->get_glyph_func = this->format4_accel.get_glyph_func;
|
||||||
this->collect_unicodes_func = this->format4_accel.collect_unicodes_func;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -992,7 +1003,7 @@ struct cmap
|
||||||
|
|
||||||
inline void collect_unicodes (hb_set_t *out) const
|
inline void collect_unicodes (hb_set_t *out) const
|
||||||
{
|
{
|
||||||
this->collect_unicodes_func (get_glyph_data, out);
|
subtable->collect_unicodes (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -1002,11 +1013,6 @@ struct cmap
|
||||||
typedef void (*hb_cmap_collect_unicodes_func_t) (const void *obj,
|
typedef void (*hb_cmap_collect_unicodes_func_t) (const void *obj,
|
||||||
hb_set_t *out);
|
hb_set_t *out);
|
||||||
|
|
||||||
static inline void collect_unicodes_func_nil (const void *obj, hb_set_t *out)
|
|
||||||
{
|
|
||||||
// NOOP
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
static inline bool get_glyph_from (const void *obj,
|
static inline bool get_glyph_from (const void *obj,
|
||||||
hb_codepoint_t codepoint,
|
hb_codepoint_t codepoint,
|
||||||
|
@ -1047,9 +1053,9 @@ struct cmap
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const CmapSubtable *subtable;
|
||||||
hb_cmap_get_glyph_func_t get_glyph_func;
|
hb_cmap_get_glyph_func_t get_glyph_func;
|
||||||
const void *get_glyph_data;
|
const void *get_glyph_data;
|
||||||
hb_cmap_collect_unicodes_func_t collect_unicodes_func;
|
|
||||||
|
|
||||||
CmapSubtableFormat4::accelerator_t format4_accel;
|
CmapSubtableFormat4::accelerator_t format4_accel;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue