Closed Typogram closed 1 year ago
After digging into the source code, it appeared that font.layout
can in fact take glyphs as params. My bad, ignore this request!
My code that worked:
const glyphIds = [430, 113, 1, 971, 87, 560, 929, 557];
const glyphs = glyphIds.map((glyphId) => font.getGlyph(glyphId));
const run = font.layout(glyphs);
Result:
Use case: How to turn on
swsh
only on the first character in a GlyphRun?When I turn on
swsh
on a Glyph run, by default, it is of course applied to every single charcter, looks like this:I would like to apply
swsh
only to the first character (or in other words, to only part of the text string in the GlyphRun), how do I achieve that? Perhaps there is a way to create a GlyphRun using an array of Glyphs? Because I can then find all the individual Glyphs I want based on my preference on typesetting on individual letters, and manually put them together.Proposal
Extend font.layout to accept Array of Glyphs, and layout them, return a GlyphRun object