mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-28 00:59:16 +01:00
[varc] Implement cycle-detection
This commit is contained in:
1 parent
d5ab62a19a
commit
aed01d016e
2 files changed
+21
-8
No files matched your search
@@ -126,7 +126,8 @@ hb_transforming_pen_get_funcs ()
|
||||
hb_ubytes_t
|
||||
VarComponent::get_path_at (hb_font_t *font, hb_codepoint_t parent_gid, hb_draw_session_t &draw_session,
|
||||
hb_array_t<const int> coords,
|
||||
hb_ubytes_t record) const
|
||||
hb_ubytes_t record,
|
||||
hb_set_t *visited) const
|
||||
{
|
||||
auto &VARC = *font->face->table.VARC;
|
||||
const unsigned char *end = record.arrayZ + record.length;
|
||||
@@ -285,7 +286,7 @@ VarComponent::get_path_at (hb_font_t *font, hb_codepoint_t parent_gid, hb_draw_s
|
||||
&draw_session.st};
|
||||
hb_draw_session_t transformer_session {transformer_funcs, &context};
|
||||
|
||||
VARC.get_path_at (font, gid, transformer_session, component_coords, parent_gid);
|
||||
VARC.get_path_at (font, gid, transformer_session, component_coords, parent_gid, visited);
|
||||
|
||||
#undef PROCESS_TRANSFORM_COMPONENTS
|
||||
#undef READ_UINT32VAR
|
||||
|
||||
+18
-6
@@ -46,7 +46,8 @@ struct VarComponent
|
||||
HB_INTERNAL hb_ubytes_t
|
||||
get_path_at (hb_font_t *font, hb_codepoint_t parent_gid, hb_draw_session_t &draw_session,
|
||||
hb_array_t<const int> coords,
|
||||
hb_ubytes_t record) const;
|
||||
hb_ubytes_t record,
|
||||
hb_set_t *visited) const;
|
||||
};
|
||||
|
||||
struct VarCompositeGlyph
|
||||
@@ -54,12 +55,13 @@ struct VarCompositeGlyph
|
||||
static void
|
||||
get_path_at (hb_font_t *font, hb_codepoint_t glyph, hb_draw_session_t &draw_session,
|
||||
hb_array_t<const int> coords,
|
||||
hb_ubytes_t record)
|
||||
hb_ubytes_t record,
|
||||
hb_set_t *visited)
|
||||
{
|
||||
while (record)
|
||||
{
|
||||
const VarComponent &comp = * (const VarComponent *) (record.arrayZ);
|
||||
record = comp.get_path_at (font, glyph, draw_session, coords, record);
|
||||
record = comp.get_path_at (font, glyph, draw_session, coords, record, visited);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -75,8 +77,13 @@ struct VARC
|
||||
bool
|
||||
get_path_at (hb_font_t *font, hb_codepoint_t glyph, hb_draw_session_t &draw_session,
|
||||
hb_array_t<const int> coords,
|
||||
hb_codepoint_t parent_glyph = HB_CODEPOINT_INVALID) const
|
||||
hb_codepoint_t parent_glyph = HB_CODEPOINT_INVALID,
|
||||
hb_set_t *visited = nullptr) const
|
||||
{
|
||||
hb_set_t stack_set;
|
||||
if (visited == nullptr)
|
||||
visited = &stack_set;
|
||||
|
||||
// Don't recurse on the same glyph.
|
||||
unsigned idx = glyph == parent_glyph ?
|
||||
NOT_COVERED :
|
||||
@@ -92,9 +99,14 @@ struct VARC
|
||||
return true;
|
||||
}
|
||||
|
||||
hb_ubytes_t record = (this+glyphRecords)[idx];
|
||||
if (visited->has (glyph))
|
||||
return true;
|
||||
visited->add (glyph);
|
||||
|
||||
VarCompositeGlyph::get_path_at (font, glyph, draw_session, coords, record);
|
||||
hb_ubytes_t record = (this+glyphRecords)[idx];
|
||||
VarCompositeGlyph::get_path_at (font, glyph, draw_session, coords, record, visited);
|
||||
|
||||
visited->del (glyph);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user