@mark1russell7/typeset 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/build/chunks/engines.d.ts +32 -0
- package/build/chunks/engines.d.ts.map +1 -0
- package/build/chunks/engines.js +35 -0
- package/build/chunks/engines.js.map +1 -0
- package/build/chunks/font.d.ts +228 -0
- package/build/chunks/font.d.ts.map +1 -0
- package/build/chunks/font.js +3779 -0
- package/build/chunks/font.js.map +1 -0
- package/build/chunks/fonts.d.ts +31 -0
- package/build/chunks/fonts.d.ts.map +1 -0
- package/build/chunks/fonts.js +150 -0
- package/build/chunks/fonts.js.map +1 -0
- package/build/chunks/measurer.d.ts +67 -0
- package/build/chunks/measurer.d.ts.map +1 -0
- package/build/chunks/measurer.js +277 -0
- package/build/chunks/measurer.js.map +1 -0
- package/build/chunks/sfnt.d.ts +22 -0
- package/build/chunks/sfnt.d.ts.map +1 -0
- package/build/chunks/text.js.map +1 -1
- package/build/fonts-inspect.d.ts +10 -0
- package/build/fonts-inspect.d.ts.map +1 -0
- package/build/fonts-inspect.js +1 -0
- package/build/fonts.d.ts +5 -0
- package/build/fonts.js +4 -0
- package/build/index.d.ts +3 -1
- package/build/index.js +3 -1
- package/build/measurer.d.ts +2 -0
- package/build/measurer.js +1 -0
- package/package.json +18 -4
- package/src/fonts/bidi.ts +125 -0
- package/src/fonts/binary.ts +41 -0
- package/src/fonts/bound.ts +167 -0
- package/src/fonts/engines.ts +38 -0
- package/src/fonts/font.ts +458 -0
- package/src/fonts/gvar.ts +220 -0
- package/src/fonts/index.ts +11 -0
- package/src/fonts/indic.ts +626 -0
- package/src/fonts/joining.ts +141 -0
- package/src/fonts/kerning.ts +278 -0
- package/src/fonts/sfnt.ts +102 -0
- package/src/fonts/substitution.ts +686 -0
- package/src/fonts/tables.ts +162 -0
- package/src/fonts/variations.ts +175 -0
- package/src/fonts/words.ts +119 -0
- package/src/fonts-inspect.ts +8 -0
- package/src/fonts.ts +9 -0
- package/src/index.ts +2 -0
- package/src/measurer/advance.ts +307 -0
- package/src/measurer.ts +5 -0
- package/src/text/rope.ts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font.js","names":["USE_MARK_FILTERING_SET","normalize","normalize"],"sources":["../../src/fonts/tables.ts","../../src/fonts/kerning.ts","../../src/fonts/binary.ts","../../src/fonts/sfnt.ts","../../src/fonts/substitution.ts","../../src/fonts/variations.ts","../../src/fonts/gvar.ts","../../src/fonts/indic.ts","../../src/fonts/joining.ts","../../src/fonts/bidi.ts","../../src/fonts/words.ts","../../src/fonts/font.ts"],"sourcesContent":["import type { Reader } from \"./binary.ts\";\n\n/** The fields of `head`, `hhea` and `maxp` that the width uses. */\nexport interface Header {\n readonly unitsPerEm: number;\n /** The revision of the font, as the raw 16.16 number. */\n readonly revision: number;\n readonly checksumAdjustment: number;\n readonly numberOfHMetrics: number;\n readonly numGlyphs: number;\n}\n\n/** This function reads the header fields from `head`, `hhea` and `maxp`. */\nexport function readHeader(head: Reader, hhea: Reader, maxp: Reader): Header {\n if (head.u32(12) !== 0x5f0f3cf5) throw new Error(\"the head table has a bad magic number\");\n return { revision: head.u32(4), checksumAdjustment: head.u32(8), unitsPerEm: head.u16(18), numberOfHMetrics: hhea.u16(34), numGlyphs: maxp.u16(4) };\n}\n\n/** This function gives the advance of each glyph in font units, from `hmtx`. */\nexport function readAdvances(hmtx: Reader, header: Header): Uint16Array {\n const advances = new Uint16Array(header.numGlyphs);\n let last = 0;\n for (let glyph = 0; glyph < header.numGlyphs; glyph++) {\n if (glyph < header.numberOfHMetrics) last = hmtx.u16(glyph * 4);\n advances[glyph] = last;\n }\n return advances;\n}\n\n/** This function gives the map from code points to glyphs of `cmap`. It uses a format 12 subtable if there is one, else a format 4 subtable. */\nexport function readCharacterMap(cmap: Reader): Map<number, number> {\n const count = cmap.u16(2);\n let best: { rank: number; offset: number } | undefined;\n for (let i = 0; i < count; i++) {\n const record = 4 + i * 8;\n const platform = cmap.u16(record);\n const encoding = cmap.u16(record + 2);\n const offset = cmap.u32(record + 4);\n const format = cmap.u16(offset);\n const unicode = platform === 0 || (platform === 3 && (encoding === 1 || encoding === 10));\n if (!unicode) continue;\n const rank = format === 12 ? 2 : format === 4 ? 1 : 0;\n if (rank > 0 && (best === undefined || rank > best.rank)) best = { rank, offset };\n }\n if (best === undefined) throw new Error(\"the cmap table has no Unicode subtable of format 4 or 12\");\n const table = cmap.part(best.offset);\n const map = new Map<number, number>();\n if (best.rank === 2) {\n const groups = table.u32(12);\n for (let g = 0; g < groups; g++) {\n const at = 16 + g * 12;\n const start = table.u32(at);\n const end = table.u32(at + 4);\n const glyph = table.u32(at + 8);\n for (let c = start; c <= end; c++) map.set(c, glyph + c - start);\n }\n return map;\n }\n const segments = table.u16(6) / 2;\n const ends = 14;\n const starts = ends + segments * 2 + 2;\n const deltas = starts + segments * 2;\n const ranges = deltas + segments * 2;\n for (let s = 0; s < segments; s++) {\n const start = table.u16(starts + s * 2);\n const end = table.u16(ends + s * 2);\n const delta = table.u16(deltas + s * 2);\n const range = table.u16(ranges + s * 2);\n for (let c = start; c <= end && c !== 0xffff; c++) {\n let glyph: number;\n if (range === 0) glyph = (c + delta) & 0xffff;\n else {\n glyph = table.u16(ranges + s * 2 + range + (c - start) * 2);\n if (glyph !== 0) glyph = (glyph + delta) & 0xffff;\n }\n if (glyph !== 0) map.set(c, glyph);\n }\n }\n return map;\n}\n\n/** This function gives the class of a glyph in a ClassDef table. A glyph that the table does not list has the class 0. */\nexport function classOf(table: Reader, glyph: number): number {\n const format = table.u16(0);\n if (format === 1) {\n const start = table.u16(2);\n const count = table.u16(4);\n return glyph >= start && glyph < start + count ? table.u16(6 + (glyph - start) * 2) : 0;\n }\n if (format === 2) {\n let low = 0;\n let high = table.u16(2) - 1;\n while (low <= high) {\n const middle = (low + high) >> 1;\n const at = 4 + middle * 6;\n if (glyph < table.u16(at)) high = middle - 1;\n else if (glyph > table.u16(at + 2)) low = middle + 1;\n else return table.u16(at + 4);\n }\n return 0;\n }\n throw new Error(`the ClassDef format ${format} is unknown`);\n}\n\n/** This function gives the index of a glyph in a Coverage table, or -1 when the table does not cover the glyph. */\nexport function coverageIndex(table: Reader, glyph: number): number {\n const format = table.u16(0);\n let low = 0;\n let high = table.u16(2) - 1;\n if (format === 1) {\n while (low <= high) {\n const middle = (low + high) >> 1;\n const value = table.u16(4 + middle * 2);\n if (glyph < value) high = middle - 1;\n else if (glyph > value) low = middle + 1;\n else return middle;\n }\n return -1;\n }\n if (format === 2) {\n while (low <= high) {\n const middle = (low + high) >> 1;\n const at = 4 + middle * 6;\n if (glyph < table.u16(at)) high = middle - 1;\n else if (glyph > table.u16(at + 2)) low = middle + 1;\n else return table.u16(at + 4) + glyph - table.u16(at);\n }\n return -1;\n }\n throw new Error(`the Coverage format ${format} is unknown`);\n}\n\n/** This function gives each glyph of a Coverage table with its coverage index, in the order of the table. */\nexport function coverageGlyphs(table: Reader): (readonly [glyph: number, index: number])[] {\n const format = table.u16(0);\n const count = table.u16(2);\n const glyphs: (readonly [number, number])[] = [];\n if (format === 1) {\n for (let k = 0; k < count; k++) glyphs.push([table.u16(4 + k * 2), k]);\n return glyphs;\n }\n if (format === 2) {\n for (let k = 0; k < count; k++) {\n const at = 4 + k * 6;\n const start = table.u16(at);\n const end = table.u16(at + 2);\n const index = table.u16(at + 4);\n for (let glyph = start; glyph <= end; glyph++) glyphs.push([glyph, index + glyph - start]);\n }\n return glyphs;\n }\n throw new Error(`the Coverage format ${format} is unknown`);\n}\n\n/** The GDEF glyph classes: 1 base, 2 ligature, 3 mark, 4 component. */\nexport function readGlyphClasses(gdef: Reader | undefined): ((glyph: number) => number) {\n if (gdef === undefined) return () => 0;\n const offset = gdef.u16(4);\n if (offset === 0) return () => 0;\n const table = gdef.part(offset);\n return (glyph) => classOf(table, glyph);\n}\n","import type { Reader } from \"./binary.ts\";\nimport type { GlyphFilter } from \"./substitution.ts\";\nimport { classOf, coverageIndex } from \"./tables.ts\";\nimport type { VariationStore } from \"./variations.ts\";\n\n/** The change of the advances of two glyphs, in font units. A variable font can give a value that is not a whole number. */\nexport interface PairValue {\n readonly first: number;\n readonly second: number;\n /** The part of `first` that comes from a VariationIndex table. HarfBuzz scales this part and the rest in different ways. */\n readonly firstDelta?: number;\n /** The part of `second` that comes from a VariationIndex table. */\n readonly secondDelta?: number;\n /** It is true when the subtable has a value for the second glyph. Then the next pair starts after the second glyph. */\n readonly skipSecond: boolean;\n}\n\n/** A lookup of pair adjustments, with the flags that tell which glyphs it skips. */\nexport interface PairLookup {\n readonly flags: number;\n /**\n * This function tells if the lookup skips a glyph, when the lookup uses a mark filtering set. Then the lookup skips each\n * mark that is not in the set. Without the function, the flags alone tell which glyphs the lookup skips.\n */\n readonly skip?: (glyph: number) => boolean;\n /** This function gives the value for a pair, or `undefined` when no subtable applies. */\n pair(first: number, second: number): PairValue | undefined;\n /**\n * This function gives the largest positive value of each glyph of a pair, over the pairs with two glyphs of `glyphs`.\n * A value is at least 0. It uses the values of the instance, so it includes each variation delta.\n */\n largest(glyphs: ReadonlySet<number>): LargestKerning;\n}\n\n/** The largest positive kerning of the first glyph and of the second glyph of a pair, in font units. */\nexport interface LargestKerning {\n readonly first: number;\n readonly second: number;\n}\n\n/** One PairPos subtable. */\ntype PairSubtable = Pick<PairLookup, \"pair\" | \"largest\">;\n\n/** The lookup flags of OpenType. */\nexport const IGNORE_BASE = 0x2;\nexport const IGNORE_LIGATURES = 0x4;\nexport const IGNORE_MARKS = 0x8;\n\n/** This function gives the size in bytes of a ValueRecord of the format `format`. */\nfunction valueSize(format: number): number {\n let bits = format & 0xff;\n let size = 0;\n while (bits !== 0) {\n size += bits & 1;\n bits >>= 1;\n }\n return size * 2;\n}\n\n/**\n * This function gives the XAdvance of a ValueRecord at `offset`, or 0 when the format has none. The offset of a device table\n * is relative to `parent`. A VariationIndex table adds its delta from `store`, not rounded, as HarfBuzz adds it. A device\n * table of hinting deltas adds nothing, because the shaper of the browser does not set a ppem.\n */\nfunction xAdvance(table: Reader, offset: number, format: number, parent: Reader, store: VariationStore | undefined): { value: number; delta: number } {\n const value = (format & 0x4) === 0 ? 0 : table.i16(offset + valueSize(format & 0x3));\n let delta = 0;\n if ((format & 0x40) !== 0 && store !== undefined) {\n const device = table.u16(offset + valueSize(format & 0x3f));\n if (device !== 0 && parent.u16(device + 4) === 0x8000) delta = store.delta(parent.u16(device), parent.u16(device + 2));\n }\n return { value: value + delta, delta };\n}\n\n/** This function makes the value of a pair from the XAdvance of its two glyphs. */\nfunction pairValue(first: { value: number; delta: number }, second: { value: number; delta: number }, skipSecond: boolean): PairValue {\n return { first: first.value, second: second.value, firstDelta: first.delta, secondDelta: second.delta, skipSecond };\n}\n\n/** This function makes the functions of one PairPos subtable. */\nfunction pairSubtable(table: Reader, store: VariationStore | undefined): PairSubtable {\n const format = table.u16(0);\n const coverage = table.part(table.u16(2));\n const format1 = table.u16(4);\n const format2 = table.u16(6);\n const size1 = valueSize(format1);\n const size2 = valueSize(format2);\n const skipSecond = format2 !== 0;\n if (format === 1) {\n const recordSize = 2 + size1 + size2;\n const pair = (first: number, second: number): PairValue | undefined => {\n const index = coverageIndex(coverage, first);\n if (index < 0) return undefined;\n const set = table.part(table.u16(10 + index * 2));\n let low = 0;\n let high = set.u16(0) - 1;\n while (low <= high) {\n const middle = (low + high) >> 1;\n const at = 2 + middle * recordSize;\n const glyph = set.u16(at);\n if (second < glyph) high = middle - 1;\n else if (second > glyph) low = middle + 1;\n else return pairValue(xAdvance(set, at + 2, format1, set, store), xAdvance(set, at + 2 + size1, format2, set, store), skipSecond);\n }\n return undefined;\n };\n const largest = (glyphs: ReadonlySet<number>): LargestKerning => {\n let first = 0;\n let second = 0;\n for (const glyph of glyphs) {\n const index = coverageIndex(coverage, glyph);\n if (index < 0) continue;\n const set = table.part(table.u16(10 + index * 2));\n for (let record = 0; record < set.u16(0); record++) {\n const at = 2 + record * recordSize;\n if (!glyphs.has(set.u16(at))) continue;\n first = Math.max(first, xAdvance(set, at + 2, format1, set, store).value);\n second = Math.max(second, xAdvance(set, at + 2 + size1, format2, set, store).value);\n }\n }\n return { first, second };\n };\n return { pair, largest };\n }\n if (format === 2) {\n const classes1 = table.part(table.u16(8));\n const classes2 = table.part(table.u16(10));\n const count1 = table.u16(12);\n const count2 = table.u16(14);\n const pair = (first: number, second: number): PairValue | undefined => {\n if (coverageIndex(coverage, first) < 0) return undefined;\n const class1 = classOf(classes1, first);\n const class2 = classOf(classes2, second);\n if (class1 >= count1 || class2 >= count2) return undefined;\n const at = 16 + (class1 * count2 + class2) * (size1 + size2);\n return pairValue(xAdvance(table, at, format1, table, store), xAdvance(table, at + size1, format2, table, store), skipSecond);\n };\n const largest = (glyphs: ReadonlySet<number>): LargestKerning => {\n const firsts = new Set<number>();\n const seconds = new Set<number>();\n for (const glyph of glyphs) {\n if (coverageIndex(coverage, glyph) >= 0) firsts.add(classOf(classes1, glyph));\n seconds.add(classOf(classes2, glyph));\n }\n let first = 0;\n let second = 0;\n for (const class1 of firsts) {\n for (const class2 of seconds) {\n if (class1 >= count1 || class2 >= count2) continue;\n const at = 16 + (class1 * count2 + class2) * (size1 + size2);\n first = Math.max(first, xAdvance(table, at, format1, table, store).value);\n second = Math.max(second, xAdvance(table, at + size1, format2, table, store).value);\n }\n }\n return { first, second };\n };\n return { pair, largest };\n }\n throw new Error(`the PairPos format ${format} is unknown`);\n}\n\n/** This function gives the tags of the scripts to try, in order, for a script tag, as HarfBuzz tries them. */\nexport function scriptTags(script: string): string[] {\n const tags = script === \"deva\" ? [\"dev2\", \"deva\"] : [script];\n return [...tags, \"DFLT\", \"dflt\", \"latn\"];\n}\n\n/** The GPOS features with pair lookups that HarfBuzz applies to horizontal text. */\nconst pairFeatures = new Set([\"kern\", \"dist\"]);\n\n/** The lookup flag that selects a mark filtering set of GDEF. */\nconst USE_MARK_FILTERING_SET = 0x10;\n\n/**\n * This function gives the pair lookups of the features `kern` and `dist` of GPOS for a script, in the order of the lookup\n * list. The store gives the deltas of a variable font at its instance. The filter gives the mark filtering sets of GDEF.\n */\nexport function readGposKerning(gpos: Reader, script: string, store?: VariationStore, filter?: GlyphFilter): PairLookup[] {\n const scripts = gpos.part(gpos.u16(4));\n const features = gpos.part(gpos.u16(6));\n const lookups = gpos.part(gpos.u16(8));\n const scriptCount = scripts.u16(0);\n let langSys: Reader | undefined;\n for (const wanted of scriptTags(script)) {\n for (let i = 0; i < scriptCount && langSys === undefined; i++) {\n if (scripts.tag(2 + i * 6) !== wanted) continue;\n const table = scripts.part(scripts.u16(2 + i * 6 + 4));\n const fallback = table.u16(0);\n if (fallback !== 0) langSys = table.part(fallback);\n }\n if (langSys !== undefined) break;\n }\n if (langSys === undefined) return [];\n const indices = new Set<number>();\n const featureCount = langSys.u16(4);\n for (let i = 0; i < featureCount; i++) {\n const record = 2 + langSys.u16(6 + i * 2) * 6;\n if (!pairFeatures.has(features.tag(record))) continue;\n const feature = features.part(features.u16(record + 4));\n for (let k = 0; k < feature.u16(2); k++) indices.add(feature.u16(4 + k * 2));\n }\n return [...indices].sort((a, b) => a - b).flatMap((index) => {\n const lookup = lookups.part(lookups.u16(2 + index * 2));\n const subtables: PairSubtable[] = [];\n const type = lookup.u16(0);\n for (let s = 0; s < lookup.u16(4); s++) {\n let subtable = lookup.part(lookup.u16(6 + s * 2));\n let subtype = type;\n if (type === 9) {\n subtype = subtable.u16(2);\n subtable = subtable.part(subtable.u32(4));\n }\n if (subtype === 2) subtables.push(pairSubtable(subtable, store));\n }\n if (subtables.length === 0) return [];\n const flags = lookup.u16(2);\n const markSet = (flags & USE_MARK_FILTERING_SET) !== 0 && filter !== undefined ? lookup.u16(6 + lookup.u16(4) * 2) : -1;\n const skip = markSet < 0 ? undefined : (glyph: number): boolean => {\n const kind = filter!.glyphClass(glyph);\n if ((flags & IGNORE_BASE) !== 0 && kind === 1) return true;\n if ((flags & IGNORE_LIGATURES) !== 0 && kind === 2) return true;\n if (kind !== 3) return false;\n return (flags & IGNORE_MARKS) !== 0 || !filter!.inMarkSet(markSet, glyph);\n };\n return [{\n flags,\n ...(skip === undefined ? {} : { skip }),\n pair(first: number, second: number): PairValue | undefined {\n for (const subtable of subtables) {\n const value = subtable.pair(first, second);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n // A pair gets the value of one subtable, so the largest value of a lookup is the largest value of its subtables\n largest(glyphs: ReadonlySet<number>): LargestKerning {\n const values = subtables.map((subtable) => subtable.largest(glyphs));\n return { first: Math.max(...values.map((value) => value.first)), second: Math.max(...values.map((value) => value.second)) };\n },\n }];\n });\n}\n\n/** This function gives the pairs of format 0 of the `kern` table, as one lookup. */\nexport function readKernTable(kern: Reader): PairLookup[] {\n // Only the version 0 of Microsoft. The version 1 of Apple starts with the 32-bit number 0x00010000\n if (kern.u16(0) !== 0) return [];\n const pairs = new Map<number, number>();\n const count = kern.u16(2);\n let offset = 4;\n for (let t = 0; t < count; t++) {\n const length = kern.u16(offset + 2);\n const coverage = kern.u16(offset + 4);\n // Only the horizontal kerning of format 0, with no minimum values and no cross-stream values\n if ((coverage & 0xff07) === 0x0001) {\n const n = kern.u16(offset + 6);\n for (let i = 0; i < n; i++) {\n const at = offset + 14 + i * 6;\n const key = kern.u16(at) * 0x10000 + kern.u16(at + 2);\n pairs.set(key, (pairs.get(key) ?? 0) + kern.i16(at + 4));\n }\n }\n offset += length;\n }\n if (pairs.size === 0) return [];\n return [{\n flags: 0,\n pair(first: number, second: number): PairValue | undefined {\n const value = pairs.get(first * 0x10000 + second);\n return value === undefined ? undefined : { first: value, second: 0, skipSecond: false };\n },\n largest(glyphs: ReadonlySet<number>): LargestKerning {\n let first = 0;\n for (const [key, value] of pairs) if (glyphs.has(Math.floor(key / 0x10000)) && glyphs.has(key % 0x10000)) first = Math.max(first, value);\n return { first, second: 0 };\n },\n }];\n}\n","/** A big-endian reader over a part of a font file. The offsets are relative to the start of the part. */\nexport class Reader {\n readonly bytes: Uint8Array;\n private readonly view: DataView;\n\n constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n }\n\n get length(): number {\n return this.bytes.byteLength;\n }\n\n u8(offset: number): number {\n return this.view.getUint8(offset);\n }\n\n u16(offset: number): number {\n return this.view.getUint16(offset);\n }\n\n i16(offset: number): number {\n return this.view.getInt16(offset);\n }\n\n u32(offset: number): number {\n return this.view.getUint32(offset);\n }\n\n tag(offset: number): string {\n return String.fromCharCode(this.u8(offset), this.u8(offset + 1), this.u8(offset + 2), this.u8(offset + 3));\n }\n\n /** This method gives a reader over the bytes from `offset`, with the length `length` or to the end. */\n part(offset: number, length?: number): Reader {\n const end = length === undefined ? this.bytes.byteLength : offset + length;\n if (offset < 0 || end > this.bytes.byteLength || offset > end) throw new RangeError(`the part ${offset}..${end} is outside ${this.bytes.byteLength} bytes`);\n return new Reader(this.bytes.subarray(offset, end));\n }\n}\n","import { Reader } from \"./binary.ts\";\n\n/** A function that decompresses Brotli data. Node gives one as `brotliDecompressSync` of `node:zlib`. */\nexport type Decompress = (data: Uint8Array) => Uint8Array;\n\n/** The tables of a font, by tag. A table that the decoder does not need can be absent. */\nexport type TableMap = ReadonlyMap<string, Reader>;\n\n/** The tags of the WOFF2 table directory, in the order of the WOFF2 specification. */\nconst knownTags = [\n \"cmap\", \"head\", \"hhea\", \"hmtx\", \"maxp\", \"name\", \"OS/2\", \"post\", \"cvt \", \"fpgm\", \"glyf\", \"loca\", \"prep\", \"CFF \", \"VORG\", \"EBDT\",\n \"EBLC\", \"gasp\", \"hdmx\", \"kern\", \"LTSH\", \"PCLT\", \"VDMX\", \"vhea\", \"vmtx\", \"BASE\", \"GDEF\", \"GPOS\", \"GSUB\", \"EBSC\", \"JSTF\", \"MATH\",\n \"CBDT\", \"CBLC\", \"COLR\", \"CPAL\", \"SVG \", \"sbix\", \"acnt\", \"avar\", \"bdat\", \"bloc\", \"bsln\", \"cvar\", \"fdsc\", \"feat\", \"fmtx\", \"fvar\",\n \"gvar\", \"hsty\", \"just\", \"lcar\", \"mort\", \"morx\", \"opbd\", \"prop\", \"trak\", \"Zapf\", \"Silf\", \"Glat\", \"Gloc\", \"Feat\", \"Sill\",\n] as const;\n\n/** This function gives the tables of a TrueType, OpenType or WOFF2 file. */\nexport function readTables(bytes: Uint8Array, decompress?: Decompress): TableMap {\n const file = new Reader(bytes);\n if (file.length < 12) throw new RangeError(\"the file is too short for a font\");\n const signature = file.tag(0);\n if (signature === \"wOF2\") {\n if (decompress === undefined) throw new Error(\"a WOFF2 file needs a Brotli decompress function\");\n return readWoff2(file, decompress);\n }\n if (signature === \"wOFF\") throw new Error(\"WOFF 1 files are not supported\");\n if (signature === \"ttcf\") throw new Error(\"font collections are not supported\");\n if (file.u32(0) !== 0x00010000 && signature !== \"OTTO\" && signature !== \"true\") throw new Error(`the signature ${JSON.stringify(signature)} is not a font`);\n const tables = new Map<string, Reader>();\n const count = file.u16(4);\n for (let i = 0; i < count; i++) {\n const record = 12 + i * 16;\n tables.set(file.tag(record), file.part(file.u32(record + 8), file.u32(record + 12)));\n }\n return tables;\n}\n\n/** This function reads a UIntBase128 number of WOFF2 and gives the number and the next offset. */\nfunction base128(file: Reader, offset: number): [value: number, next: number] {\n let value = 0;\n for (let i = 0; i < 5; i++) {\n const byte = file.u8(offset + i);\n if (i === 0 && byte === 0x80) throw new RangeError(\"a UIntBase128 has a leading zero\");\n value = value * 128 + (byte & 0x7f);\n if ((byte & 0x80) === 0) return [value, offset + i + 1];\n }\n throw new RangeError(\"a UIntBase128 is longer than 5 bytes\");\n}\n\n/**\n * This function gives the tables of a WOFF2 file. The `glyf` and `loca` tables stay in their transformed form,\n * because the width does not use them. A transformed `hmtx` table becomes a plain table again.\n */\nfunction readWoff2(file: Reader, decompress: Decompress): TableMap {\n const flavor = file.u32(4);\n if (flavor === 0x74746366) throw new Error(\"WOFF2 font collections are not supported\");\n const count = file.u16(12);\n const compressedLength = file.u32(20);\n let offset = 48;\n const entries: { tag: string; length: number; transformed: boolean }[] = [];\n for (let i = 0; i < count; i++) {\n const flags = file.u8(offset++);\n let tag: string;\n if ((flags & 0x3f) === 0x3f) {\n tag = file.tag(offset);\n offset += 4;\n } else {\n const known = knownTags[flags & 0x3f];\n if (known === undefined) throw new RangeError(`the WOFF2 tag index ${flags & 0x3f} is unknown`);\n tag = known;\n }\n const version = (flags >> 6) & 3;\n let length: number;\n [length, offset] = base128(file, offset);\n // For glyf and loca, the version 0 is the transform. For the other tables, each version other than 0 is a transform\n const transformed = tag === \"glyf\" || tag === \"loca\" ? version === 0 : version !== 0;\n if (transformed) [length, offset] = base128(file, offset);\n entries.push({ tag, length, transformed });\n }\n const data = new Reader(decompress(file.bytes.subarray(offset, offset + compressedLength)));\n const tables = new Map<string, Reader>();\n let at = 0;\n for (const entry of entries) {\n tables.set(entry.tag, data.part(at, entry.length));\n at += entry.length;\n }\n const hmtx = entries.find((entry) => entry.tag === \"hmtx\");\n if (hmtx?.transformed === true) tables.set(\"hmtx\", untransformHmtx(tables));\n return tables;\n}\n\n/** This function gives a plain `hmtx` table from the transform of WOFF2. Only the advances matter, so each side bearing is 0. */\nfunction untransformHmtx(tables: Map<string, Reader>): Reader {\n const source = tables.get(\"hmtx\")!;\n const hhea = tables.get(\"hhea\");\n if (hhea === undefined) throw new Error(\"a transformed hmtx needs hhea\");\n const metrics = hhea.u16(34);\n const plain = new Uint8Array(metrics * 4);\n const view = new DataView(plain.buffer);\n for (let i = 0; i < metrics; i++) view.setUint16(i * 4, source.u16(1 + i * 2));\n return new Reader(plain);\n}\n","import type { Reader } from \"./binary.ts\";\nimport { IGNORE_BASE, IGNORE_LIGATURES, IGNORE_MARKS, scriptTags } from \"./kerning.ts\";\nimport { classOf, coverageGlyphs, coverageIndex } from \"./tables.ts\";\n\n/**\n * The GSUB features that the default model applies: the features that HarfBuzz and Chromium apply to horizontal text\n * when the page does not change them.\n */\nexport const defaultFeatures: readonly string[] = [\"ccmp\", \"locl\", \"rlig\", \"liga\", \"clig\", \"calt\", \"rclt\"];\n\n/** The lookup flag that selects a mark filtering set of GDEF. */\nconst USE_MARK_FILTERING_SET = 0x10;\n/** The largest depth of nested lookups, as in HarfBuzz. */\nconst MAX_NESTING = 64;\n\n/** The data of GDEF that tells which glyphs a lookup skips. */\nexport interface GlyphFilter {\n /** This function gives the GDEF class of a glyph: 1 base, 2 ligature, 3 mark, 4 component, 0 none. */\n glyphClass(glyph: number): number;\n /** This function gives the mark attachment class of a glyph, or 0. */\n markAttachClass(glyph: number): number;\n /** This function tells if a glyph is in the mark filtering set `set`. */\n inMarkSet(set: number, glyph: number): boolean;\n}\n\n/** This function reads the glyph classes, the mark attachment classes and the mark filtering sets of GDEF. */\nexport function readGlyphFilter(gdef: Reader | undefined, glyphClass: (glyph: number) => number): GlyphFilter {\n const attachOffset = gdef === undefined ? 0 : gdef.u16(10);\n const attach = attachOffset === 0 ? undefined : gdef!.part(attachOffset);\n // GDEF 1.2 adds the MarkGlyphSetsDef table\n const setsOffset = gdef === undefined || gdef.u16(2) < 2 ? 0 : gdef.u16(12);\n const sets = setsOffset === 0 ? undefined : gdef!.part(setsOffset);\n return {\n glyphClass,\n markAttachClass: (glyph) => (attach === undefined ? 0 : classOf(attach, glyph)),\n inMarkSet(set, glyph) {\n if (sets === undefined || set >= sets.u16(2)) return false;\n return coverageIndex(sets.part(sets.u32(4 + set * 4)), glyph) >= 0;\n },\n };\n}\n\n/** The glyph property of HarfBuzz for a glyph that a substitution changed. */\nexport const SUBSTITUTED = 0x10;\n/** The glyph property of HarfBuzz for a glyph that a ligature substitution made. */\nexport const LIGATED = 0x20;\n/** The glyph property of HarfBuzz for a glyph that a multiple substitution made, with more than one glyph. */\nexport const MULTIPLIED = 0x40;\n\n/**\n * The data that a syllabic shaper keeps with each glyph, as the `hb_glyph_info_t` of HarfBuzz keeps it. A substitution\n * gives each new glyph a copy of the data of the glyph that it replaces. A ligature keeps the data of its first glyph.\n */\nexport interface GlyphInfo {\n /** The feature mask. A lookup starts only at a glyph with a bit of the mask of the lookup. */\n mask: number;\n /** The syllable byte of HarfBuzz: the serial number in the high 4 bits, and the syllable type in the low 4 bits. */\n syllable: number;\n /** The glyph properties `SUBSTITUTED`, `LIGATED` and `MULTIPLIED`. */\n props: number;\n /** The category of the shaper. */\n category: number;\n /** The position of the shaper. */\n position: number;\n /** The code point of the character of the glyph, after the normalization. */\n readonly codePoint: number;\n}\n\n/** One substitution that a lookup can do, with no context. */\nexport interface SubstitutionRule {\n /** The glyph that the rule replaces. The first glyph of a ligature is this glyph. */\n readonly from: number;\n /** The glyphs that replace it. A multiple substitution can give no glyph. */\n readonly to: readonly number[];\n /** The other glyphs of a ligature, in order. Another rule has no such glyphs. */\n readonly components?: readonly number[];\n}\n\n/** A lookup of GSUB for one script and one set of features. */\nexport interface SubstitutionLookup {\n /** The index of the lookup in the lookup list of GSUB. */\n readonly index: number;\n /** The lookup type, from 1 to 8. The type of an Extension lookup is the type of its subtables. */\n readonly type: number;\n /** The lookup flags. */\n readonly flags: number;\n /** The tags of the features that use the lookup. */\n readonly features: readonly string[];\n /**\n * This function applies the lookup to all the glyphs of a text. It changes the array. The array `masks`, when it is\n * given, has one mask for each glyph. Then the lookup starts only at a glyph whose mask has a bit of `mask`, as the\n * feature masks of HarfBuzz do. The function keeps `masks` in step with the glyphs.\n */\n apply(glyphs: number[], masks?: number[], mask?: number): void;\n /**\n * This function applies the lookup with the data `infos` of the glyphs, as HarfBuzz applies a lookup of a syllabic shaper.\n * The lookup starts at a glyph with a bit of `mask`, and each input glyph after it also needs a bit of `mask`. When\n * `perSyllable` is true, all the matched glyphs have the syllable of the first glyph. The function keeps `infos` in step.\n */\n applyInfos(glyphs: number[], infos: GlyphInfo[], mask: number, perSyllable: boolean): void;\n /**\n * This function tells if the lookup changes the glyph sequence `glyphs` when the sequence is all the text, as\n * `hb_ot_layout_lookup_would_substitute` with zero context tells it. A context rule with backtrack or lookahead does not apply.\n */\n wouldApply(glyphs: readonly number[]): boolean;\n /**\n * This function gives the rules of the lookup, and the rules of each lookup that it nests in a context rule. Each lookup\n * has one list, and the list of this lookup is the first. The lists do not tell a context, so each nested rule counts.\n * An alternate substitution gives one rule for each alternate.\n */\n rules(): readonly (readonly SubstitutionRule[])[];\n}\n\n/** One lookup of the lookup list, with the subtables of an extension lookup resolved. */\ninterface Lookup {\n readonly type: number;\n readonly flags: number;\n readonly subtables: readonly Reader[];\n readonly skip: (glyph: number) => boolean;\n}\n\n/** One SubstLookupRecord of a context rule: the input position and the lookup to apply there. */\ninterface SequenceRecord {\n readonly sequenceIndex: number;\n readonly lookupIndex: number;\n}\n\nfunction records(table: Reader, at: number, count: number): SequenceRecord[] {\n return Array.from({ length: count }, (_, k) => ({ sequenceIndex: table.u16(at + k * 4), lookupIndex: table.u16(at + k * 4 + 2) }));\n}\n\n/** This function gives each rule table of the rule sets at `at` of a context subtable of format 1 or 2. An offset 0 is an empty set. */\nfunction ruleTables(t: Reader, at: number): Reader[] {\n const tables: Reader[] = [];\n for (let s = 0; s < t.u16(at); s++) {\n const offset = t.u16(at + 2 + s * 2);\n if (offset === 0) continue;\n const set = t.part(offset);\n for (let r = 0; r < set.u16(0); r++) tables.push(set.part(set.u16(2 + r * 2)));\n }\n return tables;\n}\n\n/** This function gives the records of each rule of a context subtable (lookup type 5). */\nfunction contextRecords(t: Reader): SequenceRecord[] {\n const format = t.u16(0);\n if (format === 3) return records(t, 6 + t.u16(2) * 2, t.u16(4));\n return ruleTables(t, format === 2 ? 6 : 4).flatMap((rule) => records(rule, 4 + (rule.u16(0) - 1) * 2, rule.u16(2)));\n}\n\n/** This function gives the records of each rule of a chained context subtable (lookup type 6). */\nfunction chainRecords(t: Reader): SequenceRecord[] {\n const format = t.u16(0);\n if (format === 3) {\n const inputAt = 4 + t.u16(2) * 2;\n const aheadAt = inputAt + 2 + t.u16(inputAt) * 2;\n const recordsAt = aheadAt + 2 + t.u16(aheadAt) * 2;\n return records(t, recordsAt + 2, t.u16(recordsAt));\n }\n return ruleTables(t, format === 2 ? 10 : 4).flatMap((rule) => {\n const inputAt = 2 + rule.u16(0) * 2;\n const aheadAt = inputAt + 2 + Math.max(0, rule.u16(inputAt) - 1) * 2;\n const recordsAt = aheadAt + 2 + rule.u16(aheadAt) * 2;\n return records(rule, recordsAt + 2, rule.u16(recordsAt));\n });\n}\n\n/** This function adds the rules of one subtable of a lookup type to `rules`, and each nested lookup to `nested`. */\nfunction readRules(type: number, t: Reader, rules: SubstitutionRule[], nested: number[]): void {\n if (type === 5 || type === 6) {\n for (const record of type === 5 ? contextRecords(t) : chainRecords(t)) nested.push(record.lookupIndex);\n return;\n }\n if (type < 1 || type > 8 || type === 7) return;\n const format = t.u16(0);\n for (const [from, index] of coverageGlyphs(t.part(t.u16(2)))) {\n if (type === 1) rules.push({ from, to: [format === 1 ? (from + t.i16(4)) & 0xffff : t.u16(6 + index * 2)] });\n else if (type === 2) {\n const sequence = t.part(t.u16(6 + index * 2));\n rules.push({ from, to: Array.from({ length: sequence.u16(0) }, (_, k) => sequence.u16(2 + k * 2)) });\n } else if (type === 3) {\n const set = t.part(t.u16(6 + index * 2));\n for (let k = 0; k < set.u16(0); k++) rules.push({ from, to: [set.u16(2 + k * 2)] });\n } else if (type === 4) {\n const set = t.part(t.u16(6 + index * 2));\n for (let l = 0; l < set.u16(0); l++) {\n const ligature = set.part(set.u16(2 + l * 2));\n rules.push({ from, to: [ligature.u16(0)], components: Array.from({ length: ligature.u16(2) - 1 }, (_, k) => ligature.u16(4 + k * 2)) });\n }\n } else {\n const aheadAt = 6 + t.u16(4) * 2;\n rules.push({ from, to: [t.u16(aheadAt + 2 + t.u16(aheadAt) * 2 + 2 + index * 2)] });\n }\n }\n}\n\n/** The lookups of one GSUB table. It reads each lookup at its first use. */\nclass Gsub {\n private readonly lookups: Reader;\n private readonly filter: GlyphFilter;\n private readonly cache = new Map<number, Lookup>();\n\n constructor(table: Reader, filter: GlyphFilter) {\n this.lookups = table.part(table.u16(8));\n this.filter = filter;\n }\n\n lookup(index: number): Lookup | undefined {\n if (index >= this.lookups.u16(0)) return undefined;\n let found = this.cache.get(index);\n if (found === undefined) {\n const table = this.lookups.part(this.lookups.u16(2 + index * 2));\n const type = table.u16(0);\n const flags = table.u16(2);\n const count = table.u16(4);\n const markSet = (flags & USE_MARK_FILTERING_SET) !== 0 ? table.u16(6 + count * 2) : -1;\n const subtables: Reader[] = [];\n let subtype = type;\n for (let s = 0; s < count; s++) {\n const subtable = table.part(table.u16(6 + s * 2));\n if (type === 7) {\n subtype = subtable.u16(2);\n subtables.push(subtable.part(subtable.u32(4)));\n } else subtables.push(subtable);\n }\n const { glyphClass, markAttachClass, inMarkSet } = this.filter;\n const skip = (glyph: number): boolean => {\n const kind = glyphClass(glyph);\n if ((flags & IGNORE_BASE) !== 0 && kind === 1) return true;\n if ((flags & IGNORE_LIGATURES) !== 0 && kind === 2) return true;\n if (kind !== 3) return false;\n if ((flags & IGNORE_MARKS) !== 0) return true;\n if (markSet >= 0) return !inMarkSet(markSet, glyph);\n const attach = flags >> 8;\n return attach !== 0 && markAttachClass(glyph) !== attach;\n };\n found = { type: subtype, flags, subtables, skip };\n this.cache.set(index, found);\n }\n return found;\n }\n\n /**\n * The masks of the glyphs of the current call of `applyAll`, or `undefined`. A substitution that adds or removes glyphs\n * changes this array in the same way.\n */\n private masks: number[] | undefined;\n\n /** The data of the glyphs of the current call of `applyRun`, or `undefined`. */\n private infos: GlyphInfo[] | undefined;\n /** The mask of the current call of `applyRun`. Each input glyph needs a bit of it. */\n private lookupMask = -1;\n /** It is true when the matched glyphs of the current call of `applyRun` need the syllable of the first glyph. */\n private perSyllable = false;\n\n /**\n * This function replaces `count` glyphs at `at` with `replacement`. Each new glyph gets the mask and the data of the\n * glyph at `at`.\n */\n private splice(glyphs: number[], at: number, count: number, replacement: readonly number[]): void {\n glyphs.splice(at, count, ...replacement);\n const masks = this.masks;\n if (masks !== undefined) masks.splice(at, count, ...replacement.map(() => masks[at] ?? 0));\n const infos = this.infos;\n if (infos !== undefined) {\n const source = infos[at]!;\n infos.splice(at, count, ...replacement.map(() => ({ ...source })));\n }\n }\n\n /** This function adds the glyph properties `set` to the glyph at `i`, and then removes the properties `clear`. */\n private setProps(i: number, set: number, clear = 0): void {\n const info = this.infos?.[i];\n if (info !== undefined) info.props = (info.props | set) & ~clear;\n }\n\n /**\n * This function tells if the glyph at `j` can match for the glyph at `first`. An input glyph needs a bit of the mask of\n * the lookup. With the per-syllable matching, each glyph needs the syllable of `first`.\n */\n private admits(j: number, first: number, input: boolean): boolean {\n const infos = this.infos;\n if (infos === undefined) return true;\n if (input && (infos[j]!.mask & this.lookupMask) === 0) return false;\n const syllable = infos[first]?.syllable ?? 0;\n return !this.perSyllable || syllable === 0 || infos[j]!.syllable === syllable;\n }\n\n /** This function applies a lookup to all the glyphs with their data `infos`, as `applyInfos` of `SubstitutionLookup` tells. */\n applyRun(index: number, glyphs: number[], infos: GlyphInfo[], mask: number, perSyllable: boolean): void {\n const lookup = this.lookup(index);\n if (lookup === undefined) return;\n this.infos = infos;\n this.lookupMask = mask;\n this.perSyllable = perSyllable;\n try {\n this.applyMasked(lookup, glyphs, (i) => (infos[i]!.mask & mask) !== 0);\n } finally {\n this.infos = undefined;\n this.lookupMask = -1;\n this.perSyllable = false;\n }\n }\n\n /**\n * This function applies a lookup to all the glyphs, as the main loop of a shaper does. With `masks`, the lookup starts\n * only at a glyph whose mask has a bit of `mask`.\n */\n applyAll(index: number, glyphs: number[], masks?: number[], mask = -1): void {\n const lookup = this.lookup(index);\n if (lookup === undefined) return;\n this.masks = masks;\n try {\n this.applyMasked(lookup, glyphs, (i) => masks === undefined || ((masks[i] ?? 0) & mask) !== 0);\n } finally {\n this.masks = undefined;\n }\n }\n\n private applyMasked(lookup: Lookup, glyphs: number[], selected: (i: number) => boolean): void {\n if (lookup.type === 8) {\n for (let i = glyphs.length - 1; i >= 0; i--) if (selected(i) && !lookup.skip(glyphs[i]!)) this.reverse(lookup, glyphs, i);\n return;\n }\n let i = 0;\n while (i < glyphs.length) {\n if (!selected(i) || lookup.skip(glyphs[i]!)) {\n i++;\n continue;\n }\n const before = glyphs.length;\n const next = this.applyAt(lookup, glyphs, i, 0);\n // A deletion (a Sequence with no glyph) gives the same position, and the text is shorter\n i = next < 0 ? i + 1 : next > i || glyphs.length < before ? next : i + 1;\n }\n }\n\n /** This function applies the first subtable of a lookup that matches at `i`. It gives the next position, or -1. */\n private applyAt(lookup: Lookup, glyphs: number[], i: number, depth: number): number {\n for (const subtable of lookup.subtables) {\n const next = this.subtable(lookup, subtable, glyphs, i, depth);\n if (next >= 0) return next;\n }\n return -1;\n }\n\n private nextOf(lookup: Lookup, glyphs: readonly number[], from: number): number {\n for (let j = from; j < glyphs.length; j++) if (!lookup.skip(glyphs[j]!)) return j;\n return -1;\n }\n\n private previousOf(lookup: Lookup, glyphs: readonly number[], from: number): number {\n for (let j = from; j >= 0; j--) if (!lookup.skip(glyphs[j]!)) return j;\n return -1;\n }\n\n /**\n * This function matches `count` glyphs after the position `i` with a test for each. It gives the positions of the\n * matched glyphs, the first glyph at `i` included, or `undefined`.\n */\n private matchInput(lookup: Lookup, glyphs: readonly number[], i: number, count: number, test: (k: number, glyph: number) => boolean): number[] | undefined {\n const positions = [i];\n let at = i;\n for (let k = 0; k < count; k++) {\n at = this.nextOf(lookup, glyphs, at + 1);\n if (at < 0 || !this.admits(at, i, true) || !test(k, glyphs[at]!)) return undefined;\n positions.push(at);\n }\n return positions;\n }\n\n private matchBacktrack(lookup: Lookup, glyphs: readonly number[], i: number, count: number, test: (k: number, glyph: number) => boolean): boolean {\n let at = i;\n for (let k = 0; k < count; k++) {\n at = this.previousOf(lookup, glyphs, at - 1);\n if (at < 0 || !this.admits(at, i, false) || !test(k, glyphs[at]!)) return false;\n }\n return true;\n }\n\n private matchLookahead(lookup: Lookup, glyphs: readonly number[], first: number, last: number, count: number, test: (k: number, glyph: number) => boolean): boolean {\n let at = last;\n for (let k = 0; k < count; k++) {\n at = this.nextOf(lookup, glyphs, at + 1);\n if (at < 0 || !this.admits(at, first, false) || !test(k, glyphs[at]!)) return false;\n }\n return true;\n }\n\n /** This function applies the lookups of the records of a context rule at the matched positions. It gives the next position. */\n private applyRecords(glyphs: number[], positions: number[], list: readonly SequenceRecord[], depth: number): number {\n if (depth < MAX_NESTING) {\n for (const record of list) {\n const at = positions[record.sequenceIndex];\n const nested = this.lookup(record.lookupIndex);\n if (at === undefined || at >= glyphs.length || nested === undefined || nested.skip(glyphs[at]!)) continue;\n const before = glyphs.length;\n if (nested.type === 8) this.reverse(nested, glyphs, at);\n else this.applyAt(nested, glyphs, at, depth + 1);\n const delta = glyphs.length - before;\n if (delta > 0) {\n for (let k = record.sequenceIndex + 1; k < positions.length; k++) positions[k] = positions[k]! + delta;\n positions.splice(record.sequenceIndex + 1, 0, ...Array.from({ length: delta }, (_, k) => at + 1 + k));\n } else if (delta < 0) {\n // A ligature took the next input glyphs: remove their positions and move the others\n positions.splice(record.sequenceIndex + 1, Math.min(-delta, positions.length - record.sequenceIndex - 1));\n for (let k = record.sequenceIndex + 1; k < positions.length; k++) positions[k] = positions[k]! + delta;\n }\n }\n }\n return Math.min(glyphs.length, positions[positions.length - 1]! + 1);\n }\n\n private reverse(lookup: Lookup, glyphs: number[], i: number): boolean {\n for (const t of lookup.subtables) {\n const index = coverageIndex(t.part(t.u16(2)), glyphs[i]!);\n if (index < 0) continue;\n const backCount = t.u16(4);\n const aheadAt = 6 + backCount * 2;\n const aheadCount = t.u16(aheadAt);\n const substituteAt = aheadAt + 2 + aheadCount * 2;\n if (!this.matchBacktrack(lookup, glyphs, i, backCount, (k, g) => coverageIndex(t.part(t.u16(6 + k * 2)), g) >= 0)) continue;\n if (!this.matchLookahead(lookup, glyphs, i, i, aheadCount, (k, g) => coverageIndex(t.part(t.u16(aheadAt + 2 + k * 2)), g) >= 0)) continue;\n glyphs[i] = t.u16(substituteAt + 2 + index * 2);\n this.setProps(i, SUBSTITUTED);\n return true;\n }\n return false;\n }\n\n /** This function tells if a lookup changes the sequence `glyphs` with no context, as `wouldApply` of `SubstitutionLookup` tells. */\n wouldApply(index: number, glyphs: readonly number[]): boolean {\n const lookup = this.lookup(index);\n if (lookup === undefined || glyphs.length === 0) return false;\n const [first] = glyphs as [number];\n return lookup.subtables.some((t) => {\n const format = t.u16(0);\n if (lookup.type === 1 || lookup.type === 2 || lookup.type === 3 || lookup.type === 8) return glyphs.length === 1 && coverageIndex(t.part(t.u16(2)), first) >= 0;\n if (lookup.type === 4) {\n const index = coverageIndex(t.part(t.u16(2)), first);\n if (index < 0) return false;\n const set = t.part(t.u16(6 + index * 2));\n return Array.from({ length: set.u16(0) }, (_, l) => set.part(set.u16(2 + l * 2))).some((ligature) => ligature.u16(2) === glyphs.length && glyphs.every((g, k) => k === 0 || ligature.u16(4 + (k - 1) * 2) === g));\n }\n if (lookup.type !== 5 && lookup.type !== 6) return false;\n const chain = lookup.type === 6;\n if (format === 3) {\n const backCount = chain ? t.u16(2) : 0;\n const inputAt = chain ? 4 + backCount * 2 : 2;\n const count = t.u16(inputAt);\n const coverageAt = chain ? inputAt + 2 : 6;\n if (chain && (backCount !== 0 || t.u16(inputAt + 2 + count * 2) !== 0)) return false;\n return count === glyphs.length && glyphs.every((g, k) => coverageIndex(t.part(t.u16(coverageAt + k * 2)), g) >= 0);\n }\n const index = coverageIndex(t.part(t.u16(2)), first);\n if (index < 0) return false;\n const classes = format === 2 ? t.part(t.u16(chain ? 6 : 4)) : undefined;\n const value = (g: number) => (classes === undefined ? g : classOf(classes, g));\n const setIndex = classes === undefined ? index : value(first);\n const setCountAt = chain ? (format === 2 ? 10 : 4) : format === 2 ? 6 : 4;\n if (setIndex >= t.u16(setCountAt) || t.u16(setCountAt + 2 + setIndex * 2) === 0) return false;\n const set = t.part(t.u16(setCountAt + 2 + setIndex * 2));\n for (let r = 0; r < set.u16(0); r++) {\n const rule = set.part(set.u16(2 + r * 2));\n const backCount = chain ? rule.u16(0) : 0;\n const inputAt = chain ? 2 + backCount * 2 : 0;\n const count = rule.u16(inputAt);\n const inputStart = chain ? inputAt + 2 : 4;\n if (chain && (backCount !== 0 || rule.u16(inputStart + Math.max(0, count - 1) * 2) !== 0)) continue;\n if (count === glyphs.length && glyphs.every((g, k) => k === 0 || value(g) === rule.u16(inputStart + (k - 1) * 2))) return true;\n }\n return false;\n });\n }\n\n /** This function gives the rules of a lookup and of each lookup that it nests, as `rules` of `SubstitutionLookup` tells. */\n rulesOf(index: number): SubstitutionRule[][] {\n const lists: SubstitutionRule[][] = [];\n const seen = new Set<number>();\n const visit = (at: number): void => {\n const lookup = this.lookup(at);\n if (seen.has(at) || lookup === undefined) return;\n seen.add(at);\n const rules: SubstitutionRule[] = [];\n const nested: number[] = [];\n for (const subtable of lookup.subtables) readRules(lookup.type, subtable, rules, nested);\n lists.push(rules);\n nested.forEach(visit);\n };\n visit(index);\n return lists;\n }\n\n /** This function applies one subtable at `i`. It gives the next position, or -1 when the subtable does not match. */\n private subtable(lookup: Lookup, t: Reader, glyphs: number[], i: number, depth: number): number {\n const glyph = glyphs[i]!;\n const format = t.u16(0);\n switch (lookup.type) {\n case 1: {\n const index = coverageIndex(t.part(t.u16(2)), glyph);\n if (index < 0) return -1;\n glyphs[i] = format === 1 ? (glyph + t.i16(4)) & 0xffff : t.u16(6 + index * 2);\n this.setProps(i, SUBSTITUTED);\n return i + 1;\n }\n case 2: {\n const index = coverageIndex(t.part(t.u16(2)), glyph);\n if (index < 0) return -1;\n const sequence = t.part(t.u16(6 + index * 2));\n const replacement = Array.from({ length: sequence.u16(0) }, (_, k) => sequence.u16(2 + k * 2));\n this.splice(glyphs, i, 1, replacement);\n for (let k = 0; k < replacement.length; k++) this.setProps(i + k, replacement.length > 1 ? SUBSTITUTED | MULTIPLIED : SUBSTITUTED);\n return i + replacement.length;\n }\n case 3: {\n const index = coverageIndex(t.part(t.u16(2)), glyph);\n if (index < 0) return -1;\n const set = t.part(t.u16(6 + index * 2));\n if (set.u16(0) > 0) glyphs[i] = set.u16(2);\n this.setProps(i, SUBSTITUTED);\n return i + 1;\n }\n case 4: {\n const index = coverageIndex(t.part(t.u16(2)), glyph);\n if (index < 0) return -1;\n const set = t.part(t.u16(6 + index * 2));\n for (let l = 0; l < set.u16(0); l++) {\n const ligature = set.part(set.u16(2 + l * 2));\n const components = ligature.u16(2);\n const positions = this.matchInput(lookup, glyphs, i, components - 1, (k, g) => g === ligature.u16(4 + k * 2));\n if (positions === undefined) continue;\n glyphs[i] = ligature.u16(0);\n // A ligature is not a multiplied glyph, even when one of its glyphs was\n this.setProps(i, SUBSTITUTED | LIGATED, MULTIPLIED);\n for (let k = positions.length - 1; k >= 1; k--) this.splice(glyphs, positions[k]!, 1, []);\n return i + 1;\n }\n return -1;\n }\n case 5:\n return this.context(lookup, t, glyphs, i, depth);\n case 6:\n return this.chainContext(lookup, t, glyphs, i, depth);\n case 8:\n return this.reverse(lookup, glyphs, i) ? i + 1 : -1;\n default:\n return -1;\n }\n }\n\n private context(lookup: Lookup, t: Reader, glyphs: number[], i: number, depth: number): number {\n const glyph = glyphs[i]!;\n const format = t.u16(0);\n if (format === 3) {\n const count = t.u16(2);\n const recordCount = t.u16(4);\n if (count === 0 || coverageIndex(t.part(t.u16(6)), glyph) < 0) return -1;\n const positions = this.matchInput(lookup, glyphs, i, count - 1, (k, g) => coverageIndex(t.part(t.u16(8 + k * 2)), g) >= 0);\n if (positions === undefined) return -1;\n return this.applyRecords(glyphs, positions, records(t, 6 + count * 2, recordCount), depth);\n }\n const index = coverageIndex(t.part(t.u16(2)), glyph);\n if (index < 0) return -1;\n const classes = format === 2 ? t.part(t.u16(4)) : undefined;\n const setIndex = classes === undefined ? index : classOf(classes, glyph);\n const setCount = t.u16(classes === undefined ? 4 : 6);\n if (setIndex >= setCount) return -1;\n const setOffset = t.u16((classes === undefined ? 6 : 8) + setIndex * 2);\n if (setOffset === 0) return -1;\n const set = t.part(setOffset);\n const value = (g: number) => (classes === undefined ? g : classOf(classes, g));\n for (let r = 0; r < set.u16(0); r++) {\n const rule = set.part(set.u16(2 + r * 2));\n const count = rule.u16(0);\n const recordCount = rule.u16(2);\n const positions = this.matchInput(lookup, glyphs, i, count - 1, (k, g) => value(g) === rule.u16(4 + k * 2));\n if (positions === undefined) continue;\n return this.applyRecords(glyphs, positions, records(rule, 4 + (count - 1) * 2, recordCount), depth);\n }\n return -1;\n }\n\n private chainContext(lookup: Lookup, t: Reader, glyphs: number[], i: number, depth: number): number {\n const glyph = glyphs[i]!;\n const format = t.u16(0);\n if (format === 3) {\n const backCount = t.u16(2);\n const inputAt = 4 + backCount * 2;\n const inputCount = t.u16(inputAt);\n const aheadAt = inputAt + 2 + inputCount * 2;\n const aheadCount = t.u16(aheadAt);\n const recordsAt = aheadAt + 2 + aheadCount * 2;\n const covers = (offset: number, g: number) => coverageIndex(t.part(t.u16(offset)), g) >= 0;\n if (inputCount === 0 || !covers(inputAt + 2, glyph)) return -1;\n if (!this.matchBacktrack(lookup, glyphs, i, backCount, (k, g) => covers(4 + k * 2, g))) return -1;\n const positions = this.matchInput(lookup, glyphs, i, inputCount - 1, (k, g) => covers(inputAt + 4 + k * 2, g));\n if (positions === undefined) return -1;\n if (!this.matchLookahead(lookup, glyphs, i, positions[positions.length - 1]!, aheadCount, (k, g) => covers(aheadAt + 2 + k * 2, g))) return -1;\n return this.applyRecords(glyphs, positions, records(t, recordsAt + 2, t.u16(recordsAt)), depth);\n }\n const index = coverageIndex(t.part(t.u16(2)), glyph);\n if (index < 0) return -1;\n const byClass = format === 2;\n const backClasses = byClass ? t.part(t.u16(4)) : undefined;\n const inputClasses = byClass ? t.part(t.u16(6)) : undefined;\n const aheadClasses = byClass ? t.part(t.u16(8)) : undefined;\n const setIndex = inputClasses === undefined ? index : classOf(inputClasses, glyph);\n const setCount = t.u16(byClass ? 10 : 4);\n if (setIndex >= setCount) return -1;\n const setOffset = t.u16((byClass ? 12 : 6) + setIndex * 2);\n if (setOffset === 0) return -1;\n const set = t.part(setOffset);\n const valueIn = (classes: Reader | undefined, g: number) => (classes === undefined ? g : classOf(classes, g));\n for (let r = 0; r < set.u16(0); r++) {\n const rule = set.part(set.u16(2 + r * 2));\n const backCount = rule.u16(0);\n const inputAt = 2 + backCount * 2;\n const inputCount = rule.u16(inputAt);\n const aheadAt = inputAt + 2 + Math.max(0, inputCount - 1) * 2;\n const aheadCount = rule.u16(aheadAt);\n const recordsAt = aheadAt + 2 + aheadCount * 2;\n if (!this.matchBacktrack(lookup, glyphs, i, backCount, (k, g) => valueIn(backClasses, g) === rule.u16(2 + k * 2))) continue;\n const positions = this.matchInput(lookup, glyphs, i, inputCount - 1, (k, g) => valueIn(inputClasses, g) === rule.u16(inputAt + 2 + k * 2));\n if (positions === undefined) continue;\n if (!this.matchLookahead(lookup, glyphs, i, positions[positions.length - 1]!, aheadCount, (k, g) => valueIn(aheadClasses, g) === rule.u16(aheadAt + 2 + k * 2))) continue;\n return this.applyRecords(glyphs, positions, records(rule, recordsAt + 2, rule.u16(recordsAt)), depth);\n }\n return -1;\n }\n}\n\n/**\n * This function gives the lookups of the features `features` of GSUB for a script, in the order of the lookup list, as\n * HarfBuzz applies them. The lookups include the lookups of the necessary feature of the language system.\n */\nexport function readSubstitutions(gsub: Reader, script: string, features: readonly string[], filter: GlyphFilter): SubstitutionLookup[] {\n const scripts = gsub.part(gsub.u16(4));\n const featureList = gsub.part(gsub.u16(6));\n const scriptCount = scripts.u16(0);\n let langSys: Reader | undefined;\n for (const wanted of scriptTags(script)) {\n for (let i = 0; i < scriptCount && langSys === undefined; i++) {\n if (scripts.tag(2 + i * 6) !== wanted) continue;\n const table = scripts.part(scripts.u16(2 + i * 6 + 4));\n const fallback = table.u16(0);\n if (fallback !== 0) langSys = table.part(fallback);\n }\n if (langSys !== undefined) break;\n }\n if (langSys === undefined || features.length === 0) return [];\n const wanted = new Set(features);\n const indices = new Map<number, string[]>();\n const add = (featureIndex: number, required: boolean) => {\n const record = 2 + featureIndex * 6;\n if (featureIndex >= featureList.u16(0)) return;\n const tag = featureList.tag(record);\n if (!required && !wanted.has(tag)) return;\n const feature = featureList.part(featureList.u16(record + 4));\n for (let k = 0; k < feature.u16(2); k++) {\n const index = feature.u16(4 + k * 2);\n const tags = indices.get(index) ?? [];\n if (!tags.includes(tag)) tags.push(tag);\n indices.set(index, tags);\n }\n };\n const required = langSys.u16(2);\n if (required !== 0xffff) add(required, true);\n for (let i = 0; i < langSys.u16(4); i++) add(langSys.u16(6 + i * 2), false);\n const table = new Gsub(gsub, filter);\n const result: SubstitutionLookup[] = [];\n for (const [index, tags] of [...indices].sort(([a], [b]) => a - b)) {\n const lookup = table.lookup(index);\n if (lookup === undefined) continue;\n result.push({\n index,\n type: lookup.type,\n flags: lookup.flags,\n features: tags,\n apply: (glyphs: number[], masks?: number[], mask?: number) => table.applyAll(index, glyphs, masks, mask),\n applyInfos: (glyphs: number[], infos: GlyphInfo[], mask: number, perSyllable: boolean) => table.applyRun(index, glyphs, infos, mask, perSyllable),\n wouldApply: (glyphs: readonly number[]) => table.wouldApply(index, glyphs),\n rules: () => table.rulesOf(index),\n });\n }\n return result;\n}\n","import type { Reader } from \"./binary.ts\";\n\n/** One axis of `fvar`, in the user units of the axis. */\nexport interface Axis {\n readonly tag: string;\n readonly min: number;\n readonly default: number;\n readonly max: number;\n}\n\n/** The coordinates of an instance in user units, by axis tag. An axis that is absent has its default value. */\nexport type Instance = Readonly<Record<string, number>>;\n\n/** This function reads a 16.16 fixed number. */\nfunction fixed(table: Reader, offset: number): number {\n return (table.u16(offset) << 16 >> 16) + table.u16(offset + 2) / 65536;\n}\n\n/** This function reads a 2.14 fixed number. */\nfunction f2dot14(table: Reader, offset: number): number {\n return table.i16(offset) / 16384;\n}\n\n/** This function rounds a number to the 2.14 grid, as HarfBuzz and FreeType do with each normalized coordinate. */\nfunction toF2dot14(value: number): number {\n return Math.round(value * 16384) / 16384;\n}\n\n/** This function gives the axes of `fvar`. */\nexport function readAxes(fvar: Reader): Axis[] {\n const offset = fvar.u16(4);\n const count = fvar.u16(8);\n const size = fvar.u16(10);\n const axes: Axis[] = [];\n for (let i = 0; i < count; i++) {\n const at = offset + i * size;\n axes.push({ tag: fvar.tag(at), min: fixed(fvar, at + 4), default: fixed(fvar, at + 8), max: fixed(fvar, at + 12) });\n }\n return axes;\n}\n\n/**\n * This function gives the normalized coordinates of an instance. Each coordinate is in -1 to 1, on the 2.14 grid. The\n * segment maps of `avar` change it when the font has them. A value outside the range of an axis is clamped to the range.\n */\nexport function normalize(axes: readonly Axis[], avar: Reader | undefined, instance: Instance): number[] {\n const coordinates = axes.map((axis) => {\n const value = Math.min(axis.max, Math.max(axis.min, instance[axis.tag] ?? axis.default));\n if (value < axis.default) return toF2dot14(axis.default === axis.min ? 0 : (value - axis.default) / (axis.default - axis.min));\n if (value > axis.default) return toF2dot14(axis.max === axis.default ? 0 : (value - axis.default) / (axis.max - axis.default));\n return 0;\n });\n if (avar === undefined || avar.u16(0) !== 1) return coordinates;\n let at = 8;\n const count = Math.min(avar.u16(6), axes.length);\n for (let a = 0; a < count; a++) {\n const pairs = avar.u16(at);\n const from: number[] = [];\n const to: number[] = [];\n for (let p = 0; p < pairs; p++) {\n from.push(f2dot14(avar, at + 2 + p * 4));\n to.push(f2dot14(avar, at + 4 + p * 4));\n }\n at += 2 + pairs * 4;\n coordinates[a] = toF2dot14(mapSegment(from, to, coordinates[a]!));\n }\n return coordinates;\n}\n\n/** This function maps a coordinate through one segment map of `avar`, by linear interpolation between its points. */\nfunction mapSegment(from: readonly number[], to: readonly number[], value: number): number {\n if (from.length === 0) return value;\n if (value <= from[0]!) return to[0]! + value - from[0]!;\n for (let i = 1; i < from.length; i++) {\n if (value === from[i]) return to[i]!;\n if (value < from[i]!) return to[i - 1]! + ((value - from[i - 1]!) * (to[i]! - to[i - 1]!)) / (from[i]! - from[i - 1]!);\n }\n return to[to.length - 1]! + value - from[from.length - 1]!;\n}\n\n/** An ItemVariationStore at fixed coordinates. */\nexport interface VariationStore {\n /** This function gives the delta of the item `inner` of the data `outer`, in font units, not rounded. */\n delta(outer: number, inner: number): number;\n}\n\n/** This function reads an ItemVariationStore and computes the scalar of each region at the coordinates. */\nexport function readVariationStore(store: Reader, coordinates: readonly number[]): VariationStore {\n const regions = store.part(store.u32(2));\n const axisCount = regions.u16(0);\n const regionCount = regions.u16(2);\n const scalars: number[] = [];\n for (let r = 0; r < regionCount; r++) {\n let scalar = 1;\n for (let a = 0; a < axisCount && scalar !== 0; a++) {\n const at = 4 + (r * axisCount + a) * 6;\n scalar *= axisScalar(f2dot14(regions, at), f2dot14(regions, at + 2), f2dot14(regions, at + 4), coordinates[a] ?? 0);\n }\n scalars.push(scalar);\n }\n const dataCount = store.u16(6);\n const data = Array.from({ length: dataCount }, (_, i) => store.part(store.u32(8 + i * 4)));\n return {\n delta(outer, inner) {\n const table = data[outer];\n if (table === undefined || inner >= table.u16(0)) return 0;\n const wordField = table.u16(2);\n const longWords = (wordField & 0x8000) !== 0;\n const words = wordField & 0x7fff;\n const count = table.u16(4);\n const wordSize = longWords ? 4 : 2;\n const smallSize = longWords ? 2 : 1;\n const rowSize = words * wordSize + (count - words) * smallSize;\n let at = 6 + count * 2 + inner * rowSize;\n let sum = 0;\n for (let i = 0; i < count; i++) {\n let value: number;\n if (i < words) {\n value = longWords ? table.u32(at) | 0 : table.i16(at);\n at += wordSize;\n } else {\n value = longWords ? table.i16(at) : (table.u8(at) << 24) >> 24;\n at += smallSize;\n }\n const scalar = scalars[table.u16(6 + i * 2)] ?? 0;\n if (scalar !== 0) sum += scalar * value;\n }\n return sum;\n },\n };\n}\n\n/** This function gives the scalar of one axis of a region, as the OpenType specification defines it. */\nexport function axisScalar(start: number, peak: number, end: number, value: number): number {\n if (start > peak || peak > end) return 1;\n if (start < 0 && end > 0 && peak !== 0) return 1;\n if (peak === 0 || value === peak) return 1;\n if (value <= start || value >= end) return 0;\n return value < peak ? (value - start) / (peak - start) : (end - value) / (end - peak);\n}\n\n/** This function gives the outer and inner index of a glyph in a DeltaSetIndexMap. A glyph after the end uses the last entry. */\nexport function mapIndex(map: Reader, index: number): [outer: number, inner: number] {\n const format = map.u8(0);\n const entryFormat = map.u8(1);\n const count = format === 0 ? map.u16(2) : map.u32(2);\n const start = format === 0 ? 4 : 6;\n if (count === 0) return [0, index];\n const size = ((entryFormat >> 4) & 3) + 1;\n const innerBits = (entryFormat & 0xf) + 1;\n const at = start + Math.min(index, count - 1) * size;\n let entry = 0;\n for (let i = 0; i < size; i++) entry = entry * 256 + map.u8(at + i);\n const innerCount = 2 ** innerBits;\n return [Math.floor(entry / innerCount), entry % innerCount];\n}\n\n/**\n * This function gives the advances of an instance. With `round`, each delta of `HVAR` is rounded to whole font units, as\n * FreeType rounds it: a half goes up. With `exact`, the delta keeps its fraction. The advances stay as they are when the\n * font has no `HVAR` table.\n */\nexport function instanceAdvances(advances: Uint16Array, hvar: Reader | undefined, coordinates: readonly number[], deltas: \"round\" | \"exact\" = \"round\"): Float64Array {\n const result = Float64Array.from(advances);\n if (hvar === undefined || coordinates.every((value) => value === 0)) return result;\n const store = readVariationStore(hvar.part(hvar.u32(4)), coordinates);\n const mapOffset = hvar.u32(8);\n const map = mapOffset === 0 ? undefined : hvar.part(mapOffset);\n for (let glyph = 0; glyph < result.length; glyph++) {\n const [outer, inner] = map === undefined ? [0, glyph] : mapIndex(map, glyph);\n const delta = store.delta(outer, inner);\n result[glyph] = advances[glyph]! + (deltas === \"round\" ? Math.round(delta) : delta);\n }\n return result;\n}\n","import type { Reader } from \"./binary.ts\";\nimport { axisScalar } from \"./variations.ts\";\n\n/** The composite flags of `glyf` that change the length of a component record. */\nconst ARG_1_AND_2_ARE_WORDS = 0x1;\nconst WE_HAVE_A_SCALE = 0x8;\nconst MORE_COMPONENTS = 0x20;\nconst WE_HAVE_AN_X_AND_Y_SCALE = 0x40;\nconst WE_HAVE_A_TWO_BY_TWO = 0x80;\n/** The composite flag that gives the metrics of the component to the composite glyph. */\nconst USE_MY_METRICS = 0x200;\n\n/** The points of the glyphs of a `glyf` table. */\nexport interface GlyphPoints {\n /** The count of points of each glyph, as `gvar` counts them. The four phantom points are not in the count. */\n readonly counts: Uint32Array;\n /** The component with the flag USE_MY_METRICS of each composite glyph, or -1. */\n readonly metrics: Int32Array;\n}\n\n/**\n * This function reads the composite records that start at `at`. It gives their length in bytes and the count of\n * components. It also gives the first component with the flag USE_MY_METRICS, or -1.\n */\nfunction components(glyph: Reader, at: number): { count: number; length: number; metrics: number } {\n let count = 0;\n let offset = at;\n let metrics = -1;\n for (;;) {\n const flags = glyph.u16(offset);\n if ((flags & USE_MY_METRICS) !== 0 && metrics < 0) metrics = glyph.u16(offset + 2);\n offset += 4 + ((flags & ARG_1_AND_2_ARE_WORDS) !== 0 ? 4 : 2);\n if ((flags & WE_HAVE_A_SCALE) !== 0) offset += 2;\n else if ((flags & WE_HAVE_AN_X_AND_Y_SCALE) !== 0) offset += 4;\n else if ((flags & WE_HAVE_A_TWO_BY_TWO) !== 0) offset += 8;\n count++;\n if ((flags & MORE_COMPONENTS) === 0) return { count, length: offset - at, metrics };\n }\n}\n\n/**\n * This function gives the points of each glyph. A glyph of contours has the points of its contours. A composite glyph\n * has one point for each component.\n */\nexport function readPointCounts(glyf: Reader, loca: Reader, indexToLocFormat: number, numGlyphs: number): GlyphPoints {\n const counts = new Uint32Array(numGlyphs);\n const metrics = new Int32Array(numGlyphs).fill(-1);\n const offsetOf = (glyph: number) => (indexToLocFormat === 0 ? loca.u16(glyph * 2) * 2 : loca.u32(glyph * 4));\n for (let glyph = 0; glyph < numGlyphs; glyph++) {\n const start = offsetOf(glyph);\n if (offsetOf(glyph + 1) <= start) continue;\n const contours = glyf.i16(start);\n if (contours > 0) counts[glyph] = glyf.u16(start + 10 + (contours - 1) * 2) + 1;\n else if (contours < 0) {\n const found = components(glyf, start + 10);\n counts[glyph] = found.count;\n metrics[glyph] = found.metrics;\n }\n }\n return { counts, metrics };\n}\n\n/** This function reads a 255UInt16 of WOFF2. It gives the value and the next offset. */\nfunction read255(stream: Reader, at: number): [number, number] {\n const code = stream.u8(at);\n if (code === 253) return [stream.u16(at + 1), at + 3];\n if (code === 254) return [stream.u8(at + 1) + 506, at + 2];\n if (code === 255) return [stream.u8(at + 1) + 253, at + 2];\n return [code, at + 1];\n}\n\n/** This function gives the points of each glyph from the transformed `glyf` table of WOFF2. */\nexport function readTransformedPointCounts(glyf: Reader, numGlyphs: number): GlyphPoints {\n const counts = new Uint32Array(numGlyphs);\n const metrics = new Int32Array(numGlyphs).fill(-1);\n const sizes = Array.from({ length: 7 }, (_, i) => glyf.u32(8 + i * 4));\n const contourStream = glyf.part(36, sizes[0]);\n const pointStream = glyf.part(36 + sizes[0]!, sizes[1]);\n // The composite stream comes after the streams of the contours, the points, the flags and the glyphs\n const compositeStream = glyf.part(36 + sizes[0]! + sizes[1]! + sizes[2]! + sizes[3]!, sizes[4]);\n let pointAt = 0;\n let compositeAt = 0;\n const glyphs = Math.min(numGlyphs, glyf.u16(4));\n for (let glyph = 0; glyph < glyphs; glyph++) {\n const contours = contourStream.i16(glyph * 2);\n if (contours > 0) {\n let total = 0;\n for (let c = 0; c < contours; c++) {\n const [points, next] = read255(pointStream, pointAt);\n total += points;\n pointAt = next;\n }\n counts[glyph] = total;\n } else if (contours < 0) {\n const found = components(compositeStream, compositeAt);\n counts[glyph] = found.count;\n metrics[glyph] = found.metrics;\n compositeAt += found.length;\n }\n }\n return { counts, metrics };\n}\n\n/** This function reads packed point numbers. It gives the point numbers, or `undefined` for all the points, and the next offset. */\nfunction readPoints(data: Reader, at: number): [number[] | undefined, number] {\n let count = data.u8(at++);\n if ((count & 0x80) !== 0) count = ((count & 0x7f) << 8) | data.u8(at++);\n if (count === 0) return [undefined, at];\n const points: number[] = [];\n let last = 0;\n while (points.length < count) {\n const control = data.u8(at++);\n const words = (control & 0x80) !== 0;\n const run = (control & 0x7f) + 1;\n for (let k = 0; k < run && points.length < count; k++) {\n last += words ? data.u16(at) : data.u8(at);\n at += words ? 2 : 1;\n points.push(last);\n }\n }\n return [points, at];\n}\n\n/** This function reads `count` packed deltas. It gives the deltas and the next offset. */\nfunction readDeltas(data: Reader, at: number, count: number): [number[], number] {\n const deltas: number[] = [];\n while (deltas.length < count) {\n const control = data.u8(at++);\n const run = (control & 0x3f) + 1;\n const kind = control & 0xc0;\n for (let k = 0; k < run && deltas.length < count; k++) {\n if (kind === 0x80) deltas.push(0);\n else if (kind === 0x40) {\n deltas.push(data.i16(at));\n at += 2;\n } else if (kind === 0xc0) {\n deltas.push(data.u32(at) | 0);\n at += 4;\n } else deltas.push((data.u8(at++) << 24) >> 24);\n }\n }\n return [deltas, at];\n}\n\n/**\n * This function gives the advance delta of each glyph at the coordinates, from the phantom points of `gvar`. The delta\n * is the x delta of the second phantom point minus the x delta of the first. With `round`, the difference is rounded to\n * whole font units, and a half goes away from 0, as HarfBuzz rounds it.\n */\nexport function gvarAdvanceDeltas(gvar: Reader, pointCounts: Uint32Array, coordinates: readonly number[], deltas: \"round\" | \"exact\"): Float64Array {\n const axisCount = gvar.u16(4);\n const sharedCount = gvar.u16(6);\n const sharedAt = gvar.u32(8);\n const glyphCount = Math.min(gvar.u16(12), pointCounts.length);\n const longOffsets = (gvar.u16(14) & 1) !== 0;\n const dataAt = gvar.u32(16);\n const offsetOf = (glyph: number) => (longOffsets ? gvar.u32(20 + glyph * 4) : gvar.u16(20 + glyph * 2) * 2);\n const peakOf = (at: number) => Array.from({ length: axisCount }, (_, a) => gvar.i16(at + a * 2) / 16384);\n const shared = Array.from({ length: sharedCount }, (_, t) => peakOf(sharedAt + t * axisCount * 2));\n const result = new Float64Array(pointCounts.length);\n for (let glyph = 0; glyph < glyphCount; glyph++) {\n const start = offsetOf(glyph);\n const end = offsetOf(glyph + 1);\n if (end <= start) continue;\n const data = gvar.part(dataAt + start, end - start);\n const tupleCount = data.u16(0) & 0x0fff;\n const sharedPoints = (data.u16(0) & 0x8000) !== 0;\n let serialized = data.u16(2);\n let header = 4;\n const allPoints = pointCounts[glyph]! + 4;\n let sharedList: number[] | undefined;\n if (sharedPoints) [sharedList, serialized] = readPoints(data, serialized);\n const first = pointCounts[glyph]!;\n let left = 0;\n let right = 0;\n for (let t = 0; t < tupleCount; t++) {\n const size = data.u16(header);\n const index = data.u16(header + 2);\n header += 4;\n let peak: number[];\n if ((index & 0x8000) !== 0) {\n peak = Array.from({ length: axisCount }, (_, a) => data.i16(header + a * 2) / 16384);\n header += axisCount * 2;\n } else peak = shared[index & 0x0fff] ?? [];\n let startTuple: number[] | undefined;\n let endTuple: number[] | undefined;\n if ((index & 0x4000) !== 0) {\n startTuple = Array.from({ length: axisCount }, (_, a) => data.i16(header + a * 2) / 16384);\n endTuple = Array.from({ length: axisCount }, (_, a) => data.i16(header + axisCount * 2 + a * 2) / 16384);\n header += axisCount * 4;\n }\n let scalar = 1;\n for (let a = 0; a < axisCount && scalar !== 0; a++) {\n const p = peak[a] ?? 0;\n const s = startTuple?.[a] ?? Math.min(p, 0);\n const e = endTuple?.[a] ?? Math.max(p, 0);\n scalar *= axisScalar(s, p, e, coordinates[a] ?? 0);\n }\n const tupleEnd = serialized + size;\n if (scalar !== 0) {\n let at = serialized;\n let points = sharedList;\n if ((index & 0x2000) !== 0) [points, at] = readPoints(data, at);\n const count = points === undefined ? allPoints : points.length;\n const [xs] = readDeltas(data, at, count);\n const deltaOf = (point: number): number => {\n if (points === undefined) return xs[point] ?? 0;\n const k = points.indexOf(point);\n return k < 0 ? 0 : xs[k]!;\n };\n left += scalar * deltaOf(first);\n right += scalar * deltaOf(first + 1);\n }\n serialized = tupleEnd;\n }\n const delta = right - left;\n result[glyph] = deltas === \"round\" ? Math.sign(delta) * Math.round(Math.abs(delta)) : delta;\n }\n return result;\n}\n","/**\n * The Indic shaper of HarfBuzz for the script Devanagari. This module follows `hb-ot-shaper-indic.cc`, the syllable machine\n * of `hb-ot-shaper-indic-machine.rl`, the dotted circles of `hb-ot-shaper-syllabic.cc` and `hb-ot-shaper-vowel-constraints.cc`,\n * and the normalization of `hb-ot-shape-normalize.cc`. The table of the categories comes from `hb-ot-shaper-indic-table.cc`.\n */\nimport type { Font } from \"./font.ts\";\nimport { LIGATED, MULTIPLIED, SUBSTITUTED, type GlyphInfo } from \"./substitution.ts\";\n\n/** The OpenType script tags that use the Indic shaper in this model. */\nexport const indicScripts: readonly string[] = [\"deva\"];\n\n// The categories of the Indic table of HarfBuzz\nconst X = 0;\nconst C = 1;\nconst V = 2;\nconst N = 3;\nconst H = 4;\nconst ZWNJ = 5;\nconst ZWJ = 6;\nconst M = 7;\nconst SM = 8;\nconst A = 9;\nconst PLACEHOLDER = 10;\nconst DOTTEDCIRCLE = 11;\nconst RS = 12;\nconst MPST = 13;\nconst REPHA = 14;\nconst RA = 15;\nconst CM = 16;\nconst SYMBOL = 17;\nconst CS = 18;\nconst SMPST = 57;\n\n// The positions of the Indic table of HarfBuzz, in the order of the glyphs of a syllable\nconst START = 0;\nconst RA_TO_BECOME_REPH = 1;\nconst PRE_M = 2;\nconst PRE_C = 3;\nconst BASE_C = 4;\nconst BELOW_C = 8;\nconst AFTER_SUB = 9;\nconst POST_C = 11;\nconst SMVD = 13;\nconst END = 14;\n\n// The syllable types of the machine\nconst CONSONANT_SYLLABLE = 0;\nconst VOWEL_SYLLABLE = 1;\nconst STANDALONE_CLUSTER = 2;\nconst SYMBOL_CLUSTER = 3;\nconst BROKEN_CLUSTER = 4;\nconst NON_INDIC_CLUSTER = 5;\n\n/**\n * The categories and positions of the Indic table of HarfBuzz for the characters that Devanagari text uses. Each group of\n * four has the first code point, the last code point, the category and the position. Another code point has the category\n * `X` and the position `END`.\n */\nconst indicTable: readonly number[] = [\n 0x2d, 0x2d, PLACEHOLDER, BASE_C, 0x30, 0x39, PLACEHOLDER, BASE_C, 0xa0, 0xa0, PLACEHOLDER, BASE_C, 0xb2, 0xb3, SMPST, SMVD,\n 0xd7, 0xd7, PLACEHOLDER, BASE_C, 0x900, 0x903, SM, SMVD, 0x904, 0x914, V, BASE_C, 0x915, 0x92f, C, BASE_C,\n 0x930, 0x930, RA, BASE_C, 0x931, 0x939, C, BASE_C, 0x93a, 0x93b, M, AFTER_SUB, 0x93c, 0x93c, N, END,\n 0x93d, 0x93d, SYMBOL, SMVD, 0x93e, 0x93e, M, AFTER_SUB, 0x93f, 0x93f, M, PRE_M, 0x940, 0x94c, M, AFTER_SUB,\n 0x94d, 0x94d, H, BELOW_C, 0x94e, 0x94e, M, PRE_M, 0x94f, 0x94f, M, AFTER_SUB, 0x951, 0x952, A, SMVD,\n 0x953, 0x954, SM, SMVD, 0x955, 0x957, M, AFTER_SUB, 0x958, 0x95f, C, BASE_C, 0x960, 0x961, V, BASE_C,\n 0x962, 0x963, M, AFTER_SUB, 0x966, 0x96f, PLACEHOLDER, BASE_C, 0x972, 0x977, V, BASE_C, 0x978, 0x97f, C, BASE_C,\n 0x1cd0, 0x1cd2, A, SMVD, 0x1cd4, 0x1ce8, A, SMVD, 0x1ce9, 0x1cec, SYMBOL, SMVD, 0x1ced, 0x1ced, A, SMVD,\n 0x1cee, 0x1cf1, SYMBOL, SMVD, 0x1cf2, 0x1cf3, C, BASE_C, 0x1cf4, 0x1cf4, A, SMVD, 0x1cf5, 0x1cf6, CS, BASE_C,\n 0x1cf7, 0x1cf9, A, SMVD, 0x1cfa, 0x1cfa, PLACEHOLDER, BASE_C, 0x200c, 0x200c, ZWNJ, END, 0x200d, 0x200d, ZWJ, END,\n 0x2010, 0x2015, PLACEHOLDER, BASE_C, 0x2022, 0x2022, PLACEHOLDER, BASE_C, 0x2074, 0x2074, SMPST, SMVD,\n 0x2082, 0x2084, SMPST, SMVD, 0x25cc, 0x25cc, DOTTEDCIRCLE, BASE_C, 0xa8e0, 0xa8f1, A, SMVD, 0xa8f2, 0xa8f7, SYMBOL, SMVD,\n 0xa8fe, 0xa8fe, V, BASE_C, 0xa8ff, 0xa8ff, M, AFTER_SUB,\n];\n\n/** This function gives the category and the position of a code point. */\nfunction indicProperties(codePoint: number): [number, number] {\n let low = 0;\n let high = indicTable.length / 4 - 1;\n while (low <= high) {\n const middle = (low + high) >> 1;\n if (codePoint < indicTable[middle * 4]!) high = middle - 1;\n else if (codePoint > indicTable[middle * 4 + 1]!) low = middle + 1;\n else return [indicTable[middle * 4 + 2]!, indicTable[middle * 4 + 3]!];\n }\n return [X, END];\n}\n\n/**\n * The canonical combining classes of the marks of the Devanagari blocks that are not 0. The normalization uses them to\n * sort the marks and to block a composition. A mark of another block has the class 0 in this model.\n */\nconst combiningClasses: readonly number[] = [\n 0x93c, 0x93c, 7, 0x94d, 0x94d, 9, 0x951, 0x951, 230, 0x952, 0x952, 220, 0x953, 0x954, 230, 0x1cd0, 0x1cd2, 230,\n 0x1cd4, 0x1cd4, 1, 0x1cd5, 0x1cd9, 220, 0x1cda, 0x1cdb, 230, 0x1cdc, 0x1cdf, 220, 0x1ce0, 0x1ce0, 230, 0x1ce2, 0x1ce8, 1,\n 0x1ced, 0x1ced, 220, 0x1cf4, 0x1cf4, 230, 0x1cf8, 0x1cf9, 230, 0xa8e0, 0xa8f1, 230,\n];\n\nfunction combiningClass(codePoint: number): number {\n for (let i = 0; i < combiningClasses.length; i += 3) if (codePoint >= combiningClasses[i]! && codePoint <= combiningClasses[i + 1]!) return combiningClasses[i + 2]!;\n return 0;\n}\n\nconst unicodeMark = /\\p{M}/u;\n/** The general categories from `FORMAT` to `NON_SPACING_MARK` of HarfBuzz: a letter, a mark, or a format or other code point. */\nconst letterOrMark = /[\\p{L}\\p{M}\\p{Cf}\\p{Cn}\\p{Co}\\p{Cs}]/u;\n\nfunction isMark(codePoint: number): boolean {\n return unicodeMark.test(String.fromCodePoint(codePoint));\n}\n\n/**\n * This function inserts a dotted circle in each vowel sequence of Devanagari that looks like another vowel, as\n * `_hb_preprocess_text_vowel_constraints` does.\n */\nfunction vowelConstraints(codePoints: readonly number[]): number[] {\n const out: number[] = [];\n let i = 0;\n while (i + 1 < codePoints.length) {\n const first = codePoints[i]!;\n const second = codePoints[i + 1]!;\n let matched = false;\n if (first === 0x905) matched = [0x93a, 0x93b, 0x93e, 0x945, 0x946, 0x949, 0x94a, 0x94b, 0x94c, 0x94f, 0x956, 0x957].includes(second);\n else if (first === 0x906) matched = [0x93a, 0x945, 0x946, 0x947, 0x948].includes(second);\n else if (first === 0x909) matched = second === 0x941;\n else if (first === 0x90f) matched = [0x945, 0x946, 0x947].includes(second);\n else if (first === 0x930 && second === 0x94d && codePoints[i + 2] === 0x907) {\n out.push(codePoints[i++]!);\n matched = true;\n }\n out.push(codePoints[i++]!);\n if (matched) out.push(0x25cc, codePoints[i++]!);\n }\n while (i < codePoints.length) out.push(codePoints[i++]!);\n return out;\n}\n\n/**\n * This function normalizes the code points as HarfBuzz does in the mode `COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT`. It\n * decomposes each character that has a canonical decomposition when the font has the glyphs of its parts. The letter\n * U+0931 does not decompose. A text with a mark after its first character then gets more steps. The function sorts the\n * marks, and composes each mark with its starter again when the font has the glyph of the composite.\n */\nfunction normalize(codePoints: readonly number[], hasGlyph: (codePoint: number) => boolean): number[] {\n const allSimple = !codePoints.some((codePoint, i) => i > 0 && isMark(codePoint));\n const decomposed = codePoints.flatMap((codePoint) => decomposition(codePoint, hasGlyph));\n if (allSimple) return decomposed;\n // A stable sort of each run of marks with a class that is not 0\n for (let i = 1; i < decomposed.length; i++) {\n for (let j = i; j > 0; j--) {\n const before = combiningClass(decomposed[j - 1]!);\n const after = combiningClass(decomposed[j]!);\n if (after === 0 || before <= after) break;\n [decomposed[j - 1], decomposed[j]] = [decomposed[j]!, decomposed[j - 1]!];\n }\n }\n const out: number[] = decomposed.slice(0, 1);\n let starter = 0;\n for (let i = 1; i < decomposed.length; i++) {\n const codePoint = decomposed[i]!;\n if (isMark(codePoint) && (starter === out.length - 1 || combiningClass(out[out.length - 1]!) < combiningClass(codePoint))) {\n const composed = compose(out[starter]!, codePoint);\n if (composed !== undefined && hasGlyph(composed)) {\n out[starter] = composed;\n continue;\n }\n }\n out.push(codePoint);\n if (combiningClass(codePoint) === 0) starter = out.length - 1;\n }\n return out;\n}\n\n/** This function gives the code points of a character after the decomposition of `normalize`. */\nfunction decomposition(codePoint: number, hasGlyph: (codePoint: number) => boolean): number[] {\n const parts = codePoint === 0x931 ? [codePoint] : [...String.fromCodePoint(codePoint).normalize(\"NFD\")].map((part) => part.codePointAt(0)!);\n return (parts.length > 1 || parts[0] !== codePoint) && parts.every(hasGlyph) ? parts : [codePoint];\n}\n\n/** The code points that `normalize` and `vowelConstraints` can give for a set of characters. */\nexport interface IndicForms {\n /** The parts of each character of the set after the decomposition. A character with no decomposition is its one part. */\n readonly parts: ReadonlyMap<number, readonly number[]>;\n /** The composites of each code point: the code points that it becomes when a mark composes with it. */\n readonly composites: ReadonlyMap<number, readonly number[]>;\n /** All the code points that the shaper can see: the set, its parts, the dotted circle and each composite. */\n readonly codePoints: ReadonlySet<number>;\n}\n\n/**\n * This function gives the code points that the normalization can give for the characters `characters`. A composite is\n * not always in the set: a nukta that follows U+0928 gives U+0929. The function repeats until no new composite appears.\n */\nexport function indicForms(characters: ReadonlySet<number>, hasGlyph: (codePoint: number) => boolean): IndicForms {\n const parts = new Map([...characters].map((codePoint) => [codePoint, decomposition(codePoint, hasGlyph)]));\n const codePoints = new Set([...parts.values()].flat());\n for (const codePoint of characters) codePoints.add(codePoint);\n codePoints.add(0x25cc);\n const composites = new Map<number, number[]>();\n for (let size = 0; size !== codePoints.size; ) {\n size = codePoints.size;\n const marks = [...codePoints].filter(isMark);\n for (const starter of codePoints) {\n for (const mark of marks) {\n const composed = compose(starter, mark);\n if (composed === undefined || !hasGlyph(composed)) continue;\n const known = composites.get(starter) ?? [];\n if (!known.includes(composed)) composites.set(starter, [...known, composed]);\n codePoints.add(composed);\n }\n }\n }\n return { parts, composites, codePoints };\n}\n\n/** This function gives the canonical composite of two code points, or `undefined`. A mark does not compose with a mark. */\nfunction compose(first: number, second: number): number | undefined {\n if (isMark(first)) return undefined;\n const composed = [(String.fromCodePoint(first) + String.fromCodePoint(second)).normalize(\"NFC\")];\n const [single, ...rest] = [...composed[0]!];\n return rest.length === 0 && single !== undefined ? single.codePointAt(0) : undefined;\n}\n\n// The syllable machine, with one letter for each category\nconst letters = new Map<number, string>([\n [X, \"x\"], [C, \"c\"], [V, \"v\"], [N, \"n\"], [H, \"h\"], [ZWNJ, \"w\"], [ZWJ, \"j\"], [M, \"m\"], [SM, \"s\"], [A, \"a\"], [PLACEHOLDER, \"p\"],\n [DOTTEDCIRCLE, \"d\"], [RS, \"r\"], [MPST, \"q\"], [REPHA, \"f\"], [RA, \"R\"], [CM, \"k\"], [SYMBOL, \"y\"], [CS, \"S\"], [SMPST, \"t\"],\n]);\nconst c = \"[cR]\";\nconst n = \"(?:w?r)?(?:nn?)?\";\nconst z = \"[wj]\";\nconst reph = \"(?:Rh|f)\";\nconst sm = \"[st]\";\nconst cn = `${c}j?${n}`;\nconst matraGroup = `${z}*(?:m|${sm}?q)n?h?`;\nconst syllableTail = `(?:${z}?${sm}${sm}?w?)?a*`;\nconst halantGroup = `(?:${z}?h(?:jn?)?)`;\nconst finalHalantGroup = `(?:${halantGroup}|hw)`;\nconst complexSyllableTail = `(?:${halantGroup}${cn})*k?(?:${finalHalantGroup}|(?:${matraGroup})*)${syllableTail}`;\n/** The rules of the machine in the order of HarfBuzz. A tie of two lengths goes to the first rule. */\nconst machine: readonly (readonly [RegExp, number])[] = (\n [\n [`[fS]?${cn}${complexSyllableTail}`, CONSONANT_SYLLABLE],\n [`${reph}?v${n}(?:j|${complexSyllableTail})`, VOWEL_SYLLABLE],\n [`(?:[fS]?p|${reph}?d)${n}${complexSyllableTail}`, STANDALONE_CLUSTER],\n [`yn?${syllableTail}`, SYMBOL_CLUSTER],\n [\"t\", NON_INDIC_CLUSTER],\n [`${reph}?${n}${complexSyllableTail}`, BROKEN_CLUSTER],\n [\"[^]\", NON_INDIC_CLUSTER],\n ] as const\n).map(([rule, type]) => [new RegExp(`^(?:${rule})$`), type] as const);\n\n/**\n * This function divides the glyphs into syllables, as the machine of HarfBuzz does. At each position, it takes the\n * longest match of the rules. Each glyph gets the syllable byte. Its high 4 bits are a serial number from 1 to 15, and\n * its low 4 bits are the type. The function tells if a syllable is a broken cluster.\n */\nfunction findSyllables(infos: GlyphInfo[]): boolean {\n const text = infos.map((info) => letters.get(info.category) ?? \"x\").join(\"\");\n let serial = 1;\n let broken = false;\n let at = 0;\n while (at < text.length) {\n // No rule but the last one matches the category X, so a syllable stops before it\n const next = text.indexOf(\"x\", at + 1);\n let length = 1;\n let type = NON_INDIC_CLUSTER;\n search: for (let end = next < 0 ? text.length : next; end > at; end--) {\n const piece = text.slice(at, end);\n for (const [rule, kind] of machine) {\n if (rule.test(piece)) {\n length = end - at;\n type = kind;\n break search;\n }\n }\n }\n if (type === BROKEN_CLUSTER) broken = true;\n for (let i = at; i < at + length; i++) infos[i]!.syllable = (serial << 4) | type;\n serial = serial === 15 ? 1 : serial + 1;\n at += length;\n }\n return broken;\n}\n\n/** The types of the syllables of the Indic machine of HarfBuzz. */\nexport type IndicSyllableType = \"consonant\" | \"vowel\" | \"standalone\" | \"symbol\" | \"broken\" | \"non-indic\";\nconst syllableTypes: readonly IndicSyllableType[] = [\"consonant\", \"vowel\", \"standalone\", \"symbol\", \"broken\", \"non-indic\"];\n\n/**\n * This function divides a text into the syllables of the Indic machine of HarfBuzz. It does not normalize the text and\n * does not insert dotted circles.\n */\nexport function indicSyllables(text: string): { readonly text: string; readonly type: IndicSyllableType }[] {\n const characters = [...text];\n const infos = characters.map((character): GlyphInfo => {\n const codePoint = character.codePointAt(0)!;\n const [category, position] = indicProperties(codePoint);\n return { mask: GLOBAL, syllable: 0, props: 0, category, position, codePoint };\n });\n findSyllables(infos);\n return syllables(infos).map(([start, end]) => ({ text: characters.slice(start, end).join(\"\"), type: syllableTypes[infos[start]!.syllable & 0x0f]! }));\n}\n\n/** It is true when the glyph made no ligature and its category is one of `categories`. A ligature has no category. */\nfunction isOneOf(info: GlyphInfo, categories: readonly number[]): boolean {\n return (info.props & LIGATED) === 0 && categories.includes(info.category);\n}\n\nconst consonants = [C, CS, RA, CM, V, PLACEHOLDER, DOTTEDCIRCLE];\nconst joiners = [ZWJ, ZWNJ];\nconst isConsonant = (info: GlyphInfo): boolean => isOneOf(info, consonants);\nconst isJoiner = (info: GlyphInfo): boolean => isOneOf(info, joiners);\nconst isHalant = (info: GlyphInfo): boolean => isOneOf(info, [H]);\nconst ligatedAndDidntMultiply = (info: GlyphInfo): boolean => (info.props & (LIGATED | MULTIPLIED)) === LIGATED;\n\n/** The basic features, in the order of their stages before the final reordering. The value is true for a global feature. */\nconst basicFeatures: readonly (readonly [string, boolean])[] = [\n [\"nukt\", true], [\"akhn\", true], [\"rphf\", false], [\"rkrf\", true], [\"pref\", false], [\"blwf\", false],\n [\"abvf\", false], [\"half\", false], [\"pstf\", false], [\"vatu\", true], [\"cjct\", true],\n];\n/** The features of the last stage, after the final reordering. They match only in a syllable. */\nconst finalFeatures: readonly string[] = [\"init\", \"pres\", \"abvs\", \"blws\", \"psts\", \"haln\"];\n/** This function gives the features of the page that the last stage applies. */\nfunction pageFeatures(features: readonly string[]): string[] {\n return features.filter((tag) => ![\"ccmp\", \"locl\", \"liga\"].includes(tag) && !finalFeatures.includes(tag));\n}\n\n/** This function gives all the features that `indicShaper` applies for the features `features` of the page. */\nexport function indicFeatures(features: readonly string[]): string[] {\n return [\"locl\", \"ccmp\", ...basicFeatures.map(([tag]) => tag), ...finalFeatures, ...pageFeatures(features)];\n}\n\n/** The mask bit of the global features. Each glyph has it. */\nconst GLOBAL = 1;\n/** The mask bits of the features that apply only to some glyphs of a syllable. */\nconst featureBits = new Map<string, number>([[\"rphf\", 2], [\"pref\", 4], [\"blwf\", 8], [\"abvf\", 16], [\"half\", 32], [\"pstf\", 64], [\"init\", 128]]);\n\n/** The glyphs of a text and the data of each glyph. The two arrays change together. */\ninterface Run {\n readonly glyphs: number[];\n readonly infos: GlyphInfo[];\n}\n\n/** This function moves the glyph at `from` to `to`. The glyphs between them move by one position. */\nfunction move(run: Run, from: number, to: number): void {\n const [glyph] = run.glyphs.splice(from, 1);\n const [info] = run.infos.splice(from, 1);\n run.glyphs.splice(to, 0, glyph!);\n run.infos.splice(to, 0, info!);\n}\n\nfunction reverse(run: Run, start: number, end: number): void {\n run.glyphs.splice(start, end - start, ...run.glyphs.slice(start, end).reverse());\n run.infos.splice(start, end - start, ...run.infos.slice(start, end).reverse());\n}\n\n/** This function gives the ranges of the syllables, as `foreach_syllable` of HarfBuzz. */\nfunction syllables(infos: readonly GlyphInfo[]): [number, number][] {\n const ranges: [number, number][] = [];\n let start = 0;\n for (let i = 1; i <= infos.length; i++) {\n if (i === infos.length || infos[i]!.syllable !== infos[start]!.syllable) {\n ranges.push([start, i]);\n start = i;\n }\n }\n return infos.length === 0 ? [] : ranges;\n}\n\n/**\n * This function makes the function that gives the glyphs of a word with the Indic shaper. The features `features` are the\n * features of the page. The shaper applies `locl` and `ccmp` before it reorders the syllables, and the other features of\n * the page after its own features. It does not apply `liga`.\n */\nexport function indicShaper(font: Font, script: string, features: readonly string[]): (word: string) => number[] {\n const lookupsOf = (tags: readonly string[]) => font.substitutions(script, tags);\n const maskOf = (tag: string): number => (lookupsOf([tag]).length === 0 ? 0 : featureBits.get(tag) ?? GLOBAL);\n const [rphfMask, prefMask, blwfMask, abvfMask, halfMask, pstfMask, initMask] = [\"rphf\", \"pref\", \"blwf\", \"abvf\", \"half\", \"pstf\", \"init\"].map(maskOf) as [number, number, number, number, number, number, number];\n const would = (tag: string, glyphs: readonly number[]): boolean => lookupsOf([tag]).some((lookup) => lookup.wouldApply(glyphs));\n const virama = font.glyph(0x94d);\n const dottedCircle = font.glyph(0x25cc);\n const positions = new Map<number, number>();\n /** This function gives the position of a consonant from the below-base, post-base and pre-base forms of the font. */\n const consonantPosition = (consonant: number): number => {\n let position = positions.get(consonant);\n if (position === undefined) {\n const before = [virama, consonant];\n const after = [consonant, virama];\n const either = (tag: string) => would(tag, before) || would(tag, after);\n position = either(\"blwf\") || either(\"vatu\") ? BELOW_C : either(\"pstf\") || either(\"pref\") ? POST_C : BASE_C;\n positions.set(consonant, position);\n }\n return position;\n };\n const first = lookupsOf([\"locl\", \"ccmp\"]);\n const basic = basicFeatures.map(([tag, global]) => ({ lookups: lookupsOf([tag]), mask: global ? GLOBAL : featureBits.get(tag)! }));\n const last = lookupsOf([...finalFeatures, ...pageFeatures(features)]).map((lookup) => ({\n lookup,\n mask: lookup.features.reduce((mask, tag) => mask | (tag === \"init\" ? initMask : GLOBAL), 0),\n perSyllable: lookup.features.some((tag) => finalFeatures.includes(tag)),\n }));\n\n /** This function reorders one syllable before the basic features, and gives the masks of its glyphs. */\n const initialReordering = (run: Run, start: number, end: number): void => {\n const { glyphs, infos } = run;\n let base = end;\n let hasReph = false;\n let limit = start;\n if (rphfMask !== 0 && start + 3 <= end && !isJoiner(infos[start + 2]!) && would(\"rphf\", [glyphs[start]!, glyphs[start + 1]!])) {\n limit += 2;\n while (limit < end && isJoiner(infos[limit]!)) limit++;\n base = start;\n hasReph = true;\n }\n // The base is the last consonant that has no below-base or post-base form\n let seenBelow = false;\n for (let i = end - 1; i >= limit; i--) {\n const info = infos[i]!;\n if (isConsonant(info)) {\n base = i;\n if (info.position !== BELOW_C && (info.position !== POST_C || seenBelow)) break;\n if (info.position === BELOW_C) seenBelow = true;\n } else if (start < i && info.category === ZWJ && infos[i - 1]!.category === H) break;\n }\n if (hasReph && base === start && limit - base <= 2) hasReph = false;\n for (let i = start; i < base; i++) infos[i]!.position = Math.min(PRE_C, infos[i]!.position);\n if (base < end) infos[base]!.position = BASE_C;\n if (hasReph) infos[start]!.position = RA_TO_BECOME_REPH;\n // A joiner, a nukta or a halant goes with the glyph before it\n let lastPosition = START;\n for (let i = start; i < end; i++) {\n const info = infos[i]!;\n if ([ZWJ, ZWNJ, N, RS, CM, H].includes(info.category)) {\n info.position = lastPosition;\n if (info.category === H && info.position === PRE_M) {\n for (let j = i; j > start; j--) {\n if (infos[j - 1]!.position !== PRE_M) {\n info.position = infos[j - 1]!.position;\n break;\n }\n }\n }\n } else if (info.position !== SMVD) {\n if (info.category === MPST && i > start && infos[i - 1]!.category === SM) infos[i - 1]!.position = info.position;\n lastPosition = info.position;\n }\n }\n // A post-base consonant takes the glyphs before it\n let previous = base;\n for (let i = base + 1; i < end; i++) {\n if (isConsonant(infos[i]!)) {\n for (let j = previous + 1; j < i; j++) if (infos[j]!.position < SMVD) infos[j]!.position = infos[i]!.position;\n previous = i;\n } else if (infos[i]!.category === M || infos[i]!.category === MPST) previous = i;\n }\n const order = glyphs.slice(start, end).map((glyph, k) => ({ glyph, info: infos[start + k]! })).sort((a, b) => a.info.position - b.info.position);\n order.forEach(({ glyph, info }, k) => {\n glyphs[start + k] = glyph;\n infos[start + k] = info;\n });\n base = end;\n let firstLeftMatra = end;\n let lastLeftMatra = end;\n for (let i = start; i < end; i++) {\n if (infos[i]!.position === BASE_C) {\n base = i;\n break;\n }\n if (infos[i]!.position === PRE_M) {\n if (firstLeftMatra === end) firstLeftMatra = i;\n lastLeftMatra = i;\n }\n }\n if (firstLeftMatra < lastLeftMatra) {\n reverse(run, firstLeftMatra, lastLeftMatra + 1);\n let i = firstLeftMatra;\n for (let j = i; j <= lastLeftMatra; j++) {\n if (infos[j]!.category === M || infos[j]!.category === MPST) {\n reverse(run, i, j + 1);\n i = j + 1;\n }\n }\n }\n for (let i = start; i < end && infos[i]!.position === RA_TO_BECOME_REPH; i++) infos[i]!.mask |= rphfMask;\n for (let i = start; i < base; i++) infos[i]!.mask |= halfMask | blwfMask;\n for (let i = base + 1; i < end; i++) infos[i]!.mask |= blwfMask | abvfMask | pstfMask;\n if (prefMask !== 0 && base + 2 < end) {\n for (let i = base + 1; i + 1 < end; i++) {\n if (would(\"pref\", [glyphs[i]!, glyphs[i + 1]!])) {\n infos[i]!.mask |= prefMask;\n infos[i + 1]!.mask |= prefMask;\n break;\n }\n }\n }\n // A ZWNJ stops the half forms of the glyphs before it\n for (let i = start + 1; i < end; i++) {\n if (!isJoiner(infos[i]!) || infos[i]!.category !== ZWNJ) continue;\n let j = i;\n do {\n j--;\n infos[j]!.mask &= ~halfMask;\n } while (j > start && !isConsonant(infos[j]!));\n }\n };\n\n /** This function moves the pre-base matra and the reph of one syllable after the basic features. */\n const finalReordering = (run: Run, start: number, end: number): void => {\n const { glyphs, infos } = run;\n for (let i = start; i < end; i++) {\n // A virama that came out of a ligature is a halant again\n if (virama !== 0 && glyphs[i] === virama && (infos[i]!.props & (LIGATED | MULTIPLIED)) === (LIGATED | MULTIPLIED)) {\n infos[i]!.category = H;\n infos[i]!.props &= ~(LIGATED | MULTIPLIED);\n }\n }\n let tryPref = prefMask !== 0;\n let base = start;\n for (; base < end; base++) {\n if (infos[base]!.position < BASE_C) continue;\n if (tryPref && base + 1 < end) {\n for (let i = base + 1; i < end; i++) {\n if ((infos[i]!.mask & prefMask) === 0) continue;\n if (!((infos[i]!.props & SUBSTITUTED) !== 0 && ligatedAndDidntMultiply(infos[i]!))) {\n base = i;\n while (base < end && isHalant(infos[base]!)) base++;\n if (base < end) infos[base]!.position = BASE_C;\n tryPref = false;\n }\n break;\n }\n if (base === end) break;\n }\n if (start < base && infos[base]!.position > BASE_C) base--;\n break;\n }\n if (base === end && start < base && isOneOf(infos[base - 1]!, [ZWJ])) base--;\n if (base < end) while (start < base && isOneOf(infos[base]!, [N, H])) base--;\n\n // A pre-base matra goes after the last halant before the base\n if (start + 1 < end && start < base) {\n let newPosition = base === end ? base - 2 : base - 1;\n for (;;) {\n while (newPosition > start && !isOneOf(infos[newPosition]!, [M, MPST, H])) newPosition--;\n if (isHalant(infos[newPosition]!) && infos[newPosition]!.position !== PRE_M) {\n if (newPosition + 1 < end && infos[newPosition + 1]!.category === ZWJ && newPosition > start) {\n newPosition--;\n continue;\n }\n } else newPosition = start;\n break;\n }\n if (start < newPosition && infos[newPosition]!.position !== PRE_M) {\n for (let i = newPosition; i > start; i--) {\n if (infos[i - 1]!.position !== PRE_M) continue;\n const oldPosition = i - 1;\n if (oldPosition < base && base <= newPosition) base--;\n move(run, oldPosition, newPosition);\n newPosition--;\n }\n }\n }\n\n // The reph goes after the first halant before the base, or else at the end of the syllable before the signs\n if (start + 1 < end && infos[start]!.position === RA_TO_BECOME_REPH && (infos[start]!.category === REPHA) !== ligatedAndDidntMultiply(infos[start]!)) {\n let newPosition = start + 1;\n while (newPosition < base && !isHalant(infos[newPosition]!)) newPosition++;\n if (newPosition < base && isHalant(infos[newPosition]!)) {\n if (newPosition + 1 < base && isJoiner(infos[newPosition + 1]!)) newPosition++;\n } else {\n newPosition = end - 1;\n while (newPosition > start && infos[newPosition]!.position === SMVD) newPosition--;\n if (isHalant(infos[newPosition]!)) {\n for (let i = base + 1; i < newPosition; i++) if (infos[i]!.category === M || infos[i]!.category === MPST) newPosition--;\n }\n }\n move(run, start, newPosition);\n if (start < base && base <= newPosition) base--;\n }\n\n // A pre-base form of a consonant goes before the base\n if (tryPref && base + 1 < end) {\n for (let i = base + 1; i < end; i++) {\n if ((infos[i]!.mask & prefMask) === 0) continue;\n if (ligatedAndDidntMultiply(infos[i]!)) {\n let newPosition = base;\n while (newPosition > start && !isOneOf(infos[newPosition - 1]!, [M, MPST, H])) newPosition--;\n if (newPosition > start && isHalant(infos[newPosition - 1]!) && newPosition < end && isJoiner(infos[newPosition]!)) newPosition++;\n move(run, i, newPosition);\n if (newPosition <= base && base < i) base++;\n }\n break;\n }\n }\n if (infos[start]!.position === PRE_M && (start === 0 || !letterOrMark.test(String.fromCodePoint(infos[start - 1]!.codePoint)))) infos[start]!.mask |= initMask;\n };\n\n return (word: string): number[] => {\n const codePoints = normalize(vowelConstraints([...word].map((character) => character.codePointAt(0)!)), (codePoint) => font.glyph(codePoint) !== 0);\n const run: Run = { glyphs: codePoints.map((codePoint) => font.glyph(codePoint)), infos: [] };\n for (const codePoint of codePoints) {\n const [category, position] = indicProperties(codePoint);\n run.infos.push({ mask: GLOBAL, syllable: 0, props: 0, category, position, codePoint });\n }\n const broken = findSyllables(run.infos);\n for (const lookup of first) lookup.applyInfos(run.glyphs, run.infos, GLOBAL, true);\n if (virama !== 0) for (let i = 0; i < run.infos.length; i++) if (run.infos[i]!.position === BASE_C) run.infos[i]!.position = consonantPosition(run.glyphs[i]!);\n if (broken && dottedCircle !== 0) {\n // A broken cluster starts with a dotted circle\n for (let i = run.infos.length - 1; i >= 0; i--) {\n const info = run.infos[i]!;\n if ((info.syllable & 0x0f) !== BROKEN_CLUSTER || (i > 0 && run.infos[i - 1]!.syllable === info.syllable)) continue;\n run.glyphs.splice(i, 0, dottedCircle);\n run.infos.splice(i, 0, { mask: info.mask, syllable: info.syllable, props: 0, category: DOTTEDCIRCLE, position: END, codePoint: 0x25cc });\n }\n }\n for (const [start, end] of syllables(run.infos)) {\n const type = run.infos[start]!.syllable & 0x0f;\n if (type !== SYMBOL_CLUSTER && type !== NON_INDIC_CLUSTER) initialReordering(run, start, end);\n }\n for (const { lookups, mask } of basic) for (const lookup of lookups) lookup.applyInfos(run.glyphs, run.infos, mask, true);\n for (const [start, end] of syllables(run.infos)) finalReordering(run, start, end);\n for (const { lookup, mask, perSyllable } of last) lookup.applyInfos(run.glyphs, run.infos, mask, perSyllable);\n return run.glyphs;\n };\n}\n","/**\n * The joining of the Arabic shaper. This module follows `hb-ot-shaper-arabic.cc` of HarfBuzz. It has the joining types of\n * the characters and the state machine that gives the form of each letter. It also has the order of the GSUB features.\n * The table of the joining types comes from `ArabicShaping.txt` of the Unicode Character Database, version 18.0.0.\n * It covers the Arabic, Syriac, NKo and Mandaic blocks, with their supplements and extensions.\n */\n\n/** The joining form of a letter, as the tag of the GSUB feature that makes it. */\nexport type JoiningForm = \"isol\" | \"fina\" | \"fin2\" | \"fin3\" | \"medi\" | \"med2\" | \"init\";\n\n/** The forms in the order of the features of the shaper. The index of a form gives its bit in a feature mask. */\nexport const joiningFeatures: readonly JoiningForm[] = [\"isol\", \"fina\", \"fin2\", \"fin3\", \"medi\", \"med2\", \"init\"];\n\n/** The OpenType script tags that use the joining of the Arabic shaper in this model. */\nexport const joiningScripts: readonly string[] = [\"arab\", \"syrc\"];\n\n// The columns of the state machine of HarfBuzz: the joining types U, L, R and D (C is D), and the Syriac joining groups.\n// The type L is the column 1. No character of these blocks has the type L.\nconst U = 0;\nconst R = 2;\nconst D = 3;\nconst ALAPH = 4;\nconst DALATH_RISH = 5;\n/** The joining type T: a transparent character, for example a mark. The state machine does not see it. */\nconst T = 6;\n\n/**\n * The joining types of `ArabicShaping.txt`. Each triple has the first code point, the last code point and the type.\n * The type `C` (join causing) is `D` here, as in HarfBuzz. A code point that is not in the table has the type `U`.\n * When its general category is `Mn`, `Me` or `Cf`, it has the type `T`.\n */\nconst joiningTable: readonly number[] = [\n 0x600, 0x605, U, 0x608, 0x608, U, 0x60b, 0x60b, U, 0x620, 0x620, D, 0x621, 0x621, U, 0x622, 0x625, R, 0x626, 0x626, D,\n 0x627, 0x627, R, 0x628, 0x628, D, 0x629, 0x629, R, 0x62a, 0x62e, D, 0x62f, 0x632, R, 0x633, 0x63f, D, 0x640, 0x640, D,\n 0x641, 0x647, D, 0x648, 0x648, R, 0x649, 0x64a, D, 0x66e, 0x66f, D, 0x671, 0x673, R, 0x674, 0x674, U, 0x675, 0x677, R,\n 0x678, 0x687, D, 0x688, 0x699, R, 0x69a, 0x6bf, D, 0x6c0, 0x6c0, R, 0x6c1, 0x6c2, D, 0x6c3, 0x6cb, R, 0x6cc, 0x6cc, D,\n 0x6cd, 0x6cd, R, 0x6ce, 0x6ce, D, 0x6cf, 0x6cf, R, 0x6d0, 0x6d1, D, 0x6d2, 0x6d3, R, 0x6d5, 0x6d5, R, 0x6dd, 0x6dd, U,\n 0x6ee, 0x6ef, R, 0x6fa, 0x6fc, D, 0x6ff, 0x6ff, D, 0x70f, 0x70f, T, 0x710, 0x710, ALAPH, 0x712, 0x714, D,\n 0x715, 0x716, DALATH_RISH, 0x717, 0x719, R, 0x71a, 0x71d, D, 0x71e, 0x71e, R, 0x71f, 0x727, D, 0x728, 0x728, R,\n 0x729, 0x729, D, 0x72a, 0x72a, DALATH_RISH, 0x72b, 0x72b, D, 0x72c, 0x72c, R, 0x72d, 0x72e, D, 0x72f, 0x72f, DALATH_RISH,\n 0x74d, 0x74d, R, 0x74e, 0x758, D, 0x759, 0x75b, R, 0x75c, 0x76a, D, 0x76b, 0x76c, R, 0x76d, 0x770, D, 0x771, 0x771, R,\n 0x772, 0x772, D, 0x773, 0x774, R, 0x775, 0x777, D, 0x778, 0x779, R, 0x77a, 0x77f, D, 0x7ca, 0x7ea, D, 0x7fa, 0x7fa, D,\n 0x840, 0x840, R, 0x841, 0x845, D, 0x846, 0x847, R, 0x848, 0x848, D, 0x849, 0x849, R, 0x84a, 0x853, D, 0x854, 0x854, R,\n 0x855, 0x855, D, 0x856, 0x858, R, 0x860, 0x860, D, 0x861, 0x861, U, 0x862, 0x865, D, 0x866, 0x866, U, 0x867, 0x867, R,\n 0x868, 0x868, D, 0x869, 0x86a, R, 0x870, 0x882, R, 0x883, 0x885, D, 0x886, 0x886, D, 0x887, 0x888, U, 0x889, 0x88d, D,\n 0x88e, 0x88e, R, 0x88f, 0x88f, D, 0x890, 0x891, U, 0x8a0, 0x8a9, D, 0x8aa, 0x8ac, R, 0x8ad, 0x8ad, U, 0x8ae, 0x8ae, R,\n 0x8af, 0x8b0, D, 0x8b1, 0x8b2, R, 0x8b3, 0x8b8, D, 0x8b9, 0x8b9, R, 0x8ba, 0x8c8, D, 0x8e2, 0x8e2, U, 0x200c, 0x200c, U,\n 0x200d, 0x200d, D,\n];\n\nconst transparent = /[\\p{Mn}\\p{Me}\\p{Cf}]/u;\n\n/** This function gives the joining type of a code point: a column of the state machine, or `T`. */\nfunction joiningType(codePoint: number): number {\n let low = 0;\n let high = joiningTable.length / 3 - 1;\n while (low <= high) {\n const middle = (low + high) >> 1;\n if (codePoint < joiningTable[middle * 3]!) high = middle - 1;\n else if (codePoint > joiningTable[middle * 3 + 1]!) low = middle + 1;\n else return joiningTable[middle * 3 + 2]!;\n }\n return transparent.test(String.fromCodePoint(codePoint)) ? T : U;\n}\n\n// The actions of the state machine: the index of a form in `joiningFeatures`, or NONE\nconst ISOL = 0;\nconst FINA = 1;\nconst FIN2 = 2;\nconst FIN3 = 3;\nconst MEDI = 4;\nconst MED2 = 5;\nconst INIT = 6;\nconst NONE = 7;\n\n/**\n * The state machine of `arabic_state_table` of HarfBuzz. Each row is a state, with one entry for each column. An entry\n * has the action for the previous letter, the action for the current letter and the next state.\n */\nconst states: readonly (readonly (readonly [number, number, number])[])[] = [\n // State 0: the previous letter was U, and it does not join\n [[NONE, NONE, 0], [NONE, ISOL, 2], [NONE, ISOL, 1], [NONE, ISOL, 2], [NONE, ISOL, 1], [NONE, ISOL, 6]],\n // State 1: the previous letter was R, or ISOL ALAPH, and it does not join\n [[NONE, NONE, 0], [NONE, ISOL, 2], [NONE, ISOL, 1], [NONE, ISOL, 2], [NONE, FIN2, 5], [NONE, ISOL, 6]],\n // State 2: the previous letter was D or L in the form ISOL, and it can join\n [[NONE, NONE, 0], [NONE, ISOL, 2], [INIT, FINA, 1], [INIT, FINA, 3], [INIT, FINA, 4], [INIT, FINA, 6]],\n // State 3: the previous letter was D in the form FINA, and it can join\n [[NONE, NONE, 0], [NONE, ISOL, 2], [MEDI, FINA, 1], [MEDI, FINA, 3], [MEDI, FINA, 4], [MEDI, FINA, 6]],\n // State 4: the previous letter was FINA ALAPH, and it does not join\n [[NONE, NONE, 0], [NONE, ISOL, 2], [MED2, ISOL, 1], [MED2, ISOL, 2], [MED2, FIN2, 5], [MED2, ISOL, 6]],\n // State 5: the previous letter was FIN2 or FIN3 ALAPH, and it does not join\n [[NONE, NONE, 0], [NONE, ISOL, 2], [ISOL, ISOL, 1], [ISOL, ISOL, 2], [ISOL, FIN2, 5], [ISOL, ISOL, 6]],\n // State 6: the previous letter was DALATH or RISH, and it does not join\n [[NONE, NONE, 0], [NONE, ISOL, 2], [NONE, ISOL, 1], [NONE, ISOL, 2], [NONE, FIN3, 5], [NONE, ISOL, 6]],\n];\n\n/**\n * This function gives the joining form of each code point of a text, in logical order. A transparent character, for\n * example a mark, and a character that does not join get `undefined`. The text before and after the code points is not\n * known, so the function sees it as a character of the type U.\n */\nexport function joiningForms(codePoints: readonly number[]): (JoiningForm | undefined)[] {\n const actions: number[] = codePoints.map(() => NONE);\n let previous = -1;\n let state = 0;\n codePoints.forEach((codePoint, i) => {\n const type = joiningType(codePoint);\n if (type === T) return;\n const [previousAction, currentAction, next] = states[state]![type]!;\n if (previousAction !== NONE && previous >= 0) actions[previous] = previousAction;\n actions[i] = currentAction;\n previous = i;\n state = next;\n });\n return actions.map((action) => joiningFeatures[action]);\n}\n\n/**\n * One stage of the GSUB features of the Arabic shaper. The lookups of one stage go in the order of the lookup list.\n * A stage with a `form` applies only to the glyphs of that joining form.\n */\nexport interface JoiningStage {\n readonly features: readonly string[];\n readonly form?: JoiningForm;\n}\n\n/**\n * This function gives the stages of the Arabic shaper of HarfBuzz for a list of features. The stages are `ccmp` and\n * `locl`, then each joining form alone, then `rlig`, then `calt`, then the other features. When the font has `rclt`,\n * `calt` and the other features are one stage, as in HarfBuzz. The list `features` gives the features apart from the\n * joining forms, so a feature that is not in the list is not in a stage.\n */\nexport function joiningStages(features: readonly string[], hasRclt: boolean): JoiningStage[] {\n const take = (tags: readonly string[]) => features.filter((tag) => tags.includes(tag));\n const first = [\"ccmp\", \"locl\"];\n const rest = features.filter((tag) => !first.includes(tag) && tag !== \"rlig\" && (hasRclt || tag !== \"calt\"));\n const stages: JoiningStage[] = [{ features: take(first) }, ...joiningFeatures.map((form) => ({ features: [form], form })), { features: take([\"rlig\"]) }];\n if (!hasRclt) stages.push({ features: take([\"calt\"]) });\n stages.push({ features: rest });\n return stages.filter((stage) => stage.features.length > 0);\n}\n","/**\n * A small model of the Unicode Bidirectional Algorithm (UAX #9) for one paragraph with the base level 0. Blink adds the\n * widths of the words of a canvas in the visual order, so the single-precision sum needs this order. The model has no\n * explicit embeddings, no isolates and no brackets (rule N0). It gets the bidi class of a character from its script and\n * its general category, so it knows the classes of the common characters only.\n */\n\n/** A bidi class of UAX #9. */\ntype BidiClass = \"L\" | \"R\" | \"AL\" | \"EN\" | \"ES\" | \"ET\" | \"AN\" | \"CS\" | \"NSM\" | \"BN\" | \"B\" | \"S\" | \"WS\" | \"ON\";\n\nconst nonSpacingMark = /[\\p{Mn}\\p{Me}]/u;\nconst currency = /\\p{Sc}/u;\nconst format = /\\p{Cf}/u;\nconst hebrew = /\\p{Script_Extensions=Hebrew}/u;\nconst arabicLetter = /[\\p{Script_Extensions=Arabic}\\p{Script_Extensions=Syriac}\\p{Script_Extensions=Thaana}]/u;\nconst letter = /[\\p{L}\\p{Mc}]/u;\nconst commonSeparators: ReadonlySet<number> = new Set([0x2c, 0x2e, 0x2f, 0x3a, 0xa0, 0x60c, 0x202f, 0x2044]);\n\n/** This function gives the bidi class of a character, from its code point, its script and its general category. */\nfunction bidiClass(character: string): BidiClass {\n const c = character.codePointAt(0)!;\n if (nonSpacingMark.test(character)) return \"NSM\";\n if ((c >= 0x30 && c <= 0x39) || (c >= 0x6f0 && c <= 0x6f9) || c === 0xb2 || c === 0xb3 || c === 0xb9 || (c >= 0xff10 && c <= 0xff19)) return \"EN\";\n if ((c >= 0x660 && c <= 0x669) || c === 0x66b || c === 0x66c) return \"AN\";\n if (c === 0x2b || c === 0x2d || c === 0x2212) return \"ES\";\n if (c === 0x23 || c === 0x25 || c === 0xb0 || c === 0x2030 || currency.test(character)) return \"ET\";\n if (commonSeparators.has(c)) return \"CS\";\n if (c === 0x9 || c === 0xb || c === 0x1f) return \"S\";\n if (c === 0xa || c === 0xd || (c >= 0x1c && c <= 0x1e) || c === 0x85 || c === 0x2029) return \"B\";\n if (c === 0x20 || c === 0xc || (c >= 0x2000 && c <= 0x200a) || c === 0x2028 || c === 0x3000) return \"WS\";\n if (format.test(character)) return \"BN\";\n if (hebrew.test(character)) return \"R\";\n if (arabicLetter.test(character)) return \"AL\";\n return letter.test(character) ? \"L\" : \"ON\";\n}\n\n/** This function gives the direction of a strong class for the rule N1: `EN` and `AN` count as `R`. */\nfunction strongDirection(type: BidiClass): \"L\" | \"R\" | undefined {\n if (type === \"L\") return \"L\";\n return type === \"R\" || type === \"EN\" || type === \"AN\" ? \"R\" : undefined;\n}\n\n/**\n * This function gives the bidi level of each code point of a text, in a paragraph with the base level 0. It applies the\n * rules W1 to W7, N1, N2, I1 and L1 of UAX #9.\n */\nexport function bidiLevels(text: string): number[] {\n const characters = [...text];\n const original = characters.map(bidiClass);\n const types = [...original];\n const n = types.length;\n // W1: a mark gets the class of the character before it\n for (let i = 0; i < n; i++) if (types[i] === \"NSM\") types[i] = i === 0 || types[i - 1] === \"BN\" ? \"L\" : types[i - 1]!;\n // W2 and W3: a European digit after an Arabic letter is an Arabic digit, and an Arabic letter is R\n let strong: BidiClass = \"L\";\n for (let i = 0; i < n; i++) {\n const type = types[i]!;\n if (type === \"L\" || type === \"R\" || type === \"AL\") strong = type;\n else if (type === \"EN\" && strong === \"AL\") types[i] = \"AN\";\n }\n for (let i = 0; i < n; i++) if (types[i] === \"AL\") types[i] = \"R\";\n // W4: one separator between two digits of the same class gets their class\n for (let i = 1; i + 1 < n; i++) {\n const before = types[i - 1]!;\n if (types[i] === \"ES\" && before === \"EN\" && types[i + 1] === \"EN\") types[i] = \"EN\";\n else if (types[i] === \"CS\" && (before === \"EN\" || before === \"AN\") && types[i + 1] === before) types[i] = before;\n }\n // W5: a sequence of terminators next to a European digit is EN\n for (let i = 0; i < n; i++) {\n if (types[i] !== \"ET\") continue;\n let end = i;\n while (end < n && types[end] === \"ET\") end++;\n if ((i > 0 && types[i - 1] === \"EN\") || (end < n && types[end] === \"EN\")) types.fill(\"EN\", i, end);\n i = end - 1;\n }\n // W6 and W7: the other separators and terminators are ON, and a European digit after L is L\n for (let i = 0; i < n; i++) if (types[i] === \"ES\" || types[i] === \"ET\" || types[i] === \"CS\") types[i] = \"ON\";\n strong = \"L\";\n for (let i = 0; i < n; i++) {\n const type = types[i]!;\n if (type === \"L\" || type === \"R\") strong = type;\n else if (type === \"EN\" && strong === \"L\") types[i] = \"L\";\n }\n // N1 and N2: a sequence of neutrals gets the direction of the strong characters on its two sides, or else L\n for (let i = 0; i < n; i++) {\n if (strongDirection(types[i]!) !== undefined) continue;\n let end = i;\n while (end < n && strongDirection(types[end]!) === undefined) end++;\n const before = i === 0 ? \"L\" : strongDirection(types[i - 1]!)!;\n const after = end === n ? \"L\" : strongDirection(types[end]!)!;\n types.fill(before === after ? before : \"L\", i, end);\n i = end - 1;\n }\n // I1: R goes up one level, and the digits go up two levels\n const levels = types.map((type) => (type === \"R\" ? 1 : type === \"AN\" || type === \"EN\" ? 2 : 0));\n // L1: the white space at the end and before each separator goes back to the base level\n const isSpace = (i: number) => original[i] === \"WS\" || original[i] === \"BN\";\n for (let i = n - 1; i >= 0 && isSpace(i); i--) levels[i] = 0;\n for (let i = 0; i < n; i++) {\n if (original[i] !== \"S\" && original[i] !== \"B\") continue;\n levels[i] = 0;\n for (let k = i - 1; k >= 0 && isSpace(k); k--) levels[k] = 0;\n }\n return levels;\n}\n\n/**\n * This function puts items in the visual order of the rule L2 of UAX #9. Each item has the level `levels[i]`. From the\n * highest level to the level 1, it reverses each sequence of items at that level or higher.\n */\nexport function visualOrder<T>(items: readonly T[], levels: readonly number[]): T[] {\n const order = items.map((_, i) => i);\n const at = [...levels];\n for (let level = Math.max(0, ...levels); level >= 1; level--) {\n for (let i = 0; i < order.length; i++) {\n if (at[i]! < level) continue;\n let end = i;\n while (end < order.length && at[end]! >= level) end++;\n order.splice(i, end - i, ...order.slice(i, end).reverse());\n at.splice(i, end - i, ...at.slice(i, end).reverse());\n i = end;\n }\n }\n return order.map((i) => items[i]!);\n}\n","/**\n * The words of the text of a canvas. Blink shapes the text of `fillText` and `measureText` one word at a time, so no GSUB\n * context and no pair kerning goes across two words. This module follows `NextWordEndIndex` of\n * `third_party/blink/renderer/platform/fonts/plain_text_node.cc` and the CJK table of `character_property_data.h`.\n * The Chromium Authors wrote these files under a BSD-style license.\n */\nimport { bidiLevels, visualOrder } from \"./bidi.ts\";\n\n/** The single code points of the CJK table of Blink. */\nconst cjkValues: ReadonlySet<number> = new Set([\n 0x2c7, 0x2ca, 0x2cb, 0x2d9, 0x2020, 0x2021, 0x2030, 0x203b, 0x203c, 0x2042, 0x2047, 0x2048, 0x2049, 0x2051, 0x20dd, 0x20de, 0x2100, 0x2103,\n 0x2105, 0x2109, 0x210a, 0x2113, 0x2116, 0x2121, 0x212b, 0x213b, 0x2150, 0x2151, 0x2152, 0x217f, 0x2189, 0x2307, 0x2312, 0x23ce, 0x2423, 0x25a0,\n 0x25a1, 0x25a2, 0x25aa, 0x25ab, 0x25b1, 0x25b2, 0x25b3, 0x25b6, 0x25b7, 0x25bc, 0x25bd, 0x25c0, 0x25c1, 0x25c6, 0x25c7, 0x25c9, 0x25cb, 0x25cc,\n 0x25ef, 0x2605, 0x2606, 0x260e, 0x2616, 0x2617, 0x26a0, 0x2713, 0x271a, 0x273f, 0x2740, 0x2756, 0x2763, 0x2b1a, 0xfe10, 0xfe11, 0xfe12, 0xfe19,\n 0xff1d, 0x1f100, 0x1f200, 0x1f237, 0x1f32c, 0x1f336, 0x1f37d, 0x1f43f, 0x1f54f, 0x1f93b, 0x1f946,\n]);\n\n/** The ranges of the CJK table of Blink, as pairs of the first and the last code point. */\nconst cjkRanges: readonly number[] = [\n 0x2e80, 0x2fdf, 0x31c0, 0x31ef, 0x3400, 0x4dbf, 0x4e00, 0x9fff, 0xf900, 0xfaff, 0x20000, 0x2ffff, 0x2156, 0x215a, 0x2160, 0x216b, 0x2170, 0x217b,\n 0x23be, 0x23cc, 0x2460, 0x2492, 0x249c, 0x24ff, 0x25ce, 0x25d3, 0x25e2, 0x25e6, 0x2600, 0x2603, 0x2660, 0x266f, 0x2672, 0x267d, 0x2776, 0x277f,\n 0x2ff0, 0x302d, 0x3031, 0x312f, 0x3190, 0x31bf, 0x3200, 0x33ff, 0x4dc0, 0x4dff, 0xf860, 0xf862, 0xfe30, 0xfe6f, 0xff00, 0xff0c, 0xff0e, 0xff1a,\n 0xff1f, 0xffef, 0x16fe0, 0x16fff, 0x17000, 0x187ff, 0x18800, 0x18aff, 0x1b000, 0x1b0ff, 0x1b100, 0x1b12f, 0x1b170, 0x1b2ff, 0x1f110, 0x1f129,\n 0x1f130, 0x1f149, 0x1f150, 0x1f169, 0x1f170, 0x1f189, 0x1f202, 0x1f219, 0x1f21b, 0x1f22e, 0x1f230, 0x1f231, 0x1f23b, 0x1f24f, 0x1f252, 0x1f2ff,\n 0x1f321, 0x1f32a, 0x1f394, 0x1f39f, 0x1f3cd, 0x1f3ce, 0x1f3d4, 0x1f3df, 0x1f3f1, 0x1f3f2, 0x1f3f5, 0x1f3f7, 0x1f4fd, 0x1f4fe, 0x1f53e, 0x1f54a,\n 0x1f568, 0x1f573, 0x1f576, 0x1f579, 0x1f57b, 0x1f58f, 0x1f591, 0x1f594, 0x1f597, 0x1f5a3, 0x1f5a5, 0x1f5e7, 0x1f5e9, 0x1f5fa, 0x1f650, 0x1f67f,\n 0x1f6c6, 0x1f6cb, 0x1f6cd, 0x1f6cf, 0x1f6d3, 0x1f6d4, 0x1f6d9, 0x1f6db, 0x1f6e0, 0x1f6ea, 0x1f6ed, 0x1f6f3, 0x1f6fd, 0x1f6ff, 0x1f900, 0x1f90b,\n 0x1fac9, 0x1facc,\n];\n\nconst emojiPresentation = /\\p{Emoji_Presentation}/u;\nconst modifierLike = /[\\p{M}\\p{Lm}\\p{Sk}]/u;\nconst continuesEmoji = /[\\p{Emoji_Component}\\p{Extended_Pictographic}]/u;\nconst commonOrInherited = /[\\p{Script=Common}\\p{Script=Inherited}]/u;\n\n/**\n * This function tells if Blink starts a CJK word at the code point `codePoint`. Blink also marks the pictographs of the\n * RGI emoji sequences. This function uses `Emoji_Presentation` for them, so some text-style pictographs are missing.\n */\nexport function isCjkIdeographOrSymbol(codePoint: number): boolean {\n if (codePoint < 0x2c7) return false;\n if (cjkValues.has(codePoint)) return true;\n for (let i = 0; i < cjkRanges.length; i += 2) if (codePoint >= cjkRanges[i]! && codePoint <= cjkRanges[i + 1]!) return true;\n return emojiPresentation.test(String.fromCodePoint(codePoint));\n}\n\n/** This function tells if Blink ends a word before the character `character`: a space, a tab or a zero width space. */\nfunction isDelimiter(character: string): boolean {\n return character === \" \" || character === \"\\t\" || character === \"\";\n}\n\n/**\n * This function divides the text of a canvas into the words that Blink shapes one at a time. Each space, tab and zero\n * width space is a word alone. Each CJK character starts a word, with its marks and the CJK characters of the script\n * Common after it.\n */\nexport function canvasWords(text: string): string[] {\n const characters = [...text];\n const words: string[] = [];\n let start = 0;\n while (start < characters.length) {\n const end = wordEnd(characters, start);\n words.push(characters.slice(start, end).join(\"\"));\n start = end;\n }\n return words;\n}\n\n/**\n * This function gives the segments of the text of a canvas in the visual order. A segment is a word of `canvasWords`, or a\n * part of a word where the bidi level changes. Blink shapes each bidi run alone and adds the widths of the words in this order.\n */\nexport function canvasSegments(text: string): string[] {\n const characters = [...text];\n const levels = bidiLevels(text);\n const segments: string[] = [];\n const segmentLevels: number[] = [];\n let at = 0;\n for (const word of canvasWords(text)) {\n const end = at + [...word].length;\n let start = at;\n for (let i = at + 1; i <= end; i++) {\n if (i < end && levels[i] === levels[start]) continue;\n segments.push(characters.slice(start, i).join(\"\"));\n segmentLevels.push(levels[start]!);\n start = i;\n }\n at = end;\n }\n return visualOrder(segments, segmentLevels);\n}\n\n/** This function gives the index after the last character of the word that starts at `start`. */\nfunction wordEnd(characters: readonly string[], start: number): number {\n const first = characters[start]!;\n if (start + 1 === characters.length || isDelimiter(first)) return start + 1;\n let end = start + 1;\n if (!isCjkIdeographOrSymbol(first.codePointAt(0)!)) {\n for (; end < characters.length; end++) {\n const character = characters[end]!;\n if (isDelimiter(character) || (isCjkIdeographOrSymbol(character.codePointAt(0)!) && !modifierLike.test(character))) return end;\n }\n return end;\n }\n let hasScript = !commonOrInherited.test(first);\n for (; end < characters.length; end++) {\n const character = characters[end]!;\n if (modifierLike.test(character) || continuesEmoji.test(character)) continue;\n if (isCjkIdeographOrSymbol(character.codePointAt(0)!)) {\n if (commonOrInherited.test(character)) continue;\n if (!hasScript) {\n hasScript = true;\n continue;\n }\n }\n return end;\n }\n return end;\n}\n","import { fnv1a32 } from \"@mark1russell7/rigor-generators\";\nimport type { Reader } from \"./binary.ts\";\nimport { readGposKerning, readKernTable, IGNORE_BASE, IGNORE_LIGATURES, IGNORE_MARKS, type PairLookup } from \"./kerning.ts\";\nimport { readTables, type Decompress, type TableMap } from \"./sfnt.ts\";\nimport { defaultFeatures, readGlyphFilter, readSubstitutions, type GlyphFilter, type SubstitutionLookup } from \"./substitution.ts\";\nimport { readAdvances, readCharacterMap, readGlyphClasses, readHeader } from \"./tables.ts\";\nimport { gvarAdvanceDeltas, readPointCounts, readTransformedPointCounts, type GlyphPoints } from \"./gvar.ts\";\nimport { instanceAdvances, normalize, readAxes, readVariationStore, type Axis, type Instance } from \"./variations.ts\";\nimport { indicScripts, indicShaper } from \"./indic.ts\";\nimport { joiningFeatures, joiningForms, joiningScripts, joiningStages } from \"./joining.ts\";\nimport { canvasSegments, canvasWords } from \"./words.ts\";\n\n/** The options of `readFont`. */\nexport interface ReadOptions {\n /** The Brotli decompress function. A WOFF2 file needs it. */\n readonly decompress?: Decompress;\n /**\n * The instance of a variable font, in the user units of its axes, for example `{ wght: 400 }`. An absent axis has its\n * default value. A browser uses the CSS weight, so a page with the weight `normal` needs `{ wght: 400 }`.\n */\n readonly instance?: Instance;\n /**\n * The rounding of the `HVAR` deltas. `round` (the default) rounds each delta to whole font units, as FreeType does.\n * `exact` keeps the fraction. The epoch tells the two modes apart.\n */\n readonly deltas?: \"round\" | \"exact\";\n /**\n * The source of the advances of an instance. `auto` (the default) uses `HVAR` when the font has it, else the phantom\n * points of `gvar`. `gvar` uses the phantom points also when the font has `HVAR`. The epoch tells the two modes apart.\n */\n readonly advances?: \"auto\" | \"gvar\";\n /**\n * The advance of a composite glyph. `own` (the default) uses the advance of the glyph, as FreeType and CoreText do.\n * `component` uses the advance of its component with the flag USE_MY_METRICS, as DirectWrite does.\n */\n readonly metrics?: \"own\" | \"component\";\n}\n\n/** The source of the advances of an instance: the default advances of `hmtx`, the deltas of `HVAR`, or the phantom points of `gvar`. */\nexport type AdvanceSource = \"hmtx\" | \"HVAR\" | \"gvar\";\n\n/** The measured tables of one font file. */\nexport interface Font {\n /**\n * The font epoch: the revision of `head` and an FNV-1a hash of the data that gives the widths. A cache of widths can use\n * it as a key. The TrueType file and the WOFF2 file of one font give the same epoch.\n */\n readonly epoch: string;\n readonly unitsPerEm: number;\n /** The axes of `fvar`. A font that is not variable has no axes. */\n readonly axes: readonly Axis[];\n /** The instance of the font: the value of each axis in user units, after the clamp to the range of the axis. */\n readonly instance: Instance;\n /** The normalized coordinates of the instance, one for each axis, after `avar`. */\n readonly coordinates: readonly number[];\n /** The source of the advances of this instance. The default instance and a font that is not variable use `hmtx`. */\n readonly advanceSource: AdvanceSource;\n readonly numGlyphs: number;\n /** This function gives the glyph of a code point, or 0 when the font has no glyph for it. */\n glyph(codePoint: number): number;\n /** This function gives the advance of a glyph in font units, as the shaper uses it. A mark has the advance 0. */\n advance(glyph: number): number;\n /** This function gives the GDEF class of a glyph: 1 base, 2 ligature, 3 mark, 4 component, 0 none. */\n glyphClass(glyph: number): number;\n /** This function gives the pair lookups of the kerning for an OpenType script tag, for example `latn`. */\n kerning(script: string): readonly PairLookup[];\n /** This function gives the GSUB lookups of a list of feature tags for an OpenType script tag, in the order of the lookup list. */\n substitutions(script: string, features: readonly string[]): readonly SubstitutionLookup[];\n /** This function gives the same font at another instance. It uses the tables that are already read. */\n at(instance: Instance): Font;\n}\n\n/** This function reads a TrueType, OpenType or WOFF2 file. */\nexport function readFont(bytes: Uint8Array, options: ReadOptions = {}): Font {\n const tables = readTables(bytes, options.decompress);\n const need = (tag: string) => {\n const table = tables.get(tag);\n if (table === undefined) throw new Error(`the font has no ${tag} table`);\n return table;\n };\n const header = readHeader(need(\"head\"), need(\"hhea\"), need(\"maxp\"));\n const parsed: Parsed = {\n tables,\n header,\n advances: readAdvances(need(\"hmtx\"), header),\n characters: readCharacterMap(need(\"cmap\")),\n glyphClass: readGlyphClasses(tables.get(\"GDEF\")),\n filter: readGlyphFilter(tables.get(\"GDEF\"), readGlyphClasses(tables.get(\"GDEF\"))),\n axes: tables.has(\"fvar\") ? readAxes(tables.get(\"fvar\")!) : [],\n points: lazy(() => pointsOf(tables, need(\"head\"), header.numGlyphs)),\n };\n const modes: Modes = { deltas: options.deltas ?? \"round\", advances: options.advances ?? \"auto\", metrics: options.metrics ?? \"own\" };\n return build(parsed, options.instance ?? {}, modes);\n}\n\n/** This function gives a function that computes a value at its first call and then keeps it. */\nfunction lazy<T>(compute: () => T): () => T {\n let done = false;\n let value: T | undefined;\n return () => {\n if (!done) {\n value = compute();\n done = true;\n }\n return value as T;\n };\n}\n\n/**\n * This function gives the points of each glyph, or `undefined` when the font has no `glyf` table. A WOFF2 file keeps\n * `glyf` in its transformed form, and its `loca` table is then empty.\n */\nfunction pointsOf(tables: TableMap, head: Reader, numGlyphs: number): GlyphPoints | undefined {\n const glyf = tables.get(\"glyf\");\n const loca = tables.get(\"loca\");\n if (glyf === undefined || loca === undefined) return undefined;\n return loca.length === 0 ? readTransformedPointCounts(glyf, numGlyphs) : readPointCounts(glyf, loca, head.i16(50), numGlyphs);\n}\n\n/** The modes of `readFont` that stay the same for each instance of a font. */\ninterface Modes {\n readonly deltas: \"round\" | \"exact\";\n readonly advances: \"auto\" | \"gvar\";\n readonly metrics: \"own\" | \"component\";\n}\n\n/** The tables of a font that do not change with the instance. */\ninterface Parsed {\n readonly tables: TableMap;\n readonly header: ReturnType<typeof readHeader>;\n readonly advances: Uint16Array;\n readonly characters: Map<number, number>;\n readonly glyphClass: (glyph: number) => number;\n readonly filter: GlyphFilter;\n readonly axes: readonly Axis[];\n /** The points of each glyph, for the phantom points of `gvar` and the flag USE_MY_METRICS. */\n readonly points: () => GlyphPoints | undefined;\n}\n\n/** This function gives the font at one instance. */\nfunction build(parsed: Parsed, requested: Instance, modes: Modes): Font {\n const { tables, header, characters, glyphClass, axes } = parsed;\n const { deltas } = modes;\n const instance = Object.fromEntries(axes.map((axis) => [axis.tag, Math.min(axis.max, Math.max(axis.min, requested[axis.tag] ?? axis.default))]));\n const coordinates = normalize(axes, tables.get(\"avar\"), instance);\n const variable = coordinates.some((value) => value !== 0);\n const hvar = tables.get(\"HVAR\");\n const gvar = tables.get(\"gvar\");\n const phantoms = gvar !== undefined && (modes.advances === \"gvar\" || hvar === undefined) && parsed.points() !== undefined;\n const advanceSource: AdvanceSource = !variable ? \"hmtx\" : phantoms ? \"gvar\" : hvar !== undefined ? \"HVAR\" : \"hmtx\";\n const advances = advanceSource === \"gvar\" ? phantomAdvances(parsed.advances, gvarAdvanceDeltas(gvar!, parsed.points()!.counts, coordinates, deltas)) : instanceAdvances(parsed.advances, advanceSource === \"HVAR\" ? hvar : undefined, coordinates, deltas);\n const metrics = modes.metrics === \"component\" ? parsed.points()?.metrics : undefined;\n if (metrics !== undefined) componentAdvances(advances, metrics);\n const gdef = tables.get(\"GDEF\");\n // The ItemVariationStore of GDEF 1.3 gives the deltas of the GPOS values\n const storeOffset = variable && gdef !== undefined && gdef.u16(2) >= 3 ? gdef.u32(14) : 0;\n const store = storeOffset === 0 ? undefined : readVariationStore(gdef!.part(storeOffset), coordinates);\n const gpos = tables.get(\"GPOS\");\n const kern = tables.get(\"kern\");\n const gsub = tables.get(\"GSUB\");\n const lookups = new Map<string, readonly PairLookup[]>();\n const substitutions = new Map<string, readonly SubstitutionLookup[]>();\n const hashed = [tables.get(\"cmap\"), gdef, gpos, kern, tables.get(\"fvar\"), tables.get(\"avar\"), tables.get(\"HVAR\"), gsub];\n return {\n epoch: `${header.revision.toString(16).padStart(8, \"0\")}-${widthHash(header.unitsPerEm, coordinates, advances, hashed)}${deltas === \"exact\" ? \"-exact\" : \"\"}${advanceSource === \"gvar\" && hvar !== undefined ? \"-gvar\" : \"\"}${metrics !== undefined ? \"-metrics\" : \"\"}`,\n unitsPerEm: header.unitsPerEm,\n numGlyphs: header.numGlyphs,\n axes,\n instance,\n coordinates,\n advanceSource,\n glyph: (codePoint) => characters.get(codePoint) ?? 0,\n advance: (glyph) => (glyphClass(glyph) === 3 ? 0 : advances[glyph] ?? 0),\n glyphClass,\n kerning(script) {\n let found = lookups.get(script);\n if (found === undefined) {\n // HarfBuzz uses the kern table only when the font has no GPOS table\n found = gpos !== undefined ? readGposKerning(gpos, script, store, parsed.filter) : kern !== undefined ? readKernTable(kern) : [];\n lookups.set(script, found);\n }\n return found;\n },\n substitutions(script, features) {\n const key = `${script} ${features.join(\",\")}`;\n let found = substitutions.get(key);\n if (found === undefined) {\n found = gsub === undefined ? [] : readSubstitutions(gsub, script, features, parsed.filter);\n substitutions.set(key, found);\n }\n return found;\n },\n at: (next) => build(parsed, next, modes),\n };\n}\n\n/**\n * This function gives each composite glyph the advance of its component with the flag USE_MY_METRICS. A component can\n * have that flag in its own components, so the function follows the chain. A chain of more than 8 steps stops.\n */\nfunction componentAdvances(advances: Float64Array, metrics: Int32Array): void {\n const own = Float64Array.from(advances);\n for (let glyph = 0; glyph < metrics.length; glyph++) {\n let source = glyph;\n for (let step = 0; step < 8 && (metrics[source] ?? -1) >= 0; step++) source = metrics[source]!;\n if (source !== glyph && source < own.length) advances[glyph] = own[source]!;\n }\n}\n\n/** This function adds the advance delta of each glyph to its default advance. A negative sum becomes 0. */\nfunction phantomAdvances(advances: Uint16Array, deltas: Float64Array): Float64Array {\n return Float64Array.from(advances, (advance, glyph) => Math.max(0, advance + (deltas[glyph] ?? 0)));\n}\n\n/**\n * This function gives 8 hexadecimal digits of FNV-1a. The hash covers the units per em, the coordinates of the instance,\n * the advances and the tables that change a width.\n */\nfunction widthHash(unitsPerEm: number, coordinates: readonly number[], advances: Float64Array, tables: readonly (Reader | undefined)[]): string {\n const parts: string[] = [String(unitsPerEm), coordinates.join(\",\")];\n const units = Uint16Array.from(advances, (value) => value & 0xffff);\n for (let i = 0; i < units.length; i += 4096) parts.push(String.fromCharCode(...units.subarray(i, i + 4096)));\n for (const table of tables) {\n parts.push(table === undefined ? \"-\" : \"+\");\n if (table === undefined) continue;\n for (let i = 0; i < table.length; i += 8192) parts.push(String.fromCharCode(...table.bytes.subarray(i, i + 8192)));\n }\n return fnv1a32(parts.join(\"\")).toString(16).padStart(8, \"0\");\n}\n\n/** The options of `measureWidth`. */\nexport interface MeasureOptions {\n /** The OpenType script tag of the text, for example `latn` or `cyrl`. The default is `DFLT`. */\n readonly script?: string;\n /**\n * The rounding of the width. `exact` (the default) adds the advances with no rounding. `pixel` rounds each advance to\n * 1/64 px and then to a whole px, and each kerning value to a whole px. Chromium on Linux does this at the device scale 1.\n */\n readonly rounding?: \"exact\" | \"pixel\";\n /** The pair kerning. When it is `false`, the width is the sum of the advances only. The default is `true`. */\n readonly kerning?: boolean;\n /**\n * The GSUB features to apply before the kerning. The default is `defaultFeatures`: the features that a browser applies\n * when the page does not change them. An empty list applies no feature of the list. The joining forms are not in the\n * list. The option `joining` controls them.\n */\n readonly features?: readonly string[];\n /**\n * The joining of the Arabic shaper of HarfBuzz. When it is `true` (the default), the scripts of `joiningScripts` get the\n * joining forms, for example `init` and `fina`. Their features then go in the stages of `joiningStages`. The other\n * scripts do not change. When it is `false`, all the scripts use the one stage of the other scripts.\n */\n readonly joining?: boolean;\n /**\n * The Indic shaper of HarfBuzz. When it is `true` (the default), the scripts of `indicScripts` get the syllables, the\n * reordering and the stages of `indicShaper`. When it is `false`, they use the one stage of the other scripts.\n */\n readonly indic?: boolean;\n /**\n * The shaping of the browser to model. `dom` (the default) shapes the words of `shapingWords` and then kerns all the\n * text. `canvas` shapes and kerns each word of `canvasWords` alone, as Blink does for the text of a canvas.\n */\n readonly shaping?: \"dom\" | \"canvas\";\n /**\n * The sum of the advances. `exact` (the default) adds them with no rounding. `float32` models the canvas of Blink with\n * CoreText and DirectWrite. Then the option `shaping` has no effect. The rounding `pixel` ignores this option.\n */\n readonly sum?: \"exact\" | \"float32\";\n}\n\n/** This function tells if a lookup with the flags `flags` skips a glyph of the GDEF class `glyphClass`. */\nfunction skips(flags: number, glyphClass: number): boolean {\n return ((flags & IGNORE_MARKS) !== 0 && glyphClass === 3) || ((flags & IGNORE_BASE) !== 0 && glyphClass === 1) || ((flags & IGNORE_LIGATURES) !== 0 && glyphClass === 2);\n}\n\n/**\n * This function divides a text into the words that the GSUB pass shapes one at a time. Each space and each tab is a word\n * alone. Blink shapes the text of a canvas in the same words, so no GSUB context goes across a space.\n */\nexport function shapingWords(text: string): string[] {\n const words: string[] = [];\n let word = \"\";\n for (const character of text) {\n if (character !== \" \" && character !== \"\t\") {\n word += character;\n continue;\n }\n if (word !== \"\") words.push(word);\n words.push(character);\n word = \"\";\n }\n if (word !== \"\") words.push(word);\n return words;\n}\n\n/** The choices that a set of options makes for the GSUB pass and for the kerning. */\nexport interface Shaping {\n readonly script: string;\n /** The features of the option `features`, or `defaultFeatures`. */\n readonly features: readonly string[];\n readonly shaper: \"indic\" | \"joining\" | \"plain\";\n readonly kerning: readonly PairLookup[];\n}\n\n/** This function gives the choices of a set of options: the script, the features, the shaper and the kerning lookups. */\nexport function shapingOf(font: Font, options: MeasureOptions): Shaping {\n const script = options.script ?? \"DFLT\";\n const features = options.features ?? defaultFeatures;\n const kerning = options.kerning === false ? [] : font.kerning(script);\n if (options.indic !== false && indicScripts.includes(script)) return { script, features, shaper: \"indic\", kerning };\n return { script, features, shaper: options.joining !== false && joiningScripts.includes(script) ? \"joining\" : \"plain\", kerning };\n}\n\n/** The GSUB pass of one set of options: a function that gives the glyphs of one word, and the kerning lookups. */\nfunction shaperOf(font: Font, options: MeasureOptions): { substitute: (word: string) => number[]; kerning: readonly PairLookup[] } {\n const { script, features, shaper, kerning } = shapingOf(font, options);\n if (shaper === \"indic\") return { substitute: indicShaper(font, script, features), kerning };\n const joins = shaper === \"joining\";\n const lookups = joins ? [] : font.substitutions(script, features);\n const stages = joins ? joiningStages(features, features.includes(\"rclt\") && font.substitutions(script, [\"rclt\"]).length > 0).map((stage) => ({ stage, lookups: font.substitutions(script, stage.features) })) : [];\n const substitute = (word: string): number[] => {\n const codePoints = [...word].map((character) => character.codePointAt(0)!);\n const wordGlyphs = codePoints.map((codePoint) => font.glyph(codePoint));\n for (const lookup of lookups) lookup.apply(wordGlyphs);\n if (joins) {\n // Each glyph has the bit of its joining form, and the bit 7 for the features of all the glyphs\n const masks = joiningForms(codePoints).map((form) => 0x80 | (form === undefined ? 0 : 1 << joiningFeatures.indexOf(form)));\n for (const { stage, lookups: stageLookups } of stages) {\n const mask = stage.form === undefined ? 0x80 : 1 << joiningFeatures.indexOf(stage.form);\n for (const lookup of stageLookups) lookup.apply(wordGlyphs, masks, mask);\n }\n }\n return wordGlyphs;\n };\n return { substitute, kerning };\n}\n\n/**\n * This function gives the glyphs of a text and their advances in font units. With the shaping `dom`, it applies the GSUB\n * substitutions to each word of `shapingWords`, and then the pair kerning to all the text. With the shaping `canvas`, it\n * applies the substitutions and the kerning to each word of `canvasWords` alone. A script of `joiningScripts` also gets\n * the joining forms of each word, in the stages of `joiningStages`. A script of `indicScripts` uses `indicShaper`.\n */\nexport function glyphAdvances(font: Font, text: string, options: MeasureOptions = {}): { glyphs: number[]; advances: number[] } {\n const { substitute, kerning } = shaperOf(font, options);\n const canvas = options.shaping === \"canvas\";\n const glyphs: number[] = [];\n const advances: number[] = [];\n for (const word of canvas ? canvasWords(text) : shapingWords(text)) {\n const wordGlyphs = substitute(word);\n const wordAdvances = wordGlyphs.map((glyph) => font.advance(glyph));\n if (canvas) kern(font, kerning, wordGlyphs, wordAdvances);\n glyphs.push(...wordGlyphs);\n advances.push(...wordAdvances);\n }\n if (!canvas) kern(font, kerning, glyphs, advances);\n return { glyphs, advances };\n}\n\n/**\n * The scale of HarfBuzz at one size. Blink gives HarfBuzz the scale of the size times 65536, so a position is in 1/65536 px.\n * The field `multiplier` is the factor of `em_mult` in `hb-font.hh`.\n */\ninterface PositionScale {\n readonly xScale: number;\n readonly multiplier: number;\n readonly unitsPerEm: number;\n}\n\n/** This function rounds a value to the nearest whole number, and a half goes away from 0, as `roundf` does. */\nfunction roundHalfAway(value: number): number {\n return Math.sign(value) * Math.floor(Math.abs(value) + 0.5);\n}\n\n/**\n * This function gives a kerning value in 1/65536 px, as HarfBuzz scales it. HarfBuzz scales the value of the ValueRecord\n * with `em_mult`, and the delta of the VariationIndex table in single precision with `em_scalef`.\n */\nfunction kerningPosition(value: number, delta: number, scale: PositionScale): number {\n const base = Math.round(value - delta);\n const scaledDelta = delta === 0 ? 0 : roundHalfAway(Math.fround(Math.fround(Math.fround(delta) * scale.xScale) / scale.unitsPerEm));\n return Math.floor((base * scale.multiplier + 32768) / 65536) + scaledDelta;\n}\n\n/**\n * This function adds the values of the pair kerning lookups `lookups` to the advances `advances` of the glyphs `glyphs`.\n * When `positions` is given, it also adds each value in 1/65536 px, as HarfBuzz scales it at the scale `scale`.\n */\nfunction kern(font: Font, lookups: readonly PairLookup[], glyphs: readonly number[], advances: number[], positions?: number[], scale?: PositionScale): void {\n for (const lookup of lookups) {\n const next = (from: number): number => {\n for (let j = from; j < glyphs.length; j++) if (!(lookup.skip?.(glyphs[j]!) ?? skips(lookup.flags, font.glyphClass(glyphs[j]!)))) return j;\n return -1;\n };\n let i = next(0);\n while (i >= 0) {\n const j = next(i + 1);\n if (j < 0) break;\n const value = lookup.pair(glyphs[i]!, glyphs[j]!);\n if (value === undefined) {\n i = j;\n continue;\n }\n advances[i]! += value.first;\n advances[j]! += value.second;\n if (positions !== undefined && scale !== undefined) {\n positions[i]! += kerningPosition(value.first, value.firstDelta ?? 0, scale);\n positions[j]! += kerningPosition(value.second, value.secondDelta ?? 0, scale);\n }\n i = value.skipSecond ? next(j + 1) : j;\n }\n }\n}\n\n/**\n * This function gives the width of a text with the sum `float32`, as Blink adds the widths of a canvas. Each advance in\n * single precision is cut to 1/65536 px, and HarfBuzz scales each kerning value. The sum of a segment of `canvasSegments`\n * is exact, and the sum of the segments is in single precision.\n */\nfunction float32Width(font: Font, text: string, size: number, options: MeasureOptions): number {\n const { substitute, kerning } = shaperOf(font, options);\n const xScale = Math.trunc(Math.fround(size) * 65536);\n const scale: PositionScale = { xScale, multiplier: Math.floor((xScale * 65536) / font.unitsPerEm), unitsPerEm: font.unitsPerEm };\n const pxPerUnit = size / font.unitsPerEm;\n let total = 0;\n for (const segment of canvasSegments(text)) {\n const glyphs = substitute(segment);\n // Skia gives each advance in single precision, and Blink cuts it to the 16.16 fixed point of HarfBuzz\n const positions = glyphs.map((glyph) => Math.trunc(Math.fround(font.advance(glyph) * pxPerUnit) * 65536));\n kern(font, kerning, glyphs, glyphs.map((glyph) => font.advance(glyph)), positions, scale);\n let units = 0;\n for (const position of positions) units += position;\n total = Math.fround(total + Math.fround(units / 65536));\n }\n return total;\n}\n\n/**\n * This function gives the width of a text in px at the size `size` in px. The width is the sum of the advances after the\n * GSUB substitutions and the pair kerning.\n */\nexport function measureWidth(font: Font, text: string, size: number, options: MeasureOptions = {}): number {\n if (options.sum === \"float32\" && options.rounding !== \"pixel\") return float32Width(font, text, size, options);\n const { glyphs, advances } = glyphAdvances(font, text, options);\n if (options.rounding === \"pixel\") {\n const scale = size / font.unitsPerEm;\n let px = 0;\n glyphs.forEach((glyph, i) => {\n const base = font.advance(glyph);\n // FreeType gives the advance in 26.6 fixed point, and Skia rounds it to whole px\n px += Math.round(Math.round(base * scale * 64) / 64) + Math.round((advances[i]! - base) * scale);\n });\n return px;\n }\n let units = 0;\n for (const advance of advances) units += advance;\n return (units * size) / font.unitsPerEm;\n}\n"],"mappings":";;;AAaA,SAAgB,WAAW,MAAc,MAAc,MAAsB;CAC3E,IAAI,KAAK,IAAI,EAAE,MAAM,YAAY,MAAM,IAAI,MAAM,uCAAuC;CACxF,OAAO;EAAE,UAAU,KAAK,IAAI,CAAC;EAAG,oBAAoB,KAAK,IAAI,CAAC;EAAG,YAAY,KAAK,IAAI,EAAE;EAAG,kBAAkB,KAAK,IAAI,EAAE;EAAG,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"./font.js";
|
|
2
|
+
import { i as isEngineName, n as EngineRules, r as engines, t as EngineName } from "./engines.js";
|
|
3
|
+
import { t as Decompress } from "./sfnt.js";
|
|
4
|
+
/** The limit of `widthBound` for the width of a text over a declared set of characters. It needs no measurement. */
|
|
5
|
+
interface WidthBound {
|
|
6
|
+
/** The largest total advance of one character with all its expansions, in font units. */
|
|
7
|
+
readonly advance: number;
|
|
8
|
+
/** The largest positive kerning of one glyph, in font units. */
|
|
9
|
+
readonly kerning: number;
|
|
10
|
+
/** The largest count of glyphs of one character. */
|
|
11
|
+
readonly glyphs: number;
|
|
12
|
+
/**
|
|
13
|
+
* This function gives the limit in px for a text of `length` UTF-16 units at the size `size`. It takes the length of a
|
|
14
|
+
* string, so it does not read the text. The limit is for a text with only the characters of the set.
|
|
15
|
+
*/
|
|
16
|
+
width(length: number, size: number): number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* This function gives a limit for the width of each text over the characters `characters`, with no measurement. For each such
|
|
20
|
+
* text, `measureWidth(font, text, size, options)` is at most `width(text.length, size)` of the result. Give the same `options`.
|
|
21
|
+
* A text with another character has no limit from this function.
|
|
22
|
+
*
|
|
23
|
+
* The limit is sound, not tight. It follows the widest character of the set. It includes each glyph of the GSUB closure, each
|
|
24
|
+
* dotted circle, each part or composite of the Indic normalization, and the largest positive kerning.
|
|
25
|
+
*/
|
|
26
|
+
declare function widthBound(font: Font, characters: string, options?: MeasureOptions): WidthBound;
|
|
27
|
+
declare namespace fonts_d_exports {
|
|
28
|
+
export { Axis, Decompress, EngineName, EngineRules, Font, Instance, MeasureOptions, ReadOptions, WidthBound, engines, isEngineName, measureWidth, readFont, widthBound };
|
|
29
|
+
}
|
|
30
|
+
export { WidthBound as n, widthBound as r, fonts_d_exports as t };
|
|
31
|
+
//# sourceMappingURL=fonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","names":[],"sources":["../../src/fonts/bound.ts","../../src/fonts.ts"],"mappings":";;;;UAMiB;;WAEN;;WAEA;;WAEA;;;;;EAKT,MAAM,gBAAgB;;;;;;;;;;iBA6FR,WAAW,MAAM,MAAM,oBAAoB,UAAS,iBAAsB"}
|