I have been doing some research into what it would take to implement subscript and superscript. For my current use case, I think that the current state is actually sufficient (however, this assessment was made is before any code is written). See the details section for a sketch of how this can be done.
Implementing subscript with the current Parley
To implement a "good-enough" version of subscript in current Parley, we can emulate it with a marker associated with the brush, and a font size modifier. When we see the marker, we manually adjust the glyph.y down by (say) 30% of the line's (or possibly run's?) line height. These numbers are all tweakable, and aren't the point of this section.
Raph did point out that this has edge cases with ligatures (e.g. if you have a normal run of ff with font size of 12, then a subscripted i with a font size of 16), then this pattern would accidentally combine them together. This also applies to languages with more complex shaping.
Some sources about implementing this with full fidelity:
I have been doing some research into what it would take to implement subscript and superscript. For my current use case, I think that the current state is actually sufficient (however, this assessment was made is before any code is written). See the details section for a sketch of how this can be done.
Implementing subscript with the current Parley
To implement a "good-enough" version of subscript in current Parley, we can emulate it with a marker associated with the brush, and a font size modifier. When we see the marker, we manually adjust the
glyph.ydown by (say) 30% of the line's (or possibly run's?) line height. These numbers are all tweakable, and aren't the point of this section.Raph did point out that this has edge cases with ligatures (e.g. if you have a normal run of
ffwith font size of 12, then a subscriptediwith a font size of 16), then this pattern would accidentally combine them together. This also applies to languages with more complex shaping.Some sources about implementing this with full fidelity:
subsandsupsopentype features.