Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exntend font.layout accept Array of Glyphs and return a GlyphRun? #318

Closed
Typogram opened this issue Aug 25, 2023 · 1 comment
Closed

Exntend font.layout accept Array of Glyphs and return a GlyphRun? #318

Typogram opened this issue Aug 25, 2023 · 1 comment

Comments

@Typogram
Copy link

Typogram commented Aug 25, 2023

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:
image

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

@Typogram Typogram changed the title How to turn on swsh only on the first character in a GlyphRun? Exntend font.layout accept Array of Glyphs and return a GlyphRun? Aug 25, 2023
@Typogram
Copy link
Author

Typogram commented Aug 25, 2023

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:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant