-
Notifications
You must be signed in to change notification settings - Fork 682
Description
In horizontal typesetting, it is convenient to iterate through glyph output in the form (cluster, codepoint, x_advance, x_offset) or something similar. However harfbuzz returns this info in two lists of glyph objects, from buffer_get_glyph_infos and hb.buffer_get_glyph_positions. That means that, in python at least, code like
glyph_iterator = ((N.cluster, N.codepoint, P.x_advance, P.x_offset) for N, P in zip(infos, positions))
is necessary to bridge that step. However my tests show that this generator actually takes about 8.1 times longer than the shaping operation itself, including calling the two buffer functions that give glyph infos and glyph positions. That means that the python unpacking operation is responsible for almost 90% of the total processing time. Further testing shows that most of this is due to the attribute lookups on .cluster, .codepoint, .x_advance, and .x_offset, not zip().
This is quite shocking to me, and I think it would be very, very helpful if harfbuzz could just build the glyphs in such a format to begin with so this bottleneck could be avoided.