My idea of how to proceed is something like this:
- add a method to NSLayoutManager for getting a range of glyphs and their
advances as efficiently as possible, which should not be difficult (or maybe we
already have that?). I'm not sure if I advertised it well, but I made a
change in NSLayoutManager several months ago so that we store advancements
along with the glyphs in the glyph run data structure (previously, the
advancements were not stored.The reason for this change is so in the future we
can implement a glyph generator which does complex text layout, by calling a
library such as harfbuzz or icu, since these take a character run and output a
glpyh run with advancements.)
- properly implement GSShowGlyphsWithAdvances in the backends. easy for cairo,
at least.
- for cairo, it would be nice to use real glyphs by importing the code from
Opal that Neils and I wrote.
The pseudocode for -drawGlyphsForGlyphRange:atPoint: should look something like
this:
for the range to be drawn:
- get the first subrange with the same colour
- get the glyphs in that subrange and their advances as efficiently as
possible
- set the colour, and send the glyphs and advances to the backend with
GSShowGlyphsWithAdvances
- start the next loop iteration, starting at the end of the current
subrange