Reputation: 1
I am currently trying to create an overview for typefaces, displaying all glyphs and their alternatives. For this I am using opentype.js to extract all necessary information. I've been looking into these featureLists and lookups but I can't yet wrap my head around how they work.
Specifically, for example, I want to get all glyphs that change when "ss01" is enabled.
Any pointers where that information is stored or if there are any libraries that can help me with that are greatly appreciated!
Upvotes: 0
Views: 357
Reputation: 3580
Within the font, that date is stored in the GSUB table, specifically within lookup subtables. The lookup subtables can be of different types, which are different kinds of substitutions (see the GSUB lookup type enumeration at https://learn.microsoft.com/en-us/typography/opentype/spec/gsub#table-organization), and which use different formats for representing the data.
A feature like 'ss01' will often use type 1 lookup subtables, which are single substitutions: replace one glyph with one glyph. Type 1 lookup subtables are represented using two simple formats (the simplest formats among GSUB lookup types). The two formats differ in how they represent what glyphs are output by the substitution; both use a coverage subtable to describe the inputs—the set of glyphs that get substituted. Coverage tables can be represented using two formats, but both formats represent the same conceptual info: a set of glyphs. So, getting the glyphs in the coverage table for type 1 lookup subtables would answer your question... for that lookup type.
There's nothing preventing a font developer from using other basic lookup types for 'ss01'—multiple substitution (one to many, type 2), alternate substitution (one to one of many, type 3), or ligature substitution (many to one, type 4)—though for 'ss01' that's probably not likely. However, there are also contextual substitution types (substitute glyphs if in a matching glyph-sequence context), and in those cases the formats are more complex and it will be less simple to get the info you want. All these types have coverage tables that indicate the first glyph in the input sequence that is acted on, though that glyph might not actually be acted upon. Unless you can find a library that has already solved this, you'll need to get familiar with all of these lookup subtable types.
Upvotes: 1