blank project
This commit is contained in:
78
node_modules/fontkit/src/tables/BASE.js
generated
vendored
Normal file
78
node_modules/fontkit/src/tables/BASE.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
import * as r from 'restructure';
|
||||
import {ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device} from './opentype';
|
||||
import {ItemVariationStore} from './variations';
|
||||
|
||||
let BaseCoord = new r.VersionedStruct(r.uint16, {
|
||||
1: { // Design units only
|
||||
coordinate: r.int16 // X or Y value, in design units
|
||||
},
|
||||
|
||||
2: { // Design units plus contour point
|
||||
coordinate: r.int16, // X or Y value, in design units
|
||||
referenceGlyph: r.uint16, // GlyphID of control glyph
|
||||
baseCoordPoint: r.uint16 // Index of contour point on the referenceGlyph
|
||||
},
|
||||
|
||||
3: { // Design units plus Device table
|
||||
coordinate: r.int16, // X or Y value, in design units
|
||||
deviceTable: new r.Pointer(r.uint16, Device) // Device table for X or Y value
|
||||
}
|
||||
});
|
||||
|
||||
let BaseValues = new r.Struct({
|
||||
defaultIndex: r.uint16, // Index of default baseline for this script-same index in the BaseTagList
|
||||
baseCoordCount: r.uint16,
|
||||
baseCoords: new r.Array(new r.Pointer(r.uint16, BaseCoord), 'baseCoordCount')
|
||||
});
|
||||
|
||||
let FeatMinMaxRecord = new r.Struct({
|
||||
tag: new r.String(4), // 4-byte feature identification tag-must match FeatureTag in FeatureList
|
||||
minCoord: new r.Pointer(r.uint16, BaseCoord, {type: 'parent'}), // May be NULL
|
||||
maxCoord: new r.Pointer(r.uint16, BaseCoord, {type: 'parent'}) // May be NULL
|
||||
});
|
||||
|
||||
let MinMax = new r.Struct({
|
||||
minCoord: new r.Pointer(r.uint16, BaseCoord), // May be NULL
|
||||
maxCoord: new r.Pointer(r.uint16, BaseCoord), // May be NULL
|
||||
featMinMaxCount: r.uint16, // May be 0
|
||||
featMinMaxRecords: new r.Array(FeatMinMaxRecord, 'featMinMaxCount') // In alphabetical order
|
||||
});
|
||||
|
||||
let BaseLangSysRecord = new r.Struct({
|
||||
tag: new r.String(4), // 4-byte language system identification tag
|
||||
minMax: new r.Pointer(r.uint16, MinMax, {type: 'parent'})
|
||||
});
|
||||
|
||||
let BaseScript = new r.Struct({
|
||||
baseValues: new r.Pointer(r.uint16, BaseValues), // May be NULL
|
||||
defaultMinMax: new r.Pointer(r.uint16, MinMax), // May be NULL
|
||||
baseLangSysCount: r.uint16, // May be 0
|
||||
baseLangSysRecords: new r.Array(BaseLangSysRecord, 'baseLangSysCount') // in alphabetical order by BaseLangSysTag
|
||||
});
|
||||
|
||||
let BaseScriptRecord = new r.Struct({
|
||||
tag: new r.String(4), // 4-byte script identification tag
|
||||
script: new r.Pointer(r.uint16, BaseScript, {type: 'parent'})
|
||||
});
|
||||
|
||||
let BaseScriptList = new r.Array(BaseScriptRecord, r.uint16);
|
||||
|
||||
// Array of 4-byte baseline identification tags-must be in alphabetical order
|
||||
let BaseTagList = new r.Array(new r.String(4), r.uint16);
|
||||
|
||||
let Axis = new r.Struct({
|
||||
baseTagList: new r.Pointer(r.uint16, BaseTagList), // May be NULL
|
||||
baseScriptList: new r.Pointer(r.uint16, BaseScriptList)
|
||||
});
|
||||
|
||||
export default new r.VersionedStruct(r.uint32, {
|
||||
header: {
|
||||
horizAxis: new r.Pointer(r.uint16, Axis), // May be NULL
|
||||
vertAxis: new r.Pointer(r.uint16, Axis) // May be NULL
|
||||
},
|
||||
|
||||
0x00010000: {},
|
||||
0x00010001: {
|
||||
itemVariationStore: new r.Pointer(r.uint32, ItemVariationStore)
|
||||
}
|
||||
});
|
||||
25
node_modules/fontkit/src/tables/COLR.js
generated
vendored
Normal file
25
node_modules/fontkit/src/tables/COLR.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let LayerRecord = new r.Struct({
|
||||
gid: r.uint16, // Glyph ID of layer glyph (must be in z-order from bottom to top).
|
||||
paletteIndex: r.uint16 // Index value to use in the appropriate palette. This value must
|
||||
}); // be less than numPaletteEntries in the CPAL table, except for
|
||||
// the special case noted below. Each palette entry is 16 bits.
|
||||
// A palette index of 0xFFFF is a special case indicating that
|
||||
// the text foreground color should be used.
|
||||
|
||||
let BaseGlyphRecord = new r.Struct({
|
||||
gid: r.uint16, // Glyph ID of reference glyph. This glyph is for reference only
|
||||
// and is not rendered for color.
|
||||
firstLayerIndex: r.uint16, // Index (from beginning of the Layer Records) to the layer record.
|
||||
// There will be numLayers consecutive entries for this base glyph.
|
||||
numLayers: r.uint16
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.uint16,
|
||||
numBaseGlyphRecords: r.uint16,
|
||||
baseGlyphRecord: new r.Pointer(r.uint32, new r.Array(BaseGlyphRecord, 'numBaseGlyphRecords')),
|
||||
layerRecords: new r.Pointer(r.uint32, new r.Array(LayerRecord, 'numLayerRecords'), { lazy: true }),
|
||||
numLayerRecords: r.uint16
|
||||
});
|
||||
24
node_modules/fontkit/src/tables/CPAL.js
generated
vendored
Normal file
24
node_modules/fontkit/src/tables/CPAL.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let ColorRecord = new r.Struct({
|
||||
blue: r.uint8,
|
||||
green: r.uint8,
|
||||
red: r.uint8,
|
||||
alpha: r.uint8
|
||||
});
|
||||
|
||||
export default new r.VersionedStruct(r.uint16, {
|
||||
header: {
|
||||
numPaletteEntries: r.uint16,
|
||||
numPalettes: r.uint16,
|
||||
numColorRecords: r.uint16,
|
||||
colorRecords: new r.Pointer(r.uint32, new r.Array(ColorRecord, 'numColorRecords')),
|
||||
colorRecordIndices: new r.Array(r.uint16, 'numPalettes'),
|
||||
},
|
||||
0: {},
|
||||
1: {
|
||||
offsetPaletteTypeArray: new r.Pointer(r.uint32, new r.Array(r.uint32, 'numPalettes')),
|
||||
offsetPaletteLabelArray: new r.Pointer(r.uint32, new r.Array(r.uint16, 'numPalettes')),
|
||||
offsetPaletteEntryLabelArray: new r.Pointer(r.uint32, new r.Array(r.uint16, 'numPaletteEntries'))
|
||||
}
|
||||
});
|
||||
21
node_modules/fontkit/src/tables/DSIG.js
generated
vendored
Normal file
21
node_modules/fontkit/src/tables/DSIG.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let Signature = new r.Struct({
|
||||
format: r.uint32,
|
||||
length: r.uint32,
|
||||
offset: r.uint32
|
||||
});
|
||||
|
||||
let SignatureBlock = new r.Struct({
|
||||
reserved: new r.Reserved(r.uint16, 2),
|
||||
cbSignature: r.uint32, // Length (in bytes) of the PKCS#7 packet in pbSignature
|
||||
signature: new r.Buffer('cbSignature')
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
ulVersion: r.uint32, // Version number of the DSIG table (0x00000001)
|
||||
usNumSigs: r.uint16, // Number of signatures in the table
|
||||
usFlag: r.uint16, // Permission flags
|
||||
signatures: new r.Array(Signature, 'usNumSigs'),
|
||||
signatureBlocks: new r.Array(SignatureBlock, 'usNumSigs')
|
||||
});
|
||||
91
node_modules/fontkit/src/tables/EBDT.js
generated
vendored
Normal file
91
node_modules/fontkit/src/tables/EBDT.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
export let BigMetrics = new r.Struct({
|
||||
height: r.uint8,
|
||||
width: r.uint8,
|
||||
horiBearingX: r.int8,
|
||||
horiBearingY: r.int8,
|
||||
horiAdvance: r.uint8,
|
||||
vertBearingX: r.int8,
|
||||
vertBearingY: r.int8,
|
||||
vertAdvance: r.uint8
|
||||
});
|
||||
|
||||
export let SmallMetrics = new r.Struct({
|
||||
height: r.uint8,
|
||||
width: r.uint8,
|
||||
bearingX: r.int8,
|
||||
bearingY: r.int8,
|
||||
advance: r.uint8
|
||||
});
|
||||
|
||||
let EBDTComponent = new r.Struct({
|
||||
glyph: r.uint16,
|
||||
xOffset: r.int8,
|
||||
yOffset: r.int8
|
||||
});
|
||||
|
||||
class ByteAligned {}
|
||||
|
||||
class BitAligned {}
|
||||
|
||||
export let glyph = new r.VersionedStruct('version', {
|
||||
1: {
|
||||
metrics: SmallMetrics,
|
||||
data: ByteAligned
|
||||
},
|
||||
|
||||
2: {
|
||||
metrics: SmallMetrics,
|
||||
data: BitAligned
|
||||
},
|
||||
|
||||
// format 3 is deprecated
|
||||
// format 4 is not supported by Microsoft
|
||||
|
||||
5: {
|
||||
data: BitAligned
|
||||
},
|
||||
|
||||
6: {
|
||||
metrics: BigMetrics,
|
||||
data: ByteAligned
|
||||
},
|
||||
|
||||
7: {
|
||||
metrics: BigMetrics,
|
||||
data: BitAligned
|
||||
},
|
||||
|
||||
8: {
|
||||
metrics: SmallMetrics,
|
||||
pad: new r.Reserved(r.uint8),
|
||||
numComponents: r.uint16,
|
||||
components: new r.Array(EBDTComponent, 'numComponents')
|
||||
},
|
||||
|
||||
9: {
|
||||
metrics: BigMetrics,
|
||||
pad: new r.Reserved(r.uint8),
|
||||
numComponents: r.uint16,
|
||||
components: new r.Array(EBDTComponent, 'numComponents')
|
||||
},
|
||||
|
||||
17: {
|
||||
metrics: SmallMetrics,
|
||||
dataLen: r.uint32,
|
||||
data: new r.Buffer('dataLen')
|
||||
},
|
||||
|
||||
18: {
|
||||
metrics: BigMetrics,
|
||||
dataLen: r.uint32,
|
||||
data: new r.Buffer('dataLen')
|
||||
},
|
||||
|
||||
19: {
|
||||
dataLen: r.uint32,
|
||||
data: new r.Buffer('dataLen')
|
||||
}
|
||||
});
|
||||
|
||||
80
node_modules/fontkit/src/tables/EBLC.js
generated
vendored
Normal file
80
node_modules/fontkit/src/tables/EBLC.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
import * as r from 'restructure';
|
||||
import {BigMetrics} from './EBDT';
|
||||
|
||||
let SBitLineMetrics = new r.Struct({
|
||||
ascender: r.int8,
|
||||
descender: r.int8,
|
||||
widthMax: r.uint8,
|
||||
caretSlopeNumerator: r.int8,
|
||||
caretSlopeDenominator: r.int8,
|
||||
caretOffset: r.int8,
|
||||
minOriginSB: r.int8,
|
||||
minAdvanceSB: r.int8,
|
||||
maxBeforeBL: r.int8,
|
||||
minAfterBL: r.int8,
|
||||
pad: new r.Reserved(r.int8, 2)
|
||||
});
|
||||
|
||||
let CodeOffsetPair = new r.Struct({
|
||||
glyphCode: r.uint16,
|
||||
offset: r.uint16
|
||||
});
|
||||
|
||||
let IndexSubtable = new r.VersionedStruct(r.uint16, {
|
||||
header: {
|
||||
imageFormat: r.uint16,
|
||||
imageDataOffset: r.uint32
|
||||
},
|
||||
|
||||
1: {
|
||||
offsetArray: new r.Array(r.uint32, t => t.parent.lastGlyphIndex - t.parent.firstGlyphIndex + 1)
|
||||
},
|
||||
|
||||
2: {
|
||||
imageSize: r.uint32,
|
||||
bigMetrics: BigMetrics
|
||||
},
|
||||
|
||||
3: {
|
||||
offsetArray: new r.Array(r.uint16, t => t.parent.lastGlyphIndex - t.parent.firstGlyphIndex + 1)
|
||||
},
|
||||
|
||||
4: {
|
||||
numGlyphs: r.uint32,
|
||||
glyphArray: new r.Array(CodeOffsetPair, t => t.numGlyphs + 1)
|
||||
},
|
||||
|
||||
5: {
|
||||
imageSize: r.uint32,
|
||||
bigMetrics: BigMetrics,
|
||||
numGlyphs: r.uint32,
|
||||
glyphCodeArray: new r.Array(r.uint16, 'numGlyphs')
|
||||
}
|
||||
});
|
||||
|
||||
let IndexSubtableArray = new r.Struct({
|
||||
firstGlyphIndex: r.uint16,
|
||||
lastGlyphIndex: r.uint16,
|
||||
subtable: new r.Pointer(r.uint32, IndexSubtable)
|
||||
});
|
||||
|
||||
let BitmapSizeTable = new r.Struct({
|
||||
indexSubTableArray: new r.Pointer(r.uint32, new r.Array(IndexSubtableArray, 1), { type: 'parent' }),
|
||||
indexTablesSize: r.uint32,
|
||||
numberOfIndexSubTables: r.uint32,
|
||||
colorRef: r.uint32,
|
||||
hori: SBitLineMetrics,
|
||||
vert: SBitLineMetrics,
|
||||
startGlyphIndex: r.uint16,
|
||||
endGlyphIndex: r.uint16,
|
||||
ppemX: r.uint8,
|
||||
ppemY: r.uint8,
|
||||
bitDepth: r.uint8,
|
||||
flags: new r.Bitfield(r.uint8, ['horizontal', 'vertical'])
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.uint32, // 0x00020000
|
||||
numSizes: r.uint32,
|
||||
sizes: new r.Array(BitmapSizeTable, 'numSizes')
|
||||
});
|
||||
57
node_modules/fontkit/src/tables/GDEF.js
generated
vendored
Normal file
57
node_modules/fontkit/src/tables/GDEF.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import * as r from 'restructure';
|
||||
import {ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device} from './opentype';
|
||||
import {ItemVariationStore} from './variations';
|
||||
|
||||
let AttachPoint = new r.Array(r.uint16, r.uint16);
|
||||
let AttachList = new r.Struct({
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
glyphCount: r.uint16,
|
||||
attachPoints: new r.Array(new r.Pointer(r.uint16, AttachPoint), 'glyphCount')
|
||||
});
|
||||
|
||||
let CaretValue = new r.VersionedStruct(r.uint16, {
|
||||
1: { // Design units only
|
||||
coordinate: r.int16
|
||||
},
|
||||
|
||||
2: { // Contour point
|
||||
caretValuePoint: r.uint16
|
||||
},
|
||||
|
||||
3: { // Design units plus Device table
|
||||
coordinate: r.int16,
|
||||
deviceTable: new r.Pointer(r.uint16, Device)
|
||||
}
|
||||
});
|
||||
|
||||
let LigGlyph = new r.Array(new r.Pointer(r.uint16, CaretValue), r.uint16);
|
||||
|
||||
let LigCaretList = new r.Struct({
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
ligGlyphCount: r.uint16,
|
||||
ligGlyphs: new r.Array(new r.Pointer(r.uint16, LigGlyph), 'ligGlyphCount')
|
||||
});
|
||||
|
||||
let MarkGlyphSetsDef = new r.Struct({
|
||||
markSetTableFormat: r.uint16,
|
||||
markSetCount: r.uint16,
|
||||
coverage: new r.Array(new r.Pointer(r.uint32, Coverage), 'markSetCount')
|
||||
});
|
||||
|
||||
export default new r.VersionedStruct(r.uint32, {
|
||||
header: {
|
||||
glyphClassDef: new r.Pointer(r.uint16, ClassDef),
|
||||
attachList: new r.Pointer(r.uint16, AttachList),
|
||||
ligCaretList: new r.Pointer(r.uint16, LigCaretList),
|
||||
markAttachClassDef: new r.Pointer(r.uint16, ClassDef)
|
||||
},
|
||||
|
||||
0x00010000: {},
|
||||
0x00010002: {
|
||||
markGlyphSetsDef: new r.Pointer(r.uint16, MarkGlyphSetsDef)
|
||||
},
|
||||
0x00010003: {
|
||||
markGlyphSetsDef: new r.Pointer(r.uint16, MarkGlyphSetsDef),
|
||||
itemVariationStore: new r.Pointer(r.uint32, ItemVariationStore)
|
||||
}
|
||||
});
|
||||
209
node_modules/fontkit/src/tables/GPOS.js
generated
vendored
Normal file
209
node_modules/fontkit/src/tables/GPOS.js
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
import * as r from 'restructure';
|
||||
import {ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device, Context, ChainingContext} from './opentype';
|
||||
import {FeatureVariations} from './variations';
|
||||
|
||||
let ValueFormat = new r.Bitfield(r.uint16, [
|
||||
'xPlacement', 'yPlacement',
|
||||
'xAdvance', 'yAdvance',
|
||||
'xPlaDevice', 'yPlaDevice',
|
||||
'xAdvDevice', 'yAdvDevice'
|
||||
]);
|
||||
|
||||
let types = {
|
||||
xPlacement: r.int16,
|
||||
yPlacement: r.int16,
|
||||
xAdvance: r.int16,
|
||||
yAdvance: r.int16,
|
||||
xPlaDevice: new r.Pointer(r.uint16, Device, { type: 'global', relativeTo: ctx => ctx.rel }),
|
||||
yPlaDevice: new r.Pointer(r.uint16, Device, { type: 'global', relativeTo: ctx => ctx.rel }),
|
||||
xAdvDevice: new r.Pointer(r.uint16, Device, { type: 'global', relativeTo: ctx => ctx.rel }),
|
||||
yAdvDevice: new r.Pointer(r.uint16, Device, { type: 'global', relativeTo: ctx => ctx.rel })
|
||||
};
|
||||
|
||||
class ValueRecord {
|
||||
constructor(key = 'valueFormat') {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
buildStruct(parent) {
|
||||
let struct = parent;
|
||||
while (!struct[this.key] && struct.parent) {
|
||||
struct = struct.parent;
|
||||
}
|
||||
|
||||
if (!struct[this.key]) return;
|
||||
|
||||
let fields = {};
|
||||
fields.rel = () => struct._startOffset;
|
||||
|
||||
let format = struct[this.key];
|
||||
for (let key in format) {
|
||||
if (format[key]) {
|
||||
fields[key] = types[key];
|
||||
}
|
||||
}
|
||||
|
||||
return new r.Struct(fields);
|
||||
}
|
||||
|
||||
size(val, ctx) {
|
||||
return this.buildStruct(ctx).size(val, ctx);
|
||||
}
|
||||
|
||||
decode(stream, parent) {
|
||||
let res = this.buildStruct(parent).decode(stream, parent);
|
||||
delete res.rel;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
let PairValueRecord = new r.Struct({
|
||||
secondGlyph: r.uint16,
|
||||
value1: new ValueRecord('valueFormat1'),
|
||||
value2: new ValueRecord('valueFormat2')
|
||||
});
|
||||
|
||||
let PairSet = new r.Array(PairValueRecord, r.uint16);
|
||||
|
||||
let Class2Record = new r.Struct({
|
||||
value1: new ValueRecord('valueFormat1'),
|
||||
value2: new ValueRecord('valueFormat2')
|
||||
});
|
||||
|
||||
let Anchor = new r.VersionedStruct(r.uint16, {
|
||||
1: { // Design units only
|
||||
xCoordinate: r.int16,
|
||||
yCoordinate: r.int16
|
||||
},
|
||||
|
||||
2: { // Design units plus contour point
|
||||
xCoordinate: r.int16,
|
||||
yCoordinate: r.int16,
|
||||
anchorPoint: r.uint16
|
||||
},
|
||||
|
||||
3: { // Design units plus Device tables
|
||||
xCoordinate: r.int16,
|
||||
yCoordinate: r.int16,
|
||||
xDeviceTable: new r.Pointer(r.uint16, Device),
|
||||
yDeviceTable: new r.Pointer(r.uint16, Device)
|
||||
}
|
||||
});
|
||||
|
||||
let EntryExitRecord = new r.Struct({
|
||||
entryAnchor: new r.Pointer(r.uint16, Anchor, {type: 'parent'}),
|
||||
exitAnchor: new r.Pointer(r.uint16, Anchor, {type: 'parent'})
|
||||
});
|
||||
|
||||
let MarkRecord = new r.Struct({
|
||||
class: r.uint16,
|
||||
markAnchor: new r.Pointer(r.uint16, Anchor, {type: 'parent'})
|
||||
});
|
||||
|
||||
let MarkArray = new r.Array(MarkRecord, r.uint16);
|
||||
|
||||
let BaseRecord = new r.Array(new r.Pointer(r.uint16, Anchor), t => t.parent.classCount);
|
||||
let BaseArray = new r.Array(BaseRecord, r.uint16);
|
||||
|
||||
let ComponentRecord = new r.Array(new r.Pointer(r.uint16, Anchor), t => t.parent.parent.classCount);
|
||||
let LigatureAttach = new r.Array(ComponentRecord, r.uint16);
|
||||
let LigatureArray = new r.Array(new r.Pointer(r.uint16, LigatureAttach), r.uint16);
|
||||
|
||||
let GPOSLookup = new r.VersionedStruct('lookupType', {
|
||||
1: new r.VersionedStruct(r.uint16, { // Single Adjustment
|
||||
1: { // Single positioning value
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
valueFormat: ValueFormat,
|
||||
value: new ValueRecord()
|
||||
},
|
||||
2: {
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
valueFormat: ValueFormat,
|
||||
valueCount: r.uint16,
|
||||
values: new r.LazyArray(new ValueRecord(), 'valueCount')
|
||||
}
|
||||
}),
|
||||
|
||||
2: new r.VersionedStruct(r.uint16, { // Pair Adjustment Positioning
|
||||
1: { // Adjustments for glyph pairs
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
valueFormat1: ValueFormat,
|
||||
valueFormat2: ValueFormat,
|
||||
pairSetCount: r.uint16,
|
||||
pairSets: new r.LazyArray(new r.Pointer(r.uint16, PairSet), 'pairSetCount')
|
||||
},
|
||||
|
||||
2: { // Class pair adjustment
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
valueFormat1: ValueFormat,
|
||||
valueFormat2: ValueFormat,
|
||||
classDef1: new r.Pointer(r.uint16, ClassDef),
|
||||
classDef2: new r.Pointer(r.uint16, ClassDef),
|
||||
class1Count: r.uint16,
|
||||
class2Count: r.uint16,
|
||||
classRecords: new r.LazyArray(new r.LazyArray(Class2Record, 'class2Count'), 'class1Count')
|
||||
}
|
||||
}),
|
||||
|
||||
3: { // Cursive Attachment Positioning
|
||||
format: r.uint16,
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
entryExitCount: r.uint16,
|
||||
entryExitRecords: new r.Array(EntryExitRecord, 'entryExitCount')
|
||||
},
|
||||
|
||||
4: { // MarkToBase Attachment Positioning
|
||||
format: r.uint16,
|
||||
markCoverage: new r.Pointer(r.uint16, Coverage),
|
||||
baseCoverage: new r.Pointer(r.uint16, Coverage),
|
||||
classCount: r.uint16,
|
||||
markArray: new r.Pointer(r.uint16, MarkArray),
|
||||
baseArray: new r.Pointer(r.uint16, BaseArray)
|
||||
},
|
||||
|
||||
5: { // MarkToLigature Attachment Positioning
|
||||
format: r.uint16,
|
||||
markCoverage: new r.Pointer(r.uint16, Coverage),
|
||||
ligatureCoverage: new r.Pointer(r.uint16, Coverage),
|
||||
classCount: r.uint16,
|
||||
markArray: new r.Pointer(r.uint16, MarkArray),
|
||||
ligatureArray: new r.Pointer(r.uint16, LigatureArray)
|
||||
},
|
||||
|
||||
6: { // MarkToMark Attachment Positioning
|
||||
format: r.uint16,
|
||||
mark1Coverage: new r.Pointer(r.uint16, Coverage),
|
||||
mark2Coverage: new r.Pointer(r.uint16, Coverage),
|
||||
classCount: r.uint16,
|
||||
mark1Array: new r.Pointer(r.uint16, MarkArray),
|
||||
mark2Array: new r.Pointer(r.uint16, BaseArray)
|
||||
},
|
||||
|
||||
7: Context, // Contextual positioning
|
||||
8: ChainingContext, // Chaining contextual positioning
|
||||
|
||||
9: { // Extension Positioning
|
||||
posFormat: r.uint16,
|
||||
lookupType: r.uint16, // cannot also be 9
|
||||
extension: new r.Pointer(r.uint32, null)
|
||||
}
|
||||
});
|
||||
|
||||
// Fix circular reference
|
||||
GPOSLookup.versions[9].extension.type = GPOSLookup;
|
||||
|
||||
export default new r.VersionedStruct(r.uint32, {
|
||||
header: {
|
||||
scriptList: new r.Pointer(r.uint16, ScriptList),
|
||||
featureList: new r.Pointer(r.uint16, FeatureList),
|
||||
lookupList: new r.Pointer(r.uint16, new LookupList(GPOSLookup))
|
||||
},
|
||||
|
||||
0x00010000: {},
|
||||
0x00010001: {
|
||||
featureVariations: new r.Pointer(r.uint32, FeatureVariations)
|
||||
}
|
||||
});
|
||||
|
||||
// export GPOSLookup for JSTF table
|
||||
export { GPOSLookup };
|
||||
84
node_modules/fontkit/src/tables/GSUB.js
generated
vendored
Normal file
84
node_modules/fontkit/src/tables/GSUB.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
import * as r from 'restructure';
|
||||
import {ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device, Context, ChainingContext} from './opentype';
|
||||
import {FeatureVariations} from './variations';
|
||||
|
||||
let Sequence = new r.Array(r.uint16, r.uint16);
|
||||
let AlternateSet = Sequence;
|
||||
|
||||
let Ligature = new r.Struct({
|
||||
glyph: r.uint16,
|
||||
compCount: r.uint16,
|
||||
components: new r.Array(r.uint16, t => t.compCount - 1)
|
||||
});
|
||||
|
||||
let LigatureSet = new r.Array(new r.Pointer(r.uint16, Ligature), r.uint16);
|
||||
|
||||
let GSUBLookup = new r.VersionedStruct('lookupType', {
|
||||
1: new r.VersionedStruct(r.uint16, {// Single Substitution
|
||||
1: {
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
deltaGlyphID: r.int16
|
||||
},
|
||||
2: {
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
glyphCount: r.uint16,
|
||||
substitute: new r.LazyArray(r.uint16, 'glyphCount')
|
||||
}
|
||||
}),
|
||||
|
||||
2: { // Multiple Substitution
|
||||
substFormat: r.uint16,
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
count: r.uint16,
|
||||
sequences: new r.LazyArray(new r.Pointer(r.uint16, Sequence), 'count')
|
||||
},
|
||||
|
||||
3: { // Alternate Substitution
|
||||
substFormat: r.uint16,
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
count: r.uint16,
|
||||
alternateSet: new r.LazyArray(new r.Pointer(r.uint16, AlternateSet), 'count')
|
||||
},
|
||||
|
||||
4: { // Ligature Substitution
|
||||
substFormat: r.uint16,
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
count: r.uint16,
|
||||
ligatureSets: new r.LazyArray(new r.Pointer(r.uint16, LigatureSet), 'count')
|
||||
},
|
||||
|
||||
5: Context, // Contextual Substitution
|
||||
6: ChainingContext, // Chaining Contextual Substitution
|
||||
|
||||
7: { // Extension Substitution
|
||||
substFormat: r.uint16,
|
||||
lookupType: r.uint16, // cannot also be 7
|
||||
extension: new r.Pointer(r.uint32, null)
|
||||
},
|
||||
|
||||
8: { // Reverse Chaining Contextual Single Substitution
|
||||
substFormat: r.uint16,
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
backtrackCoverage: new r.Array(new r.Pointer(r.uint16, Coverage), 'backtrackGlyphCount'),
|
||||
lookaheadGlyphCount: r.uint16,
|
||||
lookaheadCoverage: new r.Array(new r.Pointer(r.uint16, Coverage), 'lookaheadGlyphCount'),
|
||||
glyphCount: r.uint16,
|
||||
substitutes: new r.Array(r.uint16, 'glyphCount')
|
||||
}
|
||||
});
|
||||
|
||||
// Fix circular reference
|
||||
GSUBLookup.versions[7].extension.type = GSUBLookup;
|
||||
|
||||
export default new r.VersionedStruct(r.uint32, {
|
||||
header: {
|
||||
scriptList: new r.Pointer(r.uint16, ScriptList),
|
||||
featureList: new r.Pointer(r.uint16, FeatureList),
|
||||
lookupList: new r.Pointer(r.uint16, new LookupList(GSUBLookup))
|
||||
},
|
||||
|
||||
0x00010000: {},
|
||||
0x00010001: {
|
||||
featureVariations: new r.Pointer(r.uint32, FeatureVariations)
|
||||
}
|
||||
});
|
||||
44
node_modules/fontkit/src/tables/HVAR.js
generated
vendored
Normal file
44
node_modules/fontkit/src/tables/HVAR.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import * as r from 'restructure';
|
||||
import { resolveLength } from 'restructure';
|
||||
import { ItemVariationStore } from './variations';
|
||||
|
||||
// TODO: add this to restructure
|
||||
class VariableSizeNumber {
|
||||
constructor(size) {
|
||||
this._size = size;
|
||||
}
|
||||
|
||||
decode(stream, parent) {
|
||||
switch (this.size(0, parent)) {
|
||||
case 1: return stream.readUInt8();
|
||||
case 2: return stream.readUInt16BE();
|
||||
case 3: return stream.readUInt24BE();
|
||||
case 4: return stream.readUInt32BE();
|
||||
}
|
||||
}
|
||||
|
||||
size(val, parent) {
|
||||
return resolveLength(this._size, null, parent);
|
||||
}
|
||||
}
|
||||
|
||||
let MapDataEntry = new r.Struct({
|
||||
entry: new VariableSizeNumber(t => ((t.parent.entryFormat & 0x0030) >> 4) + 1),
|
||||
outerIndex: t => t.entry >> ((t.parent.entryFormat & 0x000F) + 1),
|
||||
innerIndex: t => t.entry & ((1 << ((t.parent.entryFormat & 0x000F) + 1)) - 1)
|
||||
});
|
||||
|
||||
let DeltaSetIndexMap = new r.Struct({
|
||||
entryFormat: r.uint16,
|
||||
mapCount: r.uint16,
|
||||
mapData: new r.Array(MapDataEntry, 'mapCount')
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
majorVersion: r.uint16,
|
||||
minorVersion: r.uint16,
|
||||
itemVariationStore: new r.Pointer(r.uint32, ItemVariationStore),
|
||||
advanceWidthMapping: new r.Pointer(r.uint32, DeltaSetIndexMap),
|
||||
LSBMapping: new r.Pointer(r.uint32, DeltaSetIndexMap),
|
||||
RSBMapping: new r.Pointer(r.uint32, DeltaSetIndexMap)
|
||||
});
|
||||
43
node_modules/fontkit/src/tables/JSTF.js
generated
vendored
Normal file
43
node_modules/fontkit/src/tables/JSTF.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import * as r from 'restructure';
|
||||
import { ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device } from './opentype';
|
||||
import { GPOSLookup } from './GPOS';
|
||||
|
||||
let JstfGSUBModList = new r.Array(r.uint16, r.uint16);
|
||||
|
||||
let JstfPriority = new r.Struct({
|
||||
shrinkageEnableGSUB: new r.Pointer(r.uint16, JstfGSUBModList),
|
||||
shrinkageDisableGSUB: new r.Pointer(r.uint16, JstfGSUBModList),
|
||||
shrinkageEnableGPOS: new r.Pointer(r.uint16, JstfGSUBModList),
|
||||
shrinkageDisableGPOS: new r.Pointer(r.uint16, JstfGSUBModList),
|
||||
shrinkageJstfMax: new r.Pointer(r.uint16, new LookupList(GPOSLookup)),
|
||||
extensionEnableGSUB: new r.Pointer(r.uint16, JstfGSUBModList),
|
||||
extensionDisableGSUB: new r.Pointer(r.uint16, JstfGSUBModList),
|
||||
extensionEnableGPOS: new r.Pointer(r.uint16, JstfGSUBModList),
|
||||
extensionDisableGPOS: new r.Pointer(r.uint16, JstfGSUBModList),
|
||||
extensionJstfMax: new r.Pointer(r.uint16, new LookupList(GPOSLookup))
|
||||
});
|
||||
|
||||
let JstfLangSys = new r.Array(new r.Pointer(r.uint16, JstfPriority), r.uint16);
|
||||
|
||||
let JstfLangSysRecord = new r.Struct({
|
||||
tag: new r.String(4),
|
||||
jstfLangSys: new r.Pointer(r.uint16, JstfLangSys)
|
||||
});
|
||||
|
||||
let JstfScript = new r.Struct({
|
||||
extenderGlyphs: new r.Pointer(r.uint16, new r.Array(r.uint16, r.uint16)), // array of glyphs to extend line length
|
||||
defaultLangSys: new r.Pointer(r.uint16, JstfLangSys),
|
||||
langSysCount: r.uint16,
|
||||
langSysRecords: new r.Array(JstfLangSysRecord, 'langSysCount')
|
||||
});
|
||||
|
||||
let JstfScriptRecord = new r.Struct({
|
||||
tag: new r.String(4),
|
||||
script: new r.Pointer(r.uint16, JstfScript, {type: 'parent'})
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.uint32, // should be 0x00010000
|
||||
scriptCount: r.uint16,
|
||||
scriptList: new r.Array(JstfScriptRecord, 'scriptCount')
|
||||
});
|
||||
10
node_modules/fontkit/src/tables/LTSH.js
generated
vendored
Normal file
10
node_modules/fontkit/src/tables/LTSH.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// Linear Threshold table
|
||||
// Records the ppem for each glyph at which the scaling becomes linear again,
|
||||
// despite instructions effecting the advance width
|
||||
export default new r.Struct({
|
||||
version: r.uint16,
|
||||
numGlyphs: r.uint16,
|
||||
yPels: new r.Array(r.uint8, 'numGlyphs')
|
||||
});
|
||||
84
node_modules/fontkit/src/tables/OS2.js
generated
vendored
Normal file
84
node_modules/fontkit/src/tables/OS2.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
var OS2 = new r.VersionedStruct(r.uint16, {
|
||||
header: {
|
||||
xAvgCharWidth: r.int16, // average weighted advance width of lower case letters and space
|
||||
usWeightClass: r.uint16, // visual weight of stroke in glyphs
|
||||
usWidthClass: r.uint16, // relative change from the normal aspect ratio (width to height ratio)
|
||||
fsType: new r.Bitfield(r.uint16, [ // Indicates font embedding licensing rights
|
||||
null, 'noEmbedding', 'viewOnly', 'editable', null,
|
||||
null, null, null, 'noSubsetting', 'bitmapOnly'
|
||||
]),
|
||||
ySubscriptXSize: r.int16, // recommended horizontal size in pixels for subscripts
|
||||
ySubscriptYSize: r.int16, // recommended vertical size in pixels for subscripts
|
||||
ySubscriptXOffset: r.int16, // recommended horizontal offset for subscripts
|
||||
ySubscriptYOffset: r.int16, // recommended vertical offset form the baseline for subscripts
|
||||
ySuperscriptXSize: r.int16, // recommended horizontal size in pixels for superscripts
|
||||
ySuperscriptYSize: r.int16, // recommended vertical size in pixels for superscripts
|
||||
ySuperscriptXOffset: r.int16, // recommended horizontal offset for superscripts
|
||||
ySuperscriptYOffset: r.int16, // recommended vertical offset from the baseline for superscripts
|
||||
yStrikeoutSize: r.int16, // width of the strikeout stroke
|
||||
yStrikeoutPosition: r.int16, // position of the strikeout stroke relative to the baseline
|
||||
sFamilyClass: r.int16, // classification of font-family design
|
||||
panose: new r.Array(r.uint8, 10), // describe the visual characteristics of a given typeface
|
||||
ulCharRange: new r.Array(r.uint32, 4),
|
||||
vendorID: new r.String(4), // four character identifier for the font vendor
|
||||
fsSelection: new r.Bitfield(r.uint16, [ // bit field containing information about the font
|
||||
'italic', 'underscore', 'negative', 'outlined', 'strikeout',
|
||||
'bold', 'regular', 'useTypoMetrics', 'wws', 'oblique'
|
||||
]),
|
||||
usFirstCharIndex: r.uint16, // The minimum Unicode index in this font
|
||||
usLastCharIndex: r.uint16 // The maximum Unicode index in this font
|
||||
},
|
||||
|
||||
// The Apple version of this table ends here, but the Microsoft one continues on...
|
||||
0: {},
|
||||
|
||||
1: {
|
||||
typoAscender: r.int16,
|
||||
typoDescender: r.int16,
|
||||
typoLineGap: r.int16,
|
||||
winAscent: r.uint16,
|
||||
winDescent: r.uint16,
|
||||
codePageRange: new r.Array(r.uint32, 2)
|
||||
},
|
||||
|
||||
2: {
|
||||
// these should be common with version 1 somehow
|
||||
typoAscender: r.int16,
|
||||
typoDescender: r.int16,
|
||||
typoLineGap: r.int16,
|
||||
winAscent: r.uint16,
|
||||
winDescent: r.uint16,
|
||||
codePageRange: new r.Array(r.uint32, 2),
|
||||
|
||||
xHeight: r.int16,
|
||||
capHeight: r.int16,
|
||||
defaultChar: r.uint16,
|
||||
breakChar: r.uint16,
|
||||
maxContent: r.uint16
|
||||
},
|
||||
|
||||
5: {
|
||||
typoAscender: r.int16,
|
||||
typoDescender: r.int16,
|
||||
typoLineGap: r.int16,
|
||||
winAscent: r.uint16,
|
||||
winDescent: r.uint16,
|
||||
codePageRange: new r.Array(r.uint32, 2),
|
||||
|
||||
xHeight: r.int16,
|
||||
capHeight: r.int16,
|
||||
defaultChar: r.uint16,
|
||||
breakChar: r.uint16,
|
||||
maxContent: r.uint16,
|
||||
|
||||
usLowerOpticalPointSize: r.uint16,
|
||||
usUpperOpticalPointSize: r.uint16
|
||||
}
|
||||
});
|
||||
|
||||
let versions = OS2.versions;
|
||||
versions[3] = versions[4] = versions[2];
|
||||
|
||||
export default OS2;
|
||||
21
node_modules/fontkit/src/tables/PCLT.js
generated
vendored
Normal file
21
node_modules/fontkit/src/tables/PCLT.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// PCL 5 Table
|
||||
// NOTE: The PCLT table is strongly discouraged for OpenType fonts with TrueType outlines
|
||||
export default new r.Struct({
|
||||
version: r.uint16,
|
||||
fontNumber: r.uint32,
|
||||
pitch: r.uint16,
|
||||
xHeight: r.uint16,
|
||||
style: r.uint16,
|
||||
typeFamily: r.uint16,
|
||||
capHeight: r.uint16,
|
||||
symbolSet: r.uint16,
|
||||
typeface: new r.String(16),
|
||||
characterComplement: new r.String(8),
|
||||
fileName: new r.String(6),
|
||||
strokeWeight: new r.String(1),
|
||||
widthType: new r.String(1),
|
||||
serifStyle: r.uint8,
|
||||
reserved: new r.Reserved(r.uint8)
|
||||
});
|
||||
33
node_modules/fontkit/src/tables/VDMX.js
generated
vendored
Normal file
33
node_modules/fontkit/src/tables/VDMX.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// VDMX tables contain ascender/descender overrides for certain (usually small)
|
||||
// sizes. This is needed in order to match font metrics on Windows.
|
||||
|
||||
let Ratio = new r.Struct({
|
||||
bCharSet: r.uint8, // Character set
|
||||
xRatio: r.uint8, // Value to use for x-Ratio
|
||||
yStartRatio: r.uint8, // Starting y-Ratio value
|
||||
yEndRatio: r.uint8 // Ending y-Ratio value
|
||||
});
|
||||
|
||||
let vTable = new r.Struct({
|
||||
yPelHeight: r.uint16, // yPelHeight to which values apply
|
||||
yMax: r.int16, // Maximum value (in pels) for this yPelHeight
|
||||
yMin: r.int16 // Minimum value (in pels) for this yPelHeight
|
||||
});
|
||||
|
||||
let VdmxGroup = new r.Struct({
|
||||
recs: r.uint16, // Number of height records in this group
|
||||
startsz: r.uint8, // Starting yPelHeight
|
||||
endsz: r.uint8, // Ending yPelHeight
|
||||
entries: new r.Array(vTable, 'recs') // The VDMX records
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.uint16, // Version number (0 or 1)
|
||||
numRecs: r.uint16, // Number of VDMX groups present
|
||||
numRatios: r.uint16, // Number of aspect ratio groupings
|
||||
ratioRanges: new r.Array(Ratio, 'numRatios'), // Ratio ranges
|
||||
offsets: new r.Array(r.uint16, 'numRatios'), // Offset to the VDMX group for this ratio range
|
||||
groups: new r.Array(VdmxGroup, 'numRecs') // The actual VDMX groupings
|
||||
});
|
||||
14
node_modules/fontkit/src/tables/VORG.js
generated
vendored
Normal file
14
node_modules/fontkit/src/tables/VORG.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let VerticalOrigin = new r.Struct({
|
||||
glyphIndex: r.uint16,
|
||||
vertOriginY: r.int16
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
majorVersion: r.uint16,
|
||||
minorVersion: r.uint16,
|
||||
defaultVertOriginY: r.int16,
|
||||
numVertOriginYMetrics: r.uint16,
|
||||
metrics: new r.Array(VerticalOrigin, 'numVertOriginYMetrics')
|
||||
});
|
||||
74
node_modules/fontkit/src/tables/WOFF2Directory.js
generated
vendored
Normal file
74
node_modules/fontkit/src/tables/WOFF2Directory.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
const Base128 = {
|
||||
decode(stream) {
|
||||
let result = 0;
|
||||
let iterable = [0, 1, 2, 3, 4];
|
||||
for (let j = 0; j < iterable.length; j++) {
|
||||
let i = iterable[j];
|
||||
let code = stream.readUInt8();
|
||||
|
||||
// If any of the top seven bits are set then we're about to overflow.
|
||||
if (result & 0xe0000000) {
|
||||
throw new Error('Overflow');
|
||||
}
|
||||
|
||||
result = (result << 7) | (code & 0x7f);
|
||||
if ((code & 0x80) === 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('Bad base 128 number');
|
||||
}
|
||||
};
|
||||
|
||||
let knownTags = [
|
||||
'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'OS/2', 'post', 'cvt ',
|
||||
'fpgm', 'glyf', 'loca', 'prep', 'CFF ', 'VORG', 'EBDT', 'EBLC', 'gasp',
|
||||
'hdmx', 'kern', 'LTSH', 'PCLT', 'VDMX', 'vhea', 'vmtx', 'BASE', 'GDEF',
|
||||
'GPOS', 'GSUB', 'EBSC', 'JSTF', 'MATH', 'CBDT', 'CBLC', 'COLR', 'CPAL',
|
||||
'SVG ', 'sbix', 'acnt', 'avar', 'bdat', 'bloc', 'bsln', 'cvar', 'fdsc',
|
||||
'feat', 'fmtx', 'fvar', 'gvar', 'hsty', 'just', 'lcar', 'mort', 'morx',
|
||||
'opbd', 'prop', 'trak', 'Zapf', 'Silf', 'Glat', 'Gloc', 'Feat', 'Sill'
|
||||
];
|
||||
|
||||
let WOFF2DirectoryEntry = new r.Struct({
|
||||
flags: r.uint8,
|
||||
customTag: new r.Optional(new r.String(4), t => (t.flags & 0x3f) === 0x3f),
|
||||
tag: t => t.customTag || knownTags[t.flags & 0x3f],// || (() => { throw new Error(`Bad tag: ${flags & 0x3f}`); })(); },
|
||||
length: Base128,
|
||||
transformVersion: t => (t.flags >>> 6) & 0x03,
|
||||
transformed: t => (t.tag === 'glyf' || t.tag === 'loca') ? t.transformVersion === 0 : t.transformVersion !== 0,
|
||||
transformLength: new r.Optional(Base128, t => t.transformed)
|
||||
});
|
||||
|
||||
let WOFF2Directory = new r.Struct({
|
||||
tag: new r.String(4), // should be 'wOF2'
|
||||
flavor: r.uint32,
|
||||
length: r.uint32,
|
||||
numTables: r.uint16,
|
||||
reserved: new r.Reserved(r.uint16),
|
||||
totalSfntSize: r.uint32,
|
||||
totalCompressedSize: r.uint32,
|
||||
majorVersion: r.uint16,
|
||||
minorVersion: r.uint16,
|
||||
metaOffset: r.uint32,
|
||||
metaLength: r.uint32,
|
||||
metaOrigLength: r.uint32,
|
||||
privOffset: r.uint32,
|
||||
privLength: r.uint32,
|
||||
tables: new r.Array(WOFF2DirectoryEntry, 'numTables')
|
||||
});
|
||||
|
||||
WOFF2Directory.process = function() {
|
||||
let tables = {};
|
||||
for (let i = 0; i < this.tables.length; i++) {
|
||||
let table = this.tables[i];
|
||||
tables[table.tag] = table;
|
||||
}
|
||||
|
||||
return this.tables = tables;
|
||||
};
|
||||
|
||||
export default WOFF2Directory;
|
||||
38
node_modules/fontkit/src/tables/WOFFDirectory.js
generated
vendored
Normal file
38
node_modules/fontkit/src/tables/WOFFDirectory.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as r from 'restructure';
|
||||
import tables from './';
|
||||
|
||||
let WOFFDirectoryEntry = new r.Struct({
|
||||
tag: new r.String(4),
|
||||
offset: new r.Pointer(r.uint32, 'void', {type: 'global'}),
|
||||
compLength: r.uint32,
|
||||
length: r.uint32,
|
||||
origChecksum: r.uint32
|
||||
});
|
||||
|
||||
let WOFFDirectory = new r.Struct({
|
||||
tag: new r.String(4), // should be 'wOFF'
|
||||
flavor: r.uint32,
|
||||
length: r.uint32,
|
||||
numTables: r.uint16,
|
||||
reserved: new r.Reserved(r.uint16),
|
||||
totalSfntSize: r.uint32,
|
||||
majorVersion: r.uint16,
|
||||
minorVersion: r.uint16,
|
||||
metaOffset: r.uint32,
|
||||
metaLength: r.uint32,
|
||||
metaOrigLength: r.uint32,
|
||||
privOffset: r.uint32,
|
||||
privLength: r.uint32,
|
||||
tables: new r.Array(WOFFDirectoryEntry, 'numTables')
|
||||
});
|
||||
|
||||
WOFFDirectory.process = function() {
|
||||
let tables = {};
|
||||
for (let table of this.tables) {
|
||||
tables[table.tag] = table;
|
||||
}
|
||||
|
||||
this.tables = tables;
|
||||
};
|
||||
|
||||
export default WOFFDirectory;
|
||||
157
node_modules/fontkit/src/tables/aat.js
generated
vendored
Normal file
157
node_modules/fontkit/src/tables/aat.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
class UnboundedArrayAccessor {
|
||||
constructor(type, stream, parent) {
|
||||
this.type = type;
|
||||
this.stream = stream;
|
||||
this.parent = parent;
|
||||
this.base = this.stream.pos;
|
||||
this._items = [];
|
||||
}
|
||||
|
||||
getItem(index) {
|
||||
if (this._items[index] == null) {
|
||||
let pos = this.stream.pos;
|
||||
this.stream.pos = this.base + this.type.size(null, this.parent) * index;
|
||||
this._items[index] = this.type.decode(this.stream, this.parent);
|
||||
this.stream.pos = pos;
|
||||
}
|
||||
|
||||
return this._items[index];
|
||||
}
|
||||
|
||||
inspect() {
|
||||
return `[UnboundedArray ${this.type.constructor.name}]`;
|
||||
}
|
||||
}
|
||||
|
||||
export class UnboundedArray extends r.Array {
|
||||
constructor(type) {
|
||||
super(type, 0);
|
||||
}
|
||||
|
||||
decode(stream, parent) {
|
||||
return new UnboundedArrayAccessor(this.type, stream, parent);
|
||||
}
|
||||
}
|
||||
|
||||
export let LookupTable = function(ValueType = r.uint16) {
|
||||
// Helper class that makes internal structures invisible to pointers
|
||||
class Shadow {
|
||||
constructor(type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
decode(stream, ctx) {
|
||||
ctx = ctx.parent.parent;
|
||||
return this.type.decode(stream, ctx);
|
||||
}
|
||||
|
||||
size(val, ctx) {
|
||||
ctx = ctx.parent.parent;
|
||||
return this.type.size(val, ctx);
|
||||
}
|
||||
|
||||
encode(stream, val, ctx) {
|
||||
ctx = ctx.parent.parent;
|
||||
return this.type.encode(stream, val, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
ValueType = new Shadow(ValueType);
|
||||
|
||||
let BinarySearchHeader = new r.Struct({
|
||||
unitSize: r.uint16,
|
||||
nUnits: r.uint16,
|
||||
searchRange: r.uint16,
|
||||
entrySelector: r.uint16,
|
||||
rangeShift: r.uint16
|
||||
});
|
||||
|
||||
let LookupSegmentSingle = new r.Struct({
|
||||
lastGlyph: r.uint16,
|
||||
firstGlyph: r.uint16,
|
||||
value: ValueType
|
||||
});
|
||||
|
||||
let LookupSegmentArray = new r.Struct({
|
||||
lastGlyph: r.uint16,
|
||||
firstGlyph: r.uint16,
|
||||
values: new r.Pointer(r.uint16, new r.Array(ValueType, t => t.lastGlyph - t.firstGlyph + 1), {type: 'parent'})
|
||||
});
|
||||
|
||||
let LookupSingle = new r.Struct({
|
||||
glyph: r.uint16,
|
||||
value: ValueType
|
||||
});
|
||||
|
||||
return new r.VersionedStruct(r.uint16, {
|
||||
0: {
|
||||
values: new UnboundedArray(ValueType) // length == number of glyphs maybe?
|
||||
},
|
||||
2: {
|
||||
binarySearchHeader: BinarySearchHeader,
|
||||
segments: new r.Array(LookupSegmentSingle, t => t.binarySearchHeader.nUnits)
|
||||
},
|
||||
4: {
|
||||
binarySearchHeader: BinarySearchHeader,
|
||||
segments: new r.Array(LookupSegmentArray, t => t.binarySearchHeader.nUnits)
|
||||
},
|
||||
6: {
|
||||
binarySearchHeader: BinarySearchHeader,
|
||||
segments: new r.Array(LookupSingle, t => t.binarySearchHeader.nUnits)
|
||||
},
|
||||
8: {
|
||||
firstGlyph: r.uint16,
|
||||
count: r.uint16,
|
||||
values: new r.Array(ValueType, 'count')
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export function StateTable(entryData = {}, lookupType = r.uint16) {
|
||||
let entry = Object.assign({
|
||||
newState: r.uint16,
|
||||
flags: r.uint16
|
||||
}, entryData);
|
||||
|
||||
let Entry = new r.Struct(entry);
|
||||
let StateArray = new UnboundedArray(new r.Array(r.uint16, t => t.nClasses));
|
||||
|
||||
let StateHeader = new r.Struct({
|
||||
nClasses: r.uint32,
|
||||
classTable: new r.Pointer(r.uint32, new LookupTable(lookupType)),
|
||||
stateArray: new r.Pointer(r.uint32, StateArray),
|
||||
entryTable: new r.Pointer(r.uint32, new UnboundedArray(Entry))
|
||||
});
|
||||
|
||||
return StateHeader;
|
||||
}
|
||||
|
||||
// This is the old version of the StateTable structure
|
||||
export function StateTable1(entryData = {}, lookupType = r.uint16) {
|
||||
let ClassLookupTable = new r.Struct({
|
||||
version() { return 8; }, // simulate LookupTable
|
||||
firstGlyph: r.uint16,
|
||||
values: new r.Array(r.uint8, r.uint16)
|
||||
});
|
||||
|
||||
let entry = Object.assign({
|
||||
newStateOffset: r.uint16,
|
||||
// convert offset to stateArray index
|
||||
newState: t => (t.newStateOffset - (t.parent.stateArray.base - t.parent._startOffset)) / t.parent.nClasses,
|
||||
flags: r.uint16
|
||||
}, entryData);
|
||||
|
||||
let Entry = new r.Struct(entry);
|
||||
let StateArray = new UnboundedArray(new r.Array(r.uint8, t => t.nClasses));
|
||||
|
||||
let StateHeader1 = new r.Struct({
|
||||
nClasses: r.uint16,
|
||||
classTable: new r.Pointer(r.uint16, ClassLookupTable),
|
||||
stateArray: new r.Pointer(r.uint16, StateArray),
|
||||
entryTable: new r.Pointer(r.uint16, new UnboundedArray(Entry))
|
||||
});
|
||||
|
||||
return StateHeader1;
|
||||
}
|
||||
19
node_modules/fontkit/src/tables/avar.js
generated
vendored
Normal file
19
node_modules/fontkit/src/tables/avar.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let shortFrac = new r.Fixed(16, 'BE', 14);
|
||||
|
||||
let Correspondence = new r.Struct({
|
||||
fromCoord: shortFrac,
|
||||
toCoord: shortFrac
|
||||
});
|
||||
|
||||
let Segment = new r.Struct({
|
||||
pairCount: r.uint16,
|
||||
correspondence: new r.Array(Correspondence, 'pairCount')
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.fixed32,
|
||||
axisCount: r.uint32,
|
||||
segment: new r.Array(Segment, 'axisCount')
|
||||
});
|
||||
31
node_modules/fontkit/src/tables/bsln.js
generated
vendored
Normal file
31
node_modules/fontkit/src/tables/bsln.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import * as r from 'restructure';
|
||||
import { LookupTable } from './aat';
|
||||
|
||||
let BslnSubtable = new r.VersionedStruct('format', {
|
||||
0: { // Distance-based, no mapping
|
||||
deltas: new r.Array(r.int16, 32)
|
||||
},
|
||||
|
||||
1: { // Distance-based, with mapping
|
||||
deltas: new r.Array(r.int16, 32),
|
||||
mappingData: new LookupTable(r.uint16)
|
||||
},
|
||||
|
||||
2: { // Control point-based, no mapping
|
||||
standardGlyph: r.uint16,
|
||||
controlPoints: new r.Array(r.uint16, 32)
|
||||
},
|
||||
|
||||
3: { // Control point-based, with mapping
|
||||
standardGlyph: r.uint16,
|
||||
controlPoints: new r.Array(r.uint16, 32),
|
||||
mappingData: new LookupTable(r.uint16)
|
||||
}
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.fixed32,
|
||||
format: r.uint16,
|
||||
defaultBaseline: r.uint16,
|
||||
subtable: BslnSubtable
|
||||
});
|
||||
127
node_modules/fontkit/src/tables/cmap.js
generated
vendored
Normal file
127
node_modules/fontkit/src/tables/cmap.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let SubHeader = new r.Struct({
|
||||
firstCode: r.uint16,
|
||||
entryCount: r.uint16,
|
||||
idDelta: r.int16,
|
||||
idRangeOffset: r.uint16
|
||||
});
|
||||
|
||||
let CmapGroup = new r.Struct({
|
||||
startCharCode: r.uint32,
|
||||
endCharCode: r.uint32,
|
||||
glyphID: r.uint32
|
||||
});
|
||||
|
||||
let UnicodeValueRange = new r.Struct({
|
||||
startUnicodeValue: r.uint24,
|
||||
additionalCount: r.uint8
|
||||
});
|
||||
|
||||
let UVSMapping = new r.Struct({
|
||||
unicodeValue: r.uint24,
|
||||
glyphID: r.uint16
|
||||
});
|
||||
|
||||
let DefaultUVS = new r.Array(UnicodeValueRange, r.uint32);
|
||||
let NonDefaultUVS = new r.Array(UVSMapping, r.uint32);
|
||||
|
||||
let VarSelectorRecord = new r.Struct({
|
||||
varSelector: r.uint24,
|
||||
defaultUVS: new r.Pointer(r.uint32, DefaultUVS, {type: 'parent'}),
|
||||
nonDefaultUVS: new r.Pointer(r.uint32, NonDefaultUVS, {type: 'parent'})
|
||||
});
|
||||
|
||||
let CmapSubtable = new r.VersionedStruct(r.uint16, {
|
||||
0: { // Byte encoding
|
||||
length: r.uint16, // Total table length in bytes (set to 262 for format 0)
|
||||
language: r.uint16, // Language code for this encoding subtable, or zero if language-independent
|
||||
codeMap: new r.LazyArray(r.uint8, 256)
|
||||
},
|
||||
|
||||
2: { // High-byte mapping (CJK)
|
||||
length: r.uint16,
|
||||
language: r.uint16,
|
||||
subHeaderKeys: new r.Array(r.uint16, 256),
|
||||
subHeaderCount: t => Math.max.apply(Math, t.subHeaderKeys),
|
||||
subHeaders: new r.LazyArray(SubHeader, 'subHeaderCount'),
|
||||
glyphIndexArray: new r.LazyArray(r.uint16, 'subHeaderCount')
|
||||
},
|
||||
|
||||
4: { // Segment mapping to delta values
|
||||
length: r.uint16, // Total table length in bytes
|
||||
language: r.uint16, // Language code
|
||||
segCountX2: r.uint16,
|
||||
segCount: t => t.segCountX2 >> 1,
|
||||
searchRange: r.uint16,
|
||||
entrySelector: r.uint16,
|
||||
rangeShift: r.uint16,
|
||||
endCode: new r.LazyArray(r.uint16, 'segCount'),
|
||||
reservedPad: new r.Reserved(r.uint16), // This value should be zero
|
||||
startCode: new r.LazyArray(r.uint16, 'segCount'),
|
||||
idDelta: new r.LazyArray(r.int16, 'segCount'),
|
||||
idRangeOffset: new r.LazyArray(r.uint16, 'segCount'),
|
||||
glyphIndexArray: new r.LazyArray(r.uint16, t => (t.length - t._currentOffset) / 2)
|
||||
},
|
||||
|
||||
6: { // Trimmed table
|
||||
length: r.uint16,
|
||||
language: r.uint16,
|
||||
firstCode: r.uint16,
|
||||
entryCount: r.uint16,
|
||||
glyphIndices: new r.LazyArray(r.uint16, 'entryCount')
|
||||
},
|
||||
|
||||
8: { // mixed 16-bit and 32-bit coverage
|
||||
reserved: new r.Reserved(r.uint16),
|
||||
length: r.uint32,
|
||||
language: r.uint16,
|
||||
is32: new r.LazyArray(r.uint8, 8192),
|
||||
nGroups: r.uint32,
|
||||
groups: new r.LazyArray(CmapGroup, 'nGroups')
|
||||
},
|
||||
|
||||
10: { // Trimmed Array
|
||||
reserved: new r.Reserved(r.uint16),
|
||||
length: r.uint32,
|
||||
language: r.uint32,
|
||||
firstCode: r.uint32,
|
||||
entryCount: r.uint32,
|
||||
glyphIndices: new r.LazyArray(r.uint16, 'numChars')
|
||||
},
|
||||
|
||||
12: { // Segmented coverage
|
||||
reserved: new r.Reserved(r.uint16),
|
||||
length: r.uint32,
|
||||
language: r.uint32,
|
||||
nGroups: r.uint32,
|
||||
groups: new r.LazyArray(CmapGroup, 'nGroups')
|
||||
},
|
||||
|
||||
13: { // Many-to-one range mappings (same as 12 except for group.startGlyphID)
|
||||
reserved: new r.Reserved(r.uint16),
|
||||
length: r.uint32,
|
||||
language: r.uint32,
|
||||
nGroups: r.uint32,
|
||||
groups: new r.LazyArray(CmapGroup, 'nGroups')
|
||||
},
|
||||
|
||||
14: { // Unicode Variation Sequences
|
||||
length: r.uint32,
|
||||
numRecords: r.uint32,
|
||||
varSelectors: new r.LazyArray(VarSelectorRecord, 'numRecords')
|
||||
}
|
||||
});
|
||||
|
||||
let CmapEntry = new r.Struct({
|
||||
platformID: r.uint16, // Platform identifier
|
||||
encodingID: r.uint16, // Platform-specific encoding identifier
|
||||
table: new r.Pointer(r.uint32, CmapSubtable, {type: 'parent', lazy: true})
|
||||
});
|
||||
|
||||
// character to glyph mapping
|
||||
export default new r.Struct({
|
||||
version: r.uint16,
|
||||
numSubtables: r.uint16,
|
||||
tables: new r.Array(CmapEntry, 'numSubtables')
|
||||
});
|
||||
6
node_modules/fontkit/src/tables/cvt.js
generated
vendored
Normal file
6
node_modules/fontkit/src/tables/cvt.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// An array of predefined values accessible by instructions
|
||||
export default new r.Struct({
|
||||
controlValues: new r.Array(r.int16)
|
||||
});
|
||||
58
node_modules/fontkit/src/tables/directory.js
generated
vendored
Normal file
58
node_modules/fontkit/src/tables/directory.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import * as r from 'restructure';
|
||||
import Tables from './';
|
||||
|
||||
let TableEntry = new r.Struct({
|
||||
tag: new r.String(4),
|
||||
checkSum: r.uint32,
|
||||
offset: new r.Pointer(r.uint32, 'void', { type: 'global' }),
|
||||
length: r.uint32
|
||||
});
|
||||
|
||||
let Directory = new r.Struct({
|
||||
tag: new r.String(4),
|
||||
numTables: r.uint16,
|
||||
searchRange: r.uint16,
|
||||
entrySelector: r.uint16,
|
||||
rangeShift: r.uint16,
|
||||
tables: new r.Array(TableEntry, 'numTables')
|
||||
});
|
||||
|
||||
Directory.process = function() {
|
||||
let tables = {};
|
||||
for (let table of this.tables) {
|
||||
tables[table.tag] = table;
|
||||
}
|
||||
|
||||
this.tables = tables;
|
||||
};
|
||||
|
||||
Directory.preEncode = function() {
|
||||
if (!Array.isArray(this.tables)) {
|
||||
let tables = [];
|
||||
for (let tag in this.tables) {
|
||||
let table = this.tables[tag];
|
||||
if (table) {
|
||||
tables.push({
|
||||
tag: tag,
|
||||
checkSum: 0,
|
||||
offset: new r.VoidPointer(Tables[tag], table),
|
||||
length: Tables[tag].size(table)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.tables = tables;
|
||||
}
|
||||
|
||||
this.tag = 'true';
|
||||
this.numTables = this.tables.length;
|
||||
|
||||
let maxExponentFor2 = Math.floor((Math.log(this.numTables) / Math.LN2));
|
||||
let maxPowerOf2 = Math.pow(2, maxExponentFor2);
|
||||
|
||||
this.searchRange = maxPowerOf2 * 16;
|
||||
this.entrySelector = Math.log(maxPowerOf2) / Math.LN2;
|
||||
this.rangeShift = this.numTables * 16 - this.searchRange;
|
||||
};
|
||||
|
||||
export default Directory;
|
||||
28
node_modules/fontkit/src/tables/feat.js
generated
vendored
Normal file
28
node_modules/fontkit/src/tables/feat.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let Setting = new r.Struct({
|
||||
setting: r.uint16,
|
||||
nameIndex: r.int16,
|
||||
name: t => t.parent.parent.parent.name.records.fontFeatures[t.nameIndex]
|
||||
});
|
||||
|
||||
let FeatureName = new r.Struct({
|
||||
feature: r.uint16,
|
||||
nSettings: r.uint16,
|
||||
settingTable: new r.Pointer(r.uint32, new r.Array(Setting, 'nSettings'), { type: 'parent' }),
|
||||
featureFlags: new r.Bitfield(r.uint8, [
|
||||
null, null, null, null, null, null,
|
||||
'hasDefault', 'exclusive'
|
||||
]),
|
||||
defaultSetting: r.uint8,
|
||||
nameIndex: r.int16,
|
||||
name: t => t.parent.parent.name.records.fontFeatures[t.nameIndex]
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.fixed32,
|
||||
featureNameCount: r.uint16,
|
||||
reserved1: new r.Reserved(r.uint16),
|
||||
reserved2: new r.Reserved(r.uint32),
|
||||
featureNames: new r.Array(FeatureName, 'featureNameCount')
|
||||
});
|
||||
8
node_modules/fontkit/src/tables/fpgm.js
generated
vendored
Normal file
8
node_modules/fontkit/src/tables/fpgm.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// A list of instructions that are executed once when a font is first used.
|
||||
// These instructions are known as the font program. The main use of this table
|
||||
// is for the definition of functions that are used in many different glyph programs.
|
||||
export default new r.Struct({
|
||||
instructions: new r.Array(r.uint8)
|
||||
});
|
||||
31
node_modules/fontkit/src/tables/fvar.js
generated
vendored
Normal file
31
node_modules/fontkit/src/tables/fvar.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let Axis = new r.Struct({
|
||||
axisTag: new r.String(4),
|
||||
minValue: r.fixed32,
|
||||
defaultValue: r.fixed32,
|
||||
maxValue: r.fixed32,
|
||||
flags: r.uint16,
|
||||
nameID: r.uint16,
|
||||
name: t => t.parent.parent.name.records.fontFeatures[t.nameID]
|
||||
});
|
||||
|
||||
let Instance = new r.Struct({
|
||||
nameID: r.uint16,
|
||||
name: t => t.parent.parent.name.records.fontFeatures[t.nameID],
|
||||
flags: r.uint16,
|
||||
coord: new r.Array(r.fixed32, t => t.parent.axisCount),
|
||||
postscriptNameID: new r.Optional(r.uint16, t => t.parent.instanceSize - t._currentOffset > 0)
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.fixed32,
|
||||
offsetToData: r.uint16,
|
||||
countSizePairs: r.uint16,
|
||||
axisCount: r.uint16,
|
||||
axisSize: r.uint16,
|
||||
instanceCount: r.uint16,
|
||||
instanceSize: r.uint16,
|
||||
axis: new r.Array(Axis, 'axisCount'),
|
||||
instance: new r.Array(Instance, 'instanceCount')
|
||||
});
|
||||
15
node_modules/fontkit/src/tables/gasp.js
generated
vendored
Normal file
15
node_modules/fontkit/src/tables/gasp.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let GaspRange = new r.Struct({
|
||||
rangeMaxPPEM: r.uint16, // Upper limit of range, in ppem
|
||||
rangeGaspBehavior: new r.Bitfield(r.uint16, [ // Flags describing desired rasterizer behavior
|
||||
'grayscale', 'gridfit',
|
||||
'symmetricSmoothing', 'symmetricGridfit' // only in version 1, for ClearType
|
||||
])
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.uint16, // set to 0
|
||||
numRanges: r.uint16,
|
||||
gaspRanges: new r.Array(GaspRange, 'numRanges') // Sorted by ppem
|
||||
});
|
||||
4
node_modules/fontkit/src/tables/glyf.js
generated
vendored
Normal file
4
node_modules/fontkit/src/tables/glyf.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// only used for encoding
|
||||
export default new r.Array(new r.Buffer);
|
||||
27
node_modules/fontkit/src/tables/gvar.js
generated
vendored
Normal file
27
node_modules/fontkit/src/tables/gvar.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let shortFrac = new r.Fixed(16, 'BE', 14);
|
||||
class Offset {
|
||||
static decode(stream, parent) {
|
||||
// In short format, offsets are multiplied by 2.
|
||||
// This doesn't seem to be documented by Apple, but it
|
||||
// is implemented this way in Freetype.
|
||||
return parent.flags
|
||||
? stream.readUInt32BE()
|
||||
: stream.readUInt16BE() * 2;
|
||||
}
|
||||
}
|
||||
|
||||
let gvar = new r.Struct({
|
||||
version: r.uint16,
|
||||
reserved: new r.Reserved(r.uint16),
|
||||
axisCount: r.uint16,
|
||||
globalCoordCount: r.uint16,
|
||||
globalCoords: new r.Pointer(r.uint32, new r.Array(new r.Array(shortFrac, 'axisCount'), 'globalCoordCount')),
|
||||
glyphCount: r.uint16,
|
||||
flags: r.uint16,
|
||||
offsetToData: r.uint32,
|
||||
offsets: new r.Array(new r.Pointer(Offset, 'void', { relativeTo: ctx => ctx.offsetToData, allowNull: false }), t => t.glyphCount + 1)
|
||||
});
|
||||
|
||||
export default gvar;
|
||||
15
node_modules/fontkit/src/tables/hdmx.js
generated
vendored
Normal file
15
node_modules/fontkit/src/tables/hdmx.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let DeviceRecord = new r.Struct({
|
||||
pixelSize: r.uint8,
|
||||
maximumWidth: r.uint8,
|
||||
widths: new r.Array(r.uint8, t => t.parent.parent.maxp.numGlyphs)
|
||||
});
|
||||
|
||||
// The Horizontal Device Metrics table stores integer advance widths scaled to particular pixel sizes
|
||||
export default new r.Struct({
|
||||
version: r.uint16,
|
||||
numRecords: r.int16,
|
||||
sizeDeviceRecord: r.int32,
|
||||
records: new r.Array(DeviceRecord, 'numRecords')
|
||||
});
|
||||
25
node_modules/fontkit/src/tables/head.js
generated
vendored
Normal file
25
node_modules/fontkit/src/tables/head.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// font header
|
||||
export default new r.Struct({
|
||||
version: r.int32, // 0x00010000 (version 1.0)
|
||||
revision: r.int32, // set by font manufacturer
|
||||
checkSumAdjustment: r.uint32,
|
||||
magicNumber: r.uint32, // set to 0x5F0F3CF5
|
||||
flags: r.uint16,
|
||||
unitsPerEm: r.uint16, // range from 64 to 16384
|
||||
created: new r.Array(r.int32, 2),
|
||||
modified: new r.Array(r.int32, 2),
|
||||
xMin: r.int16, // for all glyph bounding boxes
|
||||
yMin: r.int16, // for all glyph bounding boxes
|
||||
xMax: r.int16, // for all glyph bounding boxes
|
||||
yMax: r.int16, // for all glyph bounding boxes
|
||||
macStyle: new r.Bitfield(r.uint16, [
|
||||
'bold', 'italic', 'underline', 'outline',
|
||||
'shadow', 'condensed', 'extended'
|
||||
]),
|
||||
lowestRecPPEM: r.uint16, // smallest readable size in pixels
|
||||
fontDirectionHint: r.int16,
|
||||
indexToLocFormat: r.int16, // 0 for short offsets, 1 for long
|
||||
glyphDataFormat: r.int16 // 0 for current format
|
||||
});
|
||||
19
node_modules/fontkit/src/tables/hhea.js
generated
vendored
Normal file
19
node_modules/fontkit/src/tables/hhea.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// horizontal header
|
||||
export default new r.Struct({
|
||||
version: r.int32,
|
||||
ascent: r.int16, // Distance from baseline of highest ascender
|
||||
descent: r.int16, // Distance from baseline of lowest descender
|
||||
lineGap: r.int16, // Typographic line gap
|
||||
advanceWidthMax: r.uint16, // Maximum advance width value in 'hmtx' table
|
||||
minLeftSideBearing: r.int16, // Maximum advance width value in 'hmtx' table
|
||||
minRightSideBearing: r.int16, // Minimum right sidebearing value
|
||||
xMaxExtent: r.int16,
|
||||
caretSlopeRise: r.int16, // Used to calculate the slope of the cursor (rise/run); 1 for vertical
|
||||
caretSlopeRun: r.int16, // 0 for vertical
|
||||
caretOffset: r.int16, // Set to 0 for non-slanted fonts
|
||||
reserved: new r.Reserved(r.int16, 4),
|
||||
metricDataFormat: r.int16, // 0 for current format
|
||||
numberOfMetrics: r.uint16 // Number of advance widths in 'hmtx' table
|
||||
});
|
||||
11
node_modules/fontkit/src/tables/hmtx.js
generated
vendored
Normal file
11
node_modules/fontkit/src/tables/hmtx.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let HmtxEntry = new r.Struct({
|
||||
advance: r.uint16,
|
||||
bearing: r.int16
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
metrics: new r.LazyArray(HmtxEntry, t => t.parent.hhea.numberOfMetrics),
|
||||
bearings: new r.LazyArray(r.int16, t => t.parent.maxp.numGlyphs - t.parent.hhea.numberOfMetrics)
|
||||
});
|
||||
117
node_modules/fontkit/src/tables/index.js
generated
vendored
Normal file
117
node_modules/fontkit/src/tables/index.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
let tables = {};
|
||||
export default tables;
|
||||
|
||||
// Required Tables
|
||||
import cmap from './cmap';
|
||||
import head from './head';
|
||||
import hhea from './hhea';
|
||||
import hmtx from './hmtx';
|
||||
import maxp from './maxp';
|
||||
import name from './name';
|
||||
import OS2 from './OS2';
|
||||
import post from './post';
|
||||
|
||||
tables.cmap = cmap;
|
||||
tables.head = head;
|
||||
tables.hhea = hhea;
|
||||
tables.hmtx = hmtx;
|
||||
tables.maxp = maxp;
|
||||
tables.name = name;
|
||||
tables['OS/2'] = OS2;
|
||||
tables.post = post;
|
||||
|
||||
|
||||
// TrueType Outlines
|
||||
import cvt from './cvt';
|
||||
import fpgm from './fpgm';
|
||||
import loca from './loca';
|
||||
import prep from './prep';
|
||||
import glyf from './glyf';
|
||||
|
||||
tables.fpgm = fpgm;
|
||||
tables.loca = loca;
|
||||
tables.prep = prep;
|
||||
tables['cvt '] = cvt;
|
||||
tables.glyf = glyf;
|
||||
|
||||
|
||||
// PostScript Outlines
|
||||
import CFFFont from '../cff/CFFFont';
|
||||
import VORG from './VORG';
|
||||
|
||||
tables['CFF '] = CFFFont;
|
||||
tables['CFF2'] = CFFFont;
|
||||
tables.VORG = VORG;
|
||||
|
||||
|
||||
// Bitmap Glyphs
|
||||
import EBLC from './EBLC';
|
||||
import sbix from './sbix';
|
||||
import COLR from './COLR';
|
||||
import CPAL from './CPAL';
|
||||
|
||||
tables.EBLC = EBLC;
|
||||
tables.CBLC = tables.EBLC;
|
||||
tables.sbix = sbix;
|
||||
tables.COLR = COLR;
|
||||
tables.CPAL = CPAL;
|
||||
|
||||
|
||||
// Advanced OpenType Tables
|
||||
import BASE from './BASE';
|
||||
import GDEF from './GDEF';
|
||||
import GPOS from './GPOS';
|
||||
import GSUB from './GSUB';
|
||||
import JSTF from './JSTF';
|
||||
|
||||
tables.BASE = BASE;
|
||||
tables.GDEF = GDEF;
|
||||
tables.GPOS = GPOS;
|
||||
tables.GSUB = GSUB;
|
||||
tables.JSTF = JSTF;
|
||||
|
||||
// OpenType variations tables
|
||||
import HVAR from './HVAR';
|
||||
|
||||
tables.HVAR = HVAR;
|
||||
|
||||
// Other OpenType Tables
|
||||
import DSIG from './DSIG';
|
||||
import gasp from './gasp';
|
||||
import hdmx from './hdmx';
|
||||
import kern from './kern';
|
||||
import LTSH from './LTSH';
|
||||
import PCLT from './PCLT';
|
||||
import VDMX from './VDMX';
|
||||
import vhea from './vhea';
|
||||
import vmtx from './vmtx';
|
||||
|
||||
tables.DSIG = DSIG;
|
||||
tables.gasp = gasp;
|
||||
tables.hdmx = hdmx;
|
||||
tables.kern = kern;
|
||||
tables.LTSH = LTSH;
|
||||
tables.PCLT = PCLT;
|
||||
tables.VDMX = VDMX;
|
||||
tables.vhea = vhea;
|
||||
tables.vmtx = vmtx;
|
||||
|
||||
|
||||
// Apple Advanced Typography Tables
|
||||
import avar from './avar';
|
||||
import bsln from './bsln';
|
||||
import feat from './feat';
|
||||
import fvar from './fvar';
|
||||
import gvar from './gvar';
|
||||
import just from './just';
|
||||
import morx from './morx';
|
||||
import opbd from './opbd';
|
||||
|
||||
tables.avar = avar;
|
||||
tables.bsln = bsln;
|
||||
tables.feat = feat;
|
||||
tables.fvar = fvar;
|
||||
tables.gvar = gvar;
|
||||
tables.just = just;
|
||||
tables.morx = morx;
|
||||
tables.opbd = opbd;
|
||||
81
node_modules/fontkit/src/tables/just.js
generated
vendored
Normal file
81
node_modules/fontkit/src/tables/just.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
import * as r from 'restructure';
|
||||
import { LookupTable, StateTable1 } from './aat';
|
||||
|
||||
let ClassTable = new r.Struct({
|
||||
length: r.uint16,
|
||||
coverage: r.uint16,
|
||||
subFeatureFlags: r.uint32,
|
||||
stateTable: new StateTable1
|
||||
});
|
||||
|
||||
let WidthDeltaRecord = new r.Struct({
|
||||
justClass: r.uint32,
|
||||
beforeGrowLimit: r.fixed32,
|
||||
beforeShrinkLimit: r.fixed32,
|
||||
afterGrowLimit: r.fixed32,
|
||||
afterShrinkLimit: r.fixed32,
|
||||
growFlags: r.uint16,
|
||||
shrinkFlags: r.uint16
|
||||
});
|
||||
|
||||
let WidthDeltaCluster = new r.Array(WidthDeltaRecord, r.uint32);
|
||||
|
||||
let ActionData = new r.VersionedStruct('actionType', {
|
||||
0: { // Decomposition action
|
||||
lowerLimit: r.fixed32,
|
||||
upperLimit: r.fixed32,
|
||||
order: r.uint16,
|
||||
glyphs: new r.Array(r.uint16, r.uint16)
|
||||
},
|
||||
|
||||
1: { // Unconditional add glyph action
|
||||
addGlyph: r.uint16
|
||||
},
|
||||
|
||||
2: { // Conditional add glyph action
|
||||
substThreshold: r.fixed32,
|
||||
addGlyph: r.uint16,
|
||||
substGlyph: r.uint16
|
||||
},
|
||||
|
||||
3: {}, // Stretch glyph action (no data, not supported by CoreText)
|
||||
|
||||
4: { // Ductile glyph action (not supported by CoreText)
|
||||
variationAxis: r.uint32,
|
||||
minimumLimit: r.fixed32,
|
||||
noStretchValue: r.fixed32,
|
||||
maximumLimit: r.fixed32
|
||||
},
|
||||
|
||||
5: { // Repeated add glyph action
|
||||
flags: r.uint16,
|
||||
glyph: r.uint16
|
||||
}
|
||||
});
|
||||
|
||||
let Action = new r.Struct({
|
||||
actionClass: r.uint16,
|
||||
actionType: r.uint16,
|
||||
actionLength: r.uint32,
|
||||
actionData: ActionData,
|
||||
padding: new r.Reserved(r.uint8, t => t.actionLength - t._currentOffset)
|
||||
});
|
||||
|
||||
let PostcompensationAction = new r.Array(Action, r.uint32);
|
||||
let PostCompensationTable = new r.Struct({
|
||||
lookupTable: new LookupTable(new r.Pointer(r.uint16, PostcompensationAction))
|
||||
});
|
||||
|
||||
let JustificationTable = new r.Struct({
|
||||
classTable: new r.Pointer(r.uint16, ClassTable, { type: 'parent' }),
|
||||
wdcOffset: r.uint16,
|
||||
postCompensationTable: new r.Pointer(r.uint16, PostCompensationTable, { type: 'parent' }),
|
||||
widthDeltaClusters: new LookupTable(new r.Pointer(r.uint16, WidthDeltaCluster, { type: 'parent', relativeTo: ctx => ctx.wdcOffset }))
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.uint32,
|
||||
format: r.uint16,
|
||||
horizontal: new r.Pointer(r.uint16, JustificationTable),
|
||||
vertical: new r.Pointer(r.uint16, JustificationTable)
|
||||
});
|
||||
91
node_modules/fontkit/src/tables/kern.js
generated
vendored
Normal file
91
node_modules/fontkit/src/tables/kern.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let KernPair = new r.Struct({
|
||||
left: r.uint16,
|
||||
right: r.uint16,
|
||||
value: r.int16
|
||||
});
|
||||
|
||||
let ClassTable = new r.Struct({
|
||||
firstGlyph: r.uint16,
|
||||
nGlyphs: r.uint16,
|
||||
offsets: new r.Array(r.uint16, 'nGlyphs'),
|
||||
max: t => t.offsets.length && Math.max.apply(Math, t.offsets)
|
||||
});
|
||||
|
||||
let Kern2Array = new r.Struct({
|
||||
off: t => t._startOffset - t.parent.parent._startOffset,
|
||||
len: t => (((t.parent.leftTable.max - t.off) / t.parent.rowWidth) + 1) * (t.parent.rowWidth / 2),
|
||||
values: new r.LazyArray(r.int16, 'len')
|
||||
});
|
||||
|
||||
let KernSubtable = new r.VersionedStruct('format', {
|
||||
0: {
|
||||
nPairs: r.uint16,
|
||||
searchRange: r.uint16,
|
||||
entrySelector: r.uint16,
|
||||
rangeShift: r.uint16,
|
||||
pairs: new r.Array(KernPair, 'nPairs')
|
||||
},
|
||||
|
||||
2: {
|
||||
rowWidth: r.uint16,
|
||||
leftTable: new r.Pointer(r.uint16, ClassTable, {type: 'parent'}),
|
||||
rightTable: new r.Pointer(r.uint16, ClassTable, {type: 'parent'}),
|
||||
array: new r.Pointer(r.uint16, Kern2Array, {type: 'parent'})
|
||||
},
|
||||
|
||||
3: {
|
||||
glyphCount: r.uint16,
|
||||
kernValueCount: r.uint8,
|
||||
leftClassCount: r.uint8,
|
||||
rightClassCount: r.uint8,
|
||||
flags: r.uint8,
|
||||
kernValue: new r.Array(r.int16, 'kernValueCount'),
|
||||
leftClass: new r.Array(r.uint8, 'glyphCount'),
|
||||
rightClass: new r.Array(r.uint8, 'glyphCount'),
|
||||
kernIndex: new r.Array(r.uint8, t => t.leftClassCount * t.rightClassCount)
|
||||
}
|
||||
});
|
||||
|
||||
let KernTable = new r.VersionedStruct('version', {
|
||||
0: { // Microsoft uses this format
|
||||
subVersion: r.uint16, // Microsoft has an extra sub-table version number
|
||||
length: r.uint16, // Length of the subtable, in bytes
|
||||
format: r.uint8, // Format of subtable
|
||||
coverage: new r.Bitfield(r.uint8, [
|
||||
'horizontal', // 1 if table has horizontal data, 0 if vertical
|
||||
'minimum', // If set to 1, the table has minimum values. If set to 0, the table has kerning values.
|
||||
'crossStream', // If set to 1, kerning is perpendicular to the flow of the text
|
||||
'override' // If set to 1 the value in this table replaces the accumulated value
|
||||
]),
|
||||
subtable: KernSubtable,
|
||||
padding: new r.Reserved(r.uint8, t => t.length - t._currentOffset)
|
||||
},
|
||||
1: { // Apple uses this format
|
||||
length: r.uint32,
|
||||
coverage: new r.Bitfield(r.uint8, [
|
||||
null, null, null, null, null,
|
||||
'variation', // Set if table has variation kerning values
|
||||
'crossStream', // Set if table has cross-stream kerning values
|
||||
'vertical' // Set if table has vertical kerning values
|
||||
]),
|
||||
format: r.uint8,
|
||||
tupleIndex: r.uint16,
|
||||
subtable: KernSubtable,
|
||||
padding: new r.Reserved(r.uint8, t => t.length - t._currentOffset)
|
||||
}
|
||||
});
|
||||
|
||||
export default new r.VersionedStruct(r.uint16, {
|
||||
0: { // Microsoft Version
|
||||
nTables: r.uint16,
|
||||
tables: new r.Array(KernTable, 'nTables')
|
||||
},
|
||||
|
||||
1: { // Apple Version
|
||||
reserved: new r.Reserved(r.uint16), // the other half of the version number
|
||||
nTables: r.uint32,
|
||||
tables: new r.Array(KernTable, 'nTables')
|
||||
}
|
||||
});
|
||||
30
node_modules/fontkit/src/tables/loca.js
generated
vendored
Normal file
30
node_modules/fontkit/src/tables/loca.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let loca = new r.VersionedStruct('head.indexToLocFormat', {
|
||||
0: {
|
||||
offsets: new r.Array(r.uint16)
|
||||
},
|
||||
1: {
|
||||
offsets: new r.Array(r.uint32)
|
||||
}
|
||||
});
|
||||
|
||||
loca.process = function() {
|
||||
if (this.version === 0 && !this._processed) {
|
||||
for (let i = 0; i < this.offsets.length; i++) {
|
||||
this.offsets[i] <<= 1;
|
||||
}
|
||||
this._processed = true;
|
||||
}
|
||||
};
|
||||
|
||||
loca.preEncode = function() {
|
||||
if (this.version === 0 && this._processed !== false) {
|
||||
for (let i = 0; i < this.offsets.length; i++) {
|
||||
this.offsets[i] >>>= 1;
|
||||
}
|
||||
this._processed = false;
|
||||
}
|
||||
};
|
||||
|
||||
export default loca;
|
||||
20
node_modules/fontkit/src/tables/maxp.js
generated
vendored
Normal file
20
node_modules/fontkit/src/tables/maxp.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// maxiumum profile
|
||||
export default new r.Struct({
|
||||
version: r.int32,
|
||||
numGlyphs: r.uint16, // The number of glyphs in the font
|
||||
maxPoints: r.uint16, // Maximum points in a non-composite glyph
|
||||
maxContours: r.uint16, // Maximum contours in a non-composite glyph
|
||||
maxComponentPoints: r.uint16, // Maximum points in a composite glyph
|
||||
maxComponentContours: r.uint16, // Maximum contours in a composite glyph
|
||||
maxZones: r.uint16, // 1 if instructions do not use the twilight zone, 2 otherwise
|
||||
maxTwilightPoints: r.uint16, // Maximum points used in Z0
|
||||
maxStorage: r.uint16, // Number of Storage Area locations
|
||||
maxFunctionDefs: r.uint16, // Number of FDEFs
|
||||
maxInstructionDefs: r.uint16, // Number of IDEFs
|
||||
maxStackElements: r.uint16, // Maximum stack depth
|
||||
maxSizeOfInstructions: r.uint16, // Maximum byte count for glyph instructions
|
||||
maxComponentElements: r.uint16, // Maximum number of components referenced at “top level” for any composite glyph
|
||||
maxComponentDepth: r.uint16 // Maximum levels of recursion; 1 for simple components
|
||||
});
|
||||
79
node_modules/fontkit/src/tables/morx.js
generated
vendored
Normal file
79
node_modules/fontkit/src/tables/morx.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
import * as r from 'restructure';
|
||||
import { UnboundedArray, LookupTable, StateTable } from './aat';
|
||||
|
||||
let LigatureData = {
|
||||
action: r.uint16
|
||||
};
|
||||
|
||||
let ContextualData = {
|
||||
markIndex: r.uint16,
|
||||
currentIndex: r.uint16
|
||||
};
|
||||
|
||||
let InsertionData = {
|
||||
currentInsertIndex: r.uint16,
|
||||
markedInsertIndex: r.uint16
|
||||
};
|
||||
|
||||
let SubstitutionTable = new r.Struct({
|
||||
items: new UnboundedArray(new r.Pointer(r.uint32, new LookupTable))
|
||||
});
|
||||
|
||||
let SubtableData = new r.VersionedStruct('type', {
|
||||
0: { // Indic Rearrangement Subtable
|
||||
stateTable: new StateTable
|
||||
},
|
||||
|
||||
1: { // Contextual Glyph Substitution Subtable
|
||||
stateTable: new StateTable(ContextualData),
|
||||
substitutionTable: new r.Pointer(r.uint32, SubstitutionTable)
|
||||
},
|
||||
|
||||
2: { // Ligature subtable
|
||||
stateTable: new StateTable(LigatureData),
|
||||
ligatureActions: new r.Pointer(r.uint32, new UnboundedArray(r.uint32)),
|
||||
components: new r.Pointer(r.uint32, new UnboundedArray(r.uint16)),
|
||||
ligatureList: new r.Pointer(r.uint32, new UnboundedArray(r.uint16))
|
||||
},
|
||||
|
||||
4: { // Non-contextual Glyph Substitution Subtable
|
||||
lookupTable: new LookupTable
|
||||
},
|
||||
|
||||
5: { // Glyph Insertion Subtable
|
||||
stateTable: new StateTable(InsertionData),
|
||||
insertionActions: new r.Pointer(r.uint32, new UnboundedArray(r.uint16))
|
||||
}
|
||||
});
|
||||
|
||||
let Subtable = new r.Struct({
|
||||
length: r.uint32,
|
||||
coverage: r.uint24,
|
||||
type: r.uint8,
|
||||
subFeatureFlags: r.uint32,
|
||||
table: SubtableData,
|
||||
padding: new r.Reserved(r.uint8, t => t.length - t._currentOffset)
|
||||
});
|
||||
|
||||
let FeatureEntry = new r.Struct({
|
||||
featureType: r.uint16,
|
||||
featureSetting: r.uint16,
|
||||
enableFlags: r.uint32,
|
||||
disableFlags: r.uint32
|
||||
});
|
||||
|
||||
let MorxChain = new r.Struct({
|
||||
defaultFlags: r.uint32,
|
||||
chainLength: r.uint32,
|
||||
nFeatureEntries: r.uint32,
|
||||
nSubtables: r.uint32,
|
||||
features: new r.Array(FeatureEntry, 'nFeatureEntries'),
|
||||
subtables: new r.Array(Subtable, 'nSubtables')
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.uint16,
|
||||
unused: new r.Reserved(r.uint16),
|
||||
nChains: r.uint32,
|
||||
chains: new r.Array(MorxChain, 'nChains')
|
||||
});
|
||||
130
node_modules/fontkit/src/tables/name.js
generated
vendored
Normal file
130
node_modules/fontkit/src/tables/name.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
import * as r from 'restructure';
|
||||
import {getEncoding, LANGUAGES} from '../encodings';
|
||||
|
||||
let NameRecord = new r.Struct({
|
||||
platformID: r.uint16,
|
||||
encodingID: r.uint16,
|
||||
languageID: r.uint16,
|
||||
nameID: r.uint16,
|
||||
length: r.uint16,
|
||||
string: new r.Pointer(r.uint16,
|
||||
new r.String('length', t => getEncoding(t.platformID, t.encodingID, t.languageID)),
|
||||
{ type: 'parent', relativeTo: ctx => ctx.parent.stringOffset, allowNull: false }
|
||||
)
|
||||
});
|
||||
|
||||
let LangTagRecord = new r.Struct({
|
||||
length: r.uint16,
|
||||
tag: new r.Pointer(r.uint16, new r.String('length', 'utf16be'), {type: 'parent', relativeTo: ctx => ctx.stringOffset})
|
||||
});
|
||||
|
||||
var NameTable = new r.VersionedStruct(r.uint16, {
|
||||
0: {
|
||||
count: r.uint16,
|
||||
stringOffset: r.uint16,
|
||||
records: new r.Array(NameRecord, 'count')
|
||||
},
|
||||
1: {
|
||||
count: r.uint16,
|
||||
stringOffset: r.uint16,
|
||||
records: new r.Array(NameRecord, 'count'),
|
||||
langTagCount: r.uint16,
|
||||
langTags: new r.Array(LangTagRecord, 'langTagCount')
|
||||
}
|
||||
});
|
||||
|
||||
export default NameTable;
|
||||
|
||||
const NAMES = [
|
||||
'copyright',
|
||||
'fontFamily',
|
||||
'fontSubfamily',
|
||||
'uniqueSubfamily',
|
||||
'fullName',
|
||||
'version',
|
||||
'postscriptName', // Note: A font may have only one PostScript name and that name must be ASCII.
|
||||
'trademark',
|
||||
'manufacturer',
|
||||
'designer',
|
||||
'description',
|
||||
'vendorURL',
|
||||
'designerURL',
|
||||
'license',
|
||||
'licenseURL',
|
||||
null, // reserved
|
||||
'preferredFamily',
|
||||
'preferredSubfamily',
|
||||
'compatibleFull',
|
||||
'sampleText',
|
||||
'postscriptCIDFontName',
|
||||
'wwsFamilyName',
|
||||
'wwsSubfamilyName'
|
||||
];
|
||||
|
||||
NameTable.process = function(stream) {
|
||||
var records = {};
|
||||
for (let record of this.records) {
|
||||
// find out what language this is for
|
||||
let language = LANGUAGES[record.platformID][record.languageID];
|
||||
|
||||
if (language == null && this.langTags != null && record.languageID >= 0x8000) {
|
||||
language = this.langTags[record.languageID - 0x8000].tag;
|
||||
}
|
||||
|
||||
if (language == null) {
|
||||
language = record.platformID + '-' + record.languageID;
|
||||
}
|
||||
|
||||
// if the nameID is >= 256, it is a font feature record (AAT)
|
||||
let key = record.nameID >= 256 ? 'fontFeatures' : (NAMES[record.nameID] || record.nameID);
|
||||
if (records[key] == null) {
|
||||
records[key] = {};
|
||||
}
|
||||
|
||||
let obj = records[key];
|
||||
if (record.nameID >= 256) {
|
||||
obj = obj[record.nameID] || (obj[record.nameID] = {});
|
||||
}
|
||||
|
||||
if (typeof record.string === 'string' || typeof obj[language] !== 'string') {
|
||||
obj[language] = record.string;
|
||||
}
|
||||
}
|
||||
|
||||
this.records = records;
|
||||
};
|
||||
|
||||
NameTable.preEncode = function() {
|
||||
if (Array.isArray(this.records)) return;
|
||||
this.version = 0;
|
||||
|
||||
let records = [];
|
||||
for (let key in this.records) {
|
||||
let val = this.records[key];
|
||||
if (key === 'fontFeatures') continue;
|
||||
|
||||
records.push({
|
||||
platformID: 3,
|
||||
encodingID: 1,
|
||||
languageID: 0x409,
|
||||
nameID: NAMES.indexOf(key),
|
||||
length: val.en.length * 2,
|
||||
string: val.en
|
||||
});
|
||||
|
||||
if (key === 'postscriptName') {
|
||||
records.push({
|
||||
platformID: 1,
|
||||
encodingID: 0,
|
||||
languageID: 0,
|
||||
nameID: NAMES.indexOf(key),
|
||||
length: val.en.length,
|
||||
string: val.en
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.records = records;
|
||||
this.count = records.length;
|
||||
this.stringOffset = NameTable.size(this, null, false);
|
||||
};
|
||||
15
node_modules/fontkit/src/tables/opbd.js
generated
vendored
Normal file
15
node_modules/fontkit/src/tables/opbd.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as r from 'restructure';
|
||||
import { LookupTable } from './aat';
|
||||
|
||||
let OpticalBounds = new r.Struct({
|
||||
left: r.int16,
|
||||
top: r.int16,
|
||||
right: r.int16,
|
||||
bottom: r.int16
|
||||
});
|
||||
|
||||
export default new r.Struct({
|
||||
version: r.fixed32,
|
||||
format: r.uint16,
|
||||
lookupTable: new LookupTable(OpticalBounds)
|
||||
});
|
||||
217
node_modules/fontkit/src/tables/opentype.js
generated
vendored
Normal file
217
node_modules/fontkit/src/tables/opentype.js
generated
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
//########################
|
||||
// Scripts and Languages #
|
||||
//########################
|
||||
|
||||
let LangSysTable = new r.Struct({
|
||||
reserved: new r.Reserved(r.uint16),
|
||||
reqFeatureIndex: r.uint16,
|
||||
featureCount: r.uint16,
|
||||
featureIndexes: new r.Array(r.uint16, 'featureCount')
|
||||
});
|
||||
|
||||
let LangSysRecord = new r.Struct({
|
||||
tag: new r.String(4),
|
||||
langSys: new r.Pointer(r.uint16, LangSysTable, { type: 'parent' })
|
||||
});
|
||||
|
||||
let Script = new r.Struct({
|
||||
defaultLangSys: new r.Pointer(r.uint16, LangSysTable),
|
||||
count: r.uint16,
|
||||
langSysRecords: new r.Array(LangSysRecord, 'count')
|
||||
});
|
||||
|
||||
let ScriptRecord = new r.Struct({
|
||||
tag: new r.String(4),
|
||||
script: new r.Pointer(r.uint16, Script, { type: 'parent' })
|
||||
});
|
||||
|
||||
export let ScriptList = new r.Array(ScriptRecord, r.uint16);
|
||||
|
||||
//#######################
|
||||
// Features and Lookups #
|
||||
//#######################
|
||||
|
||||
let FeatureParams = new r.Struct({
|
||||
version: r.uint16, // should be set to 0 according OT spec
|
||||
nameID: r.uint16, //OT spec: UI Name ID or uiLabelNameId
|
||||
});
|
||||
|
||||
export let Feature = new r.Struct({
|
||||
featureParams: new r.Pointer(r.uint16, FeatureParams),
|
||||
lookupCount: r.uint16,
|
||||
lookupListIndexes: new r.Array(r.uint16, 'lookupCount')
|
||||
});
|
||||
|
||||
let FeatureRecord = new r.Struct({
|
||||
tag: new r.String(4),
|
||||
feature: new r.Pointer(r.uint16, Feature, { type: 'parent' })
|
||||
});
|
||||
|
||||
export let FeatureList = new r.Array(FeatureRecord, r.uint16);
|
||||
|
||||
let LookupFlags = new r.Struct({
|
||||
markAttachmentType: r.uint8,
|
||||
flags: new r.Bitfield(r.uint8, [
|
||||
'rightToLeft', 'ignoreBaseGlyphs', 'ignoreLigatures',
|
||||
'ignoreMarks', 'useMarkFilteringSet'
|
||||
])
|
||||
});
|
||||
|
||||
export function LookupList(SubTable) {
|
||||
let Lookup = new r.Struct({
|
||||
lookupType: r.uint16,
|
||||
flags: LookupFlags,
|
||||
subTableCount: r.uint16,
|
||||
subTables: new r.Array(new r.Pointer(r.uint16, SubTable), 'subTableCount'),
|
||||
markFilteringSet: new r.Optional(r.uint16, t => t.flags.flags.useMarkFilteringSet)
|
||||
});
|
||||
|
||||
return new r.LazyArray(new r.Pointer(r.uint16, Lookup), r.uint16);
|
||||
}
|
||||
|
||||
//#################
|
||||
// Coverage Table #
|
||||
//#################
|
||||
|
||||
let RangeRecord = new r.Struct({
|
||||
start: r.uint16,
|
||||
end: r.uint16,
|
||||
startCoverageIndex: r.uint16
|
||||
});
|
||||
|
||||
export let Coverage = new r.VersionedStruct(r.uint16, {
|
||||
1: {
|
||||
glyphCount: r.uint16,
|
||||
glyphs: new r.Array(r.uint16, 'glyphCount')
|
||||
},
|
||||
2: {
|
||||
rangeCount: r.uint16,
|
||||
rangeRecords: new r.Array(RangeRecord, 'rangeCount')
|
||||
}
|
||||
});
|
||||
|
||||
//#########################
|
||||
// Class Definition Table #
|
||||
//#########################
|
||||
|
||||
let ClassRangeRecord = new r.Struct({
|
||||
start: r.uint16,
|
||||
end: r.uint16,
|
||||
class: r.uint16
|
||||
});
|
||||
|
||||
export let ClassDef = new r.VersionedStruct(r.uint16, {
|
||||
1: { // Class array
|
||||
startGlyph: r.uint16,
|
||||
glyphCount: r.uint16,
|
||||
classValueArray: new r.Array(r.uint16, 'glyphCount')
|
||||
},
|
||||
2: { // Class ranges
|
||||
classRangeCount: r.uint16,
|
||||
classRangeRecord: new r.Array(ClassRangeRecord, 'classRangeCount')
|
||||
}
|
||||
});
|
||||
|
||||
//###############
|
||||
// Device Table #
|
||||
//###############
|
||||
|
||||
export let Device = new r.Struct({
|
||||
a: r.uint16, // startSize for hinting Device, outerIndex for VariationIndex
|
||||
b: r.uint16, // endSize for Device, innerIndex for VariationIndex
|
||||
deltaFormat: r.uint16
|
||||
});
|
||||
|
||||
//#############################################
|
||||
// Contextual Substitution/Positioning Tables #
|
||||
//#############################################
|
||||
|
||||
let LookupRecord = new r.Struct({
|
||||
sequenceIndex: r.uint16,
|
||||
lookupListIndex: r.uint16
|
||||
});
|
||||
|
||||
let Rule = new r.Struct({
|
||||
glyphCount: r.uint16,
|
||||
lookupCount: r.uint16,
|
||||
input: new r.Array(r.uint16, t => t.glyphCount - 1),
|
||||
lookupRecords: new r.Array(LookupRecord, 'lookupCount')
|
||||
});
|
||||
|
||||
let RuleSet = new r.Array(new r.Pointer(r.uint16, Rule), r.uint16);
|
||||
|
||||
let ClassRule = new r.Struct({
|
||||
glyphCount: r.uint16,
|
||||
lookupCount: r.uint16,
|
||||
classes: new r.Array(r.uint16, t => t.glyphCount - 1),
|
||||
lookupRecords: new r.Array(LookupRecord, 'lookupCount')
|
||||
});
|
||||
|
||||
let ClassSet = new r.Array(new r.Pointer(r.uint16, ClassRule), r.uint16);
|
||||
|
||||
export let Context = new r.VersionedStruct(r.uint16, {
|
||||
1: { // Simple context
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
ruleSetCount: r.uint16,
|
||||
ruleSets: new r.Array(new r.Pointer(r.uint16, RuleSet), 'ruleSetCount')
|
||||
},
|
||||
2: { // Class-based context
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
classDef: new r.Pointer(r.uint16, ClassDef),
|
||||
classSetCnt: r.uint16,
|
||||
classSet: new r.Array(new r.Pointer(r.uint16, ClassSet), 'classSetCnt')
|
||||
},
|
||||
3: {
|
||||
glyphCount: r.uint16,
|
||||
lookupCount: r.uint16,
|
||||
coverages: new r.Array(new r.Pointer(r.uint16, Coverage), 'glyphCount'),
|
||||
lookupRecords: new r.Array(LookupRecord, 'lookupCount')
|
||||
}
|
||||
});
|
||||
|
||||
//######################################################
|
||||
// Chaining Contextual Substitution/Positioning Tables #
|
||||
//######################################################
|
||||
|
||||
let ChainRule = new r.Struct({
|
||||
backtrackGlyphCount: r.uint16,
|
||||
backtrack: new r.Array(r.uint16, 'backtrackGlyphCount'),
|
||||
inputGlyphCount: r.uint16,
|
||||
input: new r.Array(r.uint16, t => t.inputGlyphCount - 1),
|
||||
lookaheadGlyphCount: r.uint16,
|
||||
lookahead: new r.Array(r.uint16, 'lookaheadGlyphCount'),
|
||||
lookupCount: r.uint16,
|
||||
lookupRecords: new r.Array(LookupRecord, 'lookupCount')
|
||||
});
|
||||
|
||||
let ChainRuleSet = new r.Array(new r.Pointer(r.uint16, ChainRule), r.uint16);
|
||||
|
||||
export let ChainingContext = new r.VersionedStruct(r.uint16, {
|
||||
1: { // Simple context glyph substitution
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
chainCount: r.uint16,
|
||||
chainRuleSets: new r.Array(new r.Pointer(r.uint16, ChainRuleSet), 'chainCount')
|
||||
},
|
||||
|
||||
2: { // Class-based chaining context
|
||||
coverage: new r.Pointer(r.uint16, Coverage),
|
||||
backtrackClassDef: new r.Pointer(r.uint16, ClassDef),
|
||||
inputClassDef: new r.Pointer(r.uint16, ClassDef),
|
||||
lookaheadClassDef: new r.Pointer(r.uint16, ClassDef),
|
||||
chainCount: r.uint16,
|
||||
chainClassSet: new r.Array(new r.Pointer(r.uint16, ChainRuleSet), 'chainCount')
|
||||
},
|
||||
|
||||
3: { // Coverage-based chaining context
|
||||
backtrackGlyphCount: r.uint16,
|
||||
backtrackCoverage: new r.Array(new r.Pointer(r.uint16, Coverage), 'backtrackGlyphCount'),
|
||||
inputGlyphCount: r.uint16,
|
||||
inputCoverage: new r.Array(new r.Pointer(r.uint16, Coverage), 'inputGlyphCount'),
|
||||
lookaheadGlyphCount: r.uint16,
|
||||
lookaheadCoverage: new r.Array(new r.Pointer(r.uint16, Coverage), 'lookaheadGlyphCount'),
|
||||
lookupCount: r.uint16,
|
||||
lookupRecords: new r.Array(LookupRecord, 'lookupCount')
|
||||
}
|
||||
});
|
||||
34
node_modules/fontkit/src/tables/post.js
generated
vendored
Normal file
34
node_modules/fontkit/src/tables/post.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// PostScript information
|
||||
export default new r.VersionedStruct(r.fixed32, {
|
||||
header: { // these fields exist at the top of all versions
|
||||
italicAngle: r.fixed32, // Italic angle in counter-clockwise degrees from the vertical.
|
||||
underlinePosition: r.int16, // Suggested distance of the top of the underline from the baseline
|
||||
underlineThickness: r.int16, // Suggested values for the underline thickness
|
||||
isFixedPitch: r.uint32, // Whether the font is monospaced
|
||||
minMemType42: r.uint32, // Minimum memory usage when a TrueType font is downloaded as a Type 42 font
|
||||
maxMemType42: r.uint32, // Maximum memory usage when a TrueType font is downloaded as a Type 42 font
|
||||
minMemType1: r.uint32, // Minimum memory usage when a TrueType font is downloaded as a Type 1 font
|
||||
maxMemType1: r.uint32 // Maximum memory usage when a TrueType font is downloaded as a Type 1 font
|
||||
},
|
||||
|
||||
1: {}, // version 1 has no additional fields
|
||||
|
||||
2: {
|
||||
numberOfGlyphs: r.uint16,
|
||||
glyphNameIndex: new r.Array(r.uint16, 'numberOfGlyphs'),
|
||||
names: new r.Array(new r.String(r.uint8))
|
||||
},
|
||||
|
||||
2.5: {
|
||||
numberOfGlyphs: r.uint16,
|
||||
offsets: new r.Array(r.uint8, 'numberOfGlyphs')
|
||||
},
|
||||
|
||||
3: {}, // version 3 has no additional fields
|
||||
|
||||
4: {
|
||||
map: new r.Array(r.uint32, t => t.parent.maxp.numGlyphs)
|
||||
}
|
||||
});
|
||||
6
node_modules/fontkit/src/tables/prep.js
generated
vendored
Normal file
6
node_modules/fontkit/src/tables/prep.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// Set of instructions executed whenever the point size or font transformation change
|
||||
export default new r.Struct({
|
||||
controlValueProgram: new r.Array(r.uint8)
|
||||
});
|
||||
17
node_modules/fontkit/src/tables/sbix.js
generated
vendored
Normal file
17
node_modules/fontkit/src/tables/sbix.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let ImageTable = new r.Struct({
|
||||
ppem: r.uint16,
|
||||
resolution: r.uint16,
|
||||
imageOffsets: new r.Array(new r.Pointer(r.uint32, 'void'), t => t.parent.parent.maxp.numGlyphs + 1)
|
||||
});
|
||||
|
||||
// This is the Apple sbix table, used by the "Apple Color Emoji" font.
|
||||
// It includes several image tables with images for each bitmap glyph
|
||||
// of several different sizes.
|
||||
export default new r.Struct({
|
||||
version: r.uint16,
|
||||
flags: new r.Bitfield(r.uint16, ['renderOutlines']),
|
||||
numImgTables: r.uint32,
|
||||
imageTables: new r.Array(new r.Pointer(r.uint32, ImageTable), 'numImgTables')
|
||||
});
|
||||
81
node_modules/fontkit/src/tables/variations.js
generated
vendored
Normal file
81
node_modules/fontkit/src/tables/variations.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
import {Feature} from './opentype';
|
||||
import * as r from 'restructure';
|
||||
|
||||
/*******************
|
||||
* Variation Store *
|
||||
*******************/
|
||||
|
||||
let F2DOT14 = new r.Fixed(16, 'BE', 14);
|
||||
let RegionAxisCoordinates = new r.Struct({
|
||||
startCoord: F2DOT14,
|
||||
peakCoord: F2DOT14,
|
||||
endCoord: F2DOT14
|
||||
});
|
||||
|
||||
let VariationRegionList = new r.Struct({
|
||||
axisCount: r.uint16,
|
||||
regionCount: r.uint16,
|
||||
variationRegions: new r.Array(new r.Array(RegionAxisCoordinates, 'axisCount'), 'regionCount')
|
||||
});
|
||||
|
||||
let DeltaSet = new r.Struct({
|
||||
shortDeltas: new r.Array(r.int16, t => t.parent.shortDeltaCount),
|
||||
regionDeltas: new r.Array(r.int8, t => t.parent.regionIndexCount - t.parent.shortDeltaCount),
|
||||
deltas: t => t.shortDeltas.concat(t.regionDeltas)
|
||||
});
|
||||
|
||||
let ItemVariationData = new r.Struct({
|
||||
itemCount: r.uint16,
|
||||
shortDeltaCount: r.uint16,
|
||||
regionIndexCount: r.uint16,
|
||||
regionIndexes: new r.Array(r.uint16, 'regionIndexCount'),
|
||||
deltaSets: new r.Array(DeltaSet, 'itemCount')
|
||||
});
|
||||
|
||||
export let ItemVariationStore = new r.Struct({
|
||||
format: r.uint16,
|
||||
variationRegionList: new r.Pointer(r.uint32, VariationRegionList),
|
||||
variationDataCount: r.uint16,
|
||||
itemVariationData: new r.Array(new r.Pointer(r.uint32, ItemVariationData), 'variationDataCount')
|
||||
});
|
||||
|
||||
/**********************
|
||||
* Feature Variations *
|
||||
**********************/
|
||||
|
||||
let ConditionTable = new r.VersionedStruct(r.uint16, {
|
||||
1: {
|
||||
axisIndex: r.uint16,
|
||||
axisIndex: r.uint16,
|
||||
filterRangeMinValue: F2DOT14,
|
||||
filterRangeMaxValue: F2DOT14
|
||||
}
|
||||
});
|
||||
|
||||
let ConditionSet = new r.Struct({
|
||||
conditionCount: r.uint16,
|
||||
conditionTable: new r.Array(new r.Pointer(r.uint32, ConditionTable), 'conditionCount')
|
||||
});
|
||||
|
||||
let FeatureTableSubstitutionRecord = new r.Struct({
|
||||
featureIndex: r.uint16,
|
||||
alternateFeatureTable: new r.Pointer(r.uint32, Feature, {type: 'parent'})
|
||||
});
|
||||
|
||||
let FeatureTableSubstitution = new r.Struct({
|
||||
version: r.fixed32,
|
||||
substitutionCount: r.uint16,
|
||||
substitutions: new r.Array(FeatureTableSubstitutionRecord, 'substitutionCount')
|
||||
});
|
||||
|
||||
let FeatureVariationRecord = new r.Struct({
|
||||
conditionSet: new r.Pointer(r.uint32, ConditionSet, {type: 'parent'}),
|
||||
featureTableSubstitution: new r.Pointer(r.uint32, FeatureTableSubstitution, {type: 'parent'})
|
||||
});
|
||||
|
||||
export let FeatureVariations = new r.Struct({
|
||||
majorVersion: r.uint16,
|
||||
minorVersion: r.uint16,
|
||||
featureVariationRecordCount: r.uint32,
|
||||
featureVariationRecords: new r.Array(FeatureVariationRecord, 'featureVariationRecordCount')
|
||||
});
|
||||
19
node_modules/fontkit/src/tables/vhea.js
generated
vendored
Normal file
19
node_modules/fontkit/src/tables/vhea.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
// Vertical Header Table
|
||||
export default new r.Struct({
|
||||
version: r.uint16, // Version number of the Vertical Header Table
|
||||
ascent: r.int16, // The vertical typographic ascender for this font
|
||||
descent: r.int16, // The vertical typographic descender for this font
|
||||
lineGap: r.int16, // The vertical typographic line gap for this font
|
||||
advanceHeightMax: r.int16, // The maximum advance height measurement found in the font
|
||||
minTopSideBearing: r.int16, // The minimum top side bearing measurement found in the font
|
||||
minBottomSideBearing: r.int16, // The minimum bottom side bearing measurement found in the font
|
||||
yMaxExtent: r.int16,
|
||||
caretSlopeRise: r.int16, // Caret slope (rise/run)
|
||||
caretSlopeRun: r.int16,
|
||||
caretOffset: r.int16, // Set value equal to 0 for nonslanted fonts
|
||||
reserved: new r.Reserved(r.int16, 4),
|
||||
metricDataFormat: r.int16, // Set to 0
|
||||
numberOfMetrics: r.uint16 // Number of advance heights in the Vertical Metrics table
|
||||
});
|
||||
12
node_modules/fontkit/src/tables/vmtx.js
generated
vendored
Normal file
12
node_modules/fontkit/src/tables/vmtx.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as r from 'restructure';
|
||||
|
||||
let VmtxEntry = new r.Struct({
|
||||
advance: r.uint16, // The advance height of the glyph
|
||||
bearing: r.int16 // The top sidebearing of the glyph
|
||||
});
|
||||
|
||||
// Vertical Metrics Table
|
||||
export default new r.Struct({
|
||||
metrics: new r.LazyArray(VmtxEntry, t => t.parent.vhea.numberOfMetrics),
|
||||
bearings: new r.LazyArray(r.int16, t => t.parent.maxp.numGlyphs - t.parent.vhea.numberOfMetrics)
|
||||
});
|
||||
Reference in New Issue
Block a user