提交 1dcf5fb0 编写于 作者: B Behdad Esfahbod

[cmap Add hb_subset_collect_variation_unicodes()

To be moved to hb-face.h later.
上级 4806b380
......@@ -296,7 +296,7 @@ struct CmapSubtableFormat4
{
/* XXX This does NOT skip over chars mapping to gid0... */
if (this->startCount[i] != 0xFFFFu || this->endCount[i] != 0xFFFFu) // Skip the last segment (0xFFFF)
hb_set_add_range (out, this->startCount[i], this->endCount[i]);
out->add_range (this->startCount[i], this->endCount[i]);
}
}
......@@ -459,11 +459,9 @@ struct CmapSubtableLongSegmented
inline void collect_unicodes (hb_set_t *out) const
{
for (unsigned int i = 0; i < this->groups.len; i++) {
hb_set_add_range (out,
MIN ((unsigned int) this->groups[i].startCharCode,
(unsigned int) HB_MAX_UNICODE_CODEPOINT_VALUE),
MIN ((unsigned int) this->groups[i].endCharCode,
(unsigned int) HB_MAX_UNICODE_CODEPOINT_VALUE));
out->add_range (this->groups[i].startCharCode,
MIN ((hb_codepoint_t) this->groups[i].endCharCode,
(hb_codepoint_t) HB_MAX_UNICODE_CODEPOINT_VALUE));
}
}
......@@ -600,7 +598,23 @@ struct UnicodeValueRange
DEFINE_SIZE_STATIC (4);
};
typedef SortedArrayOf<UnicodeValueRange, HBUINT32> DefaultUVS;
struct DefaultUVS : SortedArrayOf<UnicodeValueRange, HBUINT32>
{
inline void collect_unicodes (hb_set_t *out) const
{
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
{
hb_codepoint_t first = arrayZ[i].startUnicodeValue;
hb_codepoint_t last = MIN ((hb_codepoint_t) (first + arrayZ[i].additionalCount),
(hb_codepoint_t) HB_MAX_UNICODE_CODEPOINT_VALUE);
out->add_range (first, last);
}
}
public:
DEFINE_SIZE_ARRAY (4, arrayZ);
};
struct UVSMapping
{
......@@ -621,7 +635,18 @@ struct UVSMapping
DEFINE_SIZE_STATIC (5);
};
typedef SortedArrayOf<UVSMapping, HBUINT32> NonDefaultUVS;
struct NonDefaultUVS : SortedArrayOf<UVSMapping, HBUINT32>
{
inline void collect_unicodes (hb_set_t *out) const
{
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
out->add (arrayZ[i].glyphID);
}
public:
DEFINE_SIZE_ARRAY (4, arrayZ);
};
struct VariationSelectorRecord
{
......@@ -644,6 +669,12 @@ struct VariationSelectorRecord
return GLYPH_VARIANT_NOT_FOUND;
}
inline void collect_unicodes (hb_set_t *out, const void *base) const
{
(base+defaultUVS).collect_unicodes (out);
(base+nonDefaultUVS).collect_unicodes (out);
}
inline int cmp (const hb_codepoint_t &variation_selector) const
{
return varSelector.cmp (variation_selector);
......@@ -672,7 +703,7 @@ struct CmapSubtableFormat14
hb_codepoint_t variation_selector,
hb_codepoint_t *glyph) const
{
return record[record.bsearch(variation_selector)].get_glyph (codepoint, glyph, this);
return record[record.bsearch (variation_selector)].get_glyph (codepoint, glyph, this);
}
inline void collect_variation_selectors (hb_set_t *out) const
......@@ -681,6 +712,11 @@ struct CmapSubtableFormat14
for (unsigned int i = 0; i < count; i++)
out->add (record.arrayZ[i].varSelector);
}
inline void collect_variation_unicodes (hb_codepoint_t variation_selector,
hb_set_t *out) const
{
record[record.bsearch (variation_selector)].collect_unicodes (out, this);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
......@@ -1045,6 +1081,11 @@ struct cmap
{
subtable_uvs->collect_variation_selectors (out);
}
inline void collect_variation_unicodes (hb_codepoint_t variation_selector,
hb_set_t *out) const
{
subtable_uvs->collect_variation_unicodes (variation_selector, out);
}
protected:
typedef bool (*hb_cmap_get_glyph_func_t) (const void *obj,
......
......@@ -263,7 +263,8 @@ hb_subset_collect_unicodes (hb_face_t *face, hb_set_t *out)
* Since: REPLACEME
*/
void
hb_subset_collect_variation_selectors (hb_face_t *face, hb_set_t *out)
hb_subset_collect_variation_selectors (hb_face_t *face,
hb_set_t *out)
{
/* XXX Use saved accel. */
OT::cmap::accelerator_t cmap;
......@@ -271,3 +272,25 @@ hb_subset_collect_variation_selectors (hb_face_t *face, hb_set_t *out)
cmap.collect_variation_selectors (out);
cmap.fini();
}
/**
* hb_subset_collect_variation_unicodes:
* @face: font face.
* @out: set to add Unicode characters for @variation_selector covered by @face to.
*
*
*
* Since: REPLACEME
*/
void
hb_subset_collect_variation_unicodes (hb_face_t *face,
hb_codepoint_t variation_selector,
hb_set_t *out)
{
/* XXX Use saved accel. */
OT::cmap::accelerator_t cmap;
cmap.init (face);
cmap.collect_variation_unicodes (variation_selector, out);
cmap.fini();
}
......@@ -84,10 +84,16 @@ hb_subset (hb_face_t *source,
/* TODO Move to hb-face.h. */
HB_EXTERN void
hb_subset_collect_unicodes (hb_face_t *source, hb_set_t *out);
hb_subset_collect_unicodes (hb_face_t *face, hb_set_t *out);
HB_EXTERN void
hb_subset_collect_variation_selectors (hb_face_t *source, hb_set_t *out);
hb_subset_collect_variation_selectors (hb_face_t *face,
hb_set_t *out);
HB_EXTERN void
hb_subset_collect_variation_unicodes (hb_face_t *face,
hb_codepoint_t variation_selector,
hb_set_t *out);
HB_END_DECLS
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册