opentype.js
opentype.js copied to clipboard
Support for enabling alternate characters/stylistic sets
I'm trying to use alternate characters in fonts (specific example: use Raleway with its more geometric and less weird stylistic alternates) for an application I'm building. I've been trying to debug why the following doesn't work:
font.forEachGlyph('wow such W', 0, 0, 24, {
ss01: true,
})
And I finally realized that only liga
and rlig
are supported right now, unless I have overlooked something. What's the status of this? Is there a plan for implementing it? Is there currently any workaround (without the application having specific knowledge of the font in use)?
I'm willing to contribute as well, but not sure how to effiiciently go about acquiring the necessary base knowledge. I'm brand new to opentype, but a seasoned JS/TS developer.
Expected Behavior
font.forEachGlyph should make use of alternate characters and stylistic sets, such as a conventional geometric W in the linked example.
Current Behavior
Only the liga
and rlig
features are supported
Steps to Reproduce (for bugs)
This example uses makerjs to simplify the code and render to SVG, but it's a relatively simple wrapper around font.forEachGlyph. https://codesandbox.io/s/cool-boyd-3r6ls?file=/src/index.js
Context
Wanting to provide access to stylistic alternates in a design webapp.
Your Environment
- opentype.js version 1.3.3
- makerjs version 0.17.0
- Font: https://fonts.gstatic.com/s/raleway/v19/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaooCPNLA3JC9c.ttf
I used SvgTextToPath library to generate design layouts. This library works with opentype.js. І will use OpenType features in CSS (tabular numbers or alternates stylistic set). But script replaces alternate symbols with the ordinary. Demo: tabular symbols "1" at the top replaced to ordinary.
Can you add support of other OT features (stylistic sets and tabular numbers)?
Please support more opentype features like smcp
and c2sc
and others. I mean it is called opentype.js!
@Typogram if you'd like to contribute support for those, we'd be happy to accept a PR for them.
@bgmort I'd take a look at the microsoft typography documentation for the features you want implemented, that should get you started.