Add support for letterspacing #1615
Open
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Building on the changes in #1611 (in particular the addition of a
PangoAttrList
to the context state), adding support for tracking/letterspacing required minimal additions.The main change is a new context attribute which I've been calling
textTracking
, both as a way to avoid confusion with the cssletter-spacing
property and as a way to signal the units that it uses. In page layout apps, ‘tracking’ is typically a positive or negative integer that expresses the additional space to add or remove in terms of 1/1000 of an em.Using em-based units has the nice effect of keeping the spacing proportions constant even if the font size changes. Expressing the size in thousandths is helpful since typical amounts of letterspacing to add are usually in the range of
50
-250
(which is more awkward to express in css units:0.05em
–0.25em
).As with the other
ctx.text*
attributes, thetextTracking
value is part of the context state and behaves as expected acrosssave()
andrestore()
calls.