Comments (12)
Thanks very much! I'll implement this in the Fondue a.s.a.p. as 6.1 is now broken 😅
from lib-font.
Of course, thanks!
how opentype GSUB works, in all its insane glory =D
This might be my commit message when I fix it!
from lib-font.
Related error (not finding input coverage for lookup type 6) can also be observed in:
https://github.com/google/fonts/blob/main/ofl/abyssinicasil/AbyssinicaSIL-Regular.ttf
Which will return undefined
for all counts when loaded in the example code above.
from lib-font.
nice finds! I'll have to dig into this over the weekend.
from lib-font.
Another font with an undefined
inputGlyphCount
: https://github.com/google/fonts/blob/main/ofl/akayakanadaka/AkayaKanadaka-Regular.ttf
from lib-font.
Another one likely getting bitten by the same bug: https://github.com/google/fonts/blob/main/ofl/alice/Alice-Regular.ttf
from lib-font.
I rewrote your original example code a little to output a treeish structure to see what we're dealing with, which for the original font shows:
script id 0
|--lang id 0
| |--feature id 0
| | |--lookup id 0
| | | |--subtable id 0 (type 1, substFormat 2)
| |--feature id 1
| | |--lookup id 0
| | | |--subtable id 0 (type 1, substFormat 2)
| |--feature id 2
| | |--lookup id 0
| | | |--subtable id 0 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | | |--subtable id 1 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | | |--subtable id 2 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | | |--subtable id 3 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | |--lookup id 1
| | | |--subtable id 0 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | | |--subtable id 1 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| |--feature id 3
| | |--lookup id 0
| | | |--subtable id 0 (type 4, substFormat 1)
| |--feature id 4
| | |--lookup id 0
| | | |--subtable id 0 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | | |--subtable id 1 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| |--feature id 5
| | |--lookup id 0
| | | |--subtable id 0 (type 1, substFormat 1)
script id 1
|--lang id 0
| |--feature id 0
| | |--lookup id 0
| | | |--subtable id 0 (type 1, substFormat 2)
| |--feature id 1
| | |--lookup id 0
| | | |--subtable id 0 (type 1, substFormat 2)
| |--feature id 2
| | |--lookup id 0
| | | |--subtable id 0 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | | |--subtable id 1 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | | |--subtable id 2 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | | |--subtable id 3 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | |--lookup id 1
| | | |--subtable id 0 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | | |--subtable id 1 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| |--feature id 3
| | |--lookup id 0
| | | |--subtable id 0 (type 4, substFormat 1)
| |--feature id 4
| | |--lookup id 0
| | | |--subtable id 0 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| | | |--subtable id 1 (type 6, substFormat 3)
| | | | |--subtable glyph count: 1
| |--feature id 5
| | |--lookup id 0
| | | |--subtable id 0 (type 1, substFormat 1)
|--lang id 1
| |--feature id 0
| | |--lookup id 0
| | | |--subtable id 0 (type 6, substFormat 1)
| | | | |--subtable glyph count: undefined
So it looks like this only affects GSUB lookup type 6, subtable format 1, which is the Chained Sequence Context. Looking at its table structure, this format does not expose the inputGlyphCount at the subtable level, but encodes a list of chainSubRuleSets, which in turn encode a set of chainSubRule objects, and each of those have an inputGlyphCount record.
from lib-font.
Updating the code to this:
// ...
if (lookup.lookupType === 6) {
const inputGlyphCount = subtable.inputGlyphCount;
console.log(
`| | | | |--subtable glyph count: ${inputGlyphCount}`
);
const chainSubRuleSetCount = subtable.chainSubRuleSetCount;
console.log(
`| | | | |--chainSubRuleSetCount: ${chainSubRuleSetCount}`
);
for (let css = 0; css < chainSubRuleSetCount; css++) {
const chainSubRuleSet = subtable.getChainSubRuleSet(css);
const chainSubRuleCount = chainSubRuleSet.chainSubRuleCount;
console.log(
`| | | | | |--chainSubRuleCount for set ${css}: ${chainSubRuleCount}`
);
for (let csr = 0; csr < chainSubRuleCount; csr++) {
const chainSubRule = chainSubRuleSet.getSubRule(csr);
const inputGlyphCount = chainSubRule.inputGlyphCount;
console.log(
`| | | | | | |--inputGlyphCount for rule ${csr}: ${inputGlyphCount}`
);
}
}
}
// ...
Shows:
script id 1
|--lang id 0
| |--feature id 0
| | |--lookup id 0
| | | |--subtable id 0 (type 1, substFormat 2)
...
|--lang id 1
| |--feature id 0
| | |--lookup id 0
| | | |--subtable id 0 (type 6, substFormat 1)
| | | | |--subtable glyph count: undefined
| | | | |--chainSubRuleSetCount: 2
| | | | | |--chainSubRuleCount for set 0: 1
| | | | | | |--inputGlyphCount for rule 0: 2
| | | | | |--chainSubRuleCount for set 1: 1
| | | | | | |--inputGlyphCount for rule 0: 2
from lib-font.
@RoelN this feels like it's just part of the GSUB insanity rather than a bug: the values are there, but lookup 6.1 just encodes them in a much deeper spot than 6.3
(the master lookuptype list, linking through to each separate subtable format, can be found here)
from lib-font.
@Pomax Thanks for looking into it. What does this mean for when you want to get the 6.1 lookups? I'd like to show these features plus their input in Wakamai Fondue! :-)
from lib-font.
You can check for the substFormat
value to determine which flavour of lookup type 6 you're handling, and if it's 1, iterate over the ChainSubRuleSets using the code above:
let inputGlyphCount = 0;
for (let css = 0; css < chainSubRuleSetCount; css++) {
const chainSubRuleSet = subtable.getChainSubRuleSet(css);
const chainSubRuleCount = chainSubRuleSet.chainSubRuleCount;
for (let csr = 0; csr < chainSubRuleCount; csr++) {
const chainSubRule = chainSubRuleSet.getSubRule(csr);
// and then, for example:
inputGlyphCount += chainSubRule.inputGlyphCount;
}
}
// inputGlyphCount is now the total tally of all input counts spanned by this 6.1 lookup
from lib-font.
(closing as not actually a bug but just "how opentype GSUB works, in all its insane glory =D")
from lib-font.
Related Issues (20)
- rollup is broken HOT 4
- rename font.js to lib-font HOT 1
- How to use lookup type 7 (Extension Substitution) HOT 3
- implement extension substitution for gsub lookuptype 7
- Fonts that trip up LibFont HOT 10
- Fix woff2 support
- add a github action for PRs that runs the tests HOT 2
- Add support for WOFF2 transformed table data for glyf/loca/htmx
- Flaticon.woff2 is not parsing correctly. HOT 15
- use node's zlib for brotli decode / gunzip HOT 1
- GSUB bug when decoding Castoro HOT 11
- Color font info HOT 1
- Error reading SVG table (ReferenceError: uint16 is not defined) HOT 5
- Investigate test framework not dealing with exceptions properly
- font.opentype.tables is not enumerable HOT 4
- Prebuilt `lib-font.browser.js` bundle throws `Unexpected token 'export'` error HOT 4
- Modify font object HOT 2
- Use the lib-font browser bundle in a webpack project. HOT 4
- Supports CommonJS HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lib-font.