Expand description
Pango-backed TextMeasure.
The one part of the engine that needs a font stack. Everything about
this implementation is shaped by the thing it must not do: xtext’s
find_next_wrap (xtext.c:3685) called backend_get_text_width_emph
per character, and each of those did a pango_layout_set_text +
pango_layout_get_pixel_size round trip. That is the single hottest
path in xtext’s append and the reason resizing a large buffer
hitches.
Here:
- the unit of work is a run, because that is all the trait exposes;
- one
pango::Layoutis reused rather than allocated per call; TextMeasure::fit_prefixis a singlexy_to_indexquery instead of the trait’s default binary search, so finding a wrap point costs one shaping pass rather thanlog nof them;- a small cache keyed on
(text, style)short-circuits the repeat measurements that wrapping produces for the same run.