[V35] Introduce a unified letter model for determining stroke placements and widths
I'd like to introduce a utility class, say LetterModel, to replace the current DivFrame and AdviceStroke mechanism. It will create a unified way to determine the strokes' width and placements.
A letter model could be introduced like this (without macros):
define lowercaseM : LetterModel.solve
SpanningBetween 0 (Width * para.advanceScaleM)
SideBearing
Named "leftStem" : Stem
Counter
Named "middleStem" : Stem
Counter
Named "rightStem" : Stem
SideBearing
console.log lowercaseM.leftStem.left # left edge of left stem
console.log lowercaseM.middleStem.sw # Width of middle stem, without HVContrastLetterModel.solve takes various "commands" to build a letter model. The commands could be either an element (like Side-bearing, Stem or Counter), or a constrain like SpanningBetween. The solver will allocate elements' width within a spanning space, and fill out the properties of the final object, containing all the key metrics.
An element of a letter model could be a stem, counter, sidebearing, or other types we could introduce in the future. In the result, the elements' width will be expected to be all positive, and they sum up to the spanning space.
An element will always have a natural width, and behave differently when being compressed or stretched. For example, a Stem is not stretchable, and is hard to be compressed, while a Counter could be easily stretched or compressed. Elements could be parametrized to introduce differen behaviors, like for stems, we could redefine its "rigidness".
The plan would be replacing many of the existing mechanisms to use the letter model. In V34 we would like to migrate most of the letters to LM.
Source: be5invis/Iosevka