-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Variable Fonts support: GVAR and CVAR table parsing (#698)
Implement parsing of gvar and cvar tables * add new parsing structures to the parser * add tests for gvar and cvar parsing * handle gvar and cvar tables during loading
- Loading branch information
Showing
17 changed files
with
558 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// The `cvar` table stores variation data for CVT values | ||
// https://learn.microsoft.com/en-us/typography/opentype/spec/cvar | ||
|
||
import parse from '../parse.js'; | ||
|
||
function parseCvarTable(data, start, fvar, cvt) { | ||
const p = new parse.Parser(data, start); | ||
const cvtVariations = p.parseTupleVariationStore( | ||
p.relativeOffset, | ||
fvar.axes.length, | ||
'cvar', | ||
cvt | ||
); | ||
const tableVersionMajor = p.parseUShort(); | ||
const tableVersionMinor = p.parseUShort(); | ||
if (tableVersionMajor !== 1) { | ||
console.warn(`Unsupported cvar table version ${tableVersionMajor}.${tableVersionMinor}`); | ||
} | ||
|
||
return { | ||
version: [tableVersionMajor, tableVersionMinor], | ||
...cvtVariations, | ||
}; | ||
} | ||
|
||
function makeCvarTable(/*cvar*/) { | ||
console.warn('Writing of cvar tables is not yet supported.'); | ||
} | ||
|
||
export default { make: makeCvarTable, parse: parseCvarTable }; |
Oops, something went wrong.