@mark1russell7/typeset 0.1.4 → 0.1.6

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.
Files changed (48) hide show
  1. package/build/chunks/breaking.js +9 -2
  2. package/build/chunks/breaking.js.map +1 -1
  3. package/build/chunks/engines.js +46 -1
  4. package/build/chunks/engines.js.map +1 -1
  5. package/build/chunks/font.d.ts +6 -0
  6. package/build/chunks/font.d.ts.map +1 -1
  7. package/build/chunks/font.js +543 -315
  8. package/build/chunks/font.js.map +1 -1
  9. package/build/chunks/fonts.d.ts +12 -2
  10. package/build/chunks/fonts.d.ts.map +1 -1
  11. package/build/chunks/fonts.js +3 -2
  12. package/build/chunks/fonts.js.map +1 -1
  13. package/build/chunks/measurer.d.ts +6 -2
  14. package/build/chunks/measurer.d.ts.map +1 -1
  15. package/build/chunks/measurer.js +45 -8
  16. package/build/chunks/measurer.js.map +1 -1
  17. package/build/chunks/paragraph.d.ts +5 -0
  18. package/build/chunks/paragraph.d.ts.map +1 -1
  19. package/build/fonts-inspect.d.ts +11 -1
  20. package/build/fonts-inspect.d.ts.map +1 -1
  21. package/build/fonts-inspect.js +1 -1
  22. package/build/fonts.d.ts +2 -2
  23. package/build/fonts.js +2 -2
  24. package/build/measurer.d.ts +2 -2
  25. package/build/segmentation.d.ts +19 -0
  26. package/build/segmentation.d.ts.map +1 -0
  27. package/build/segmentation.js +267 -0
  28. package/build/segmentation.js.map +1 -0
  29. package/package.json +7 -3
  30. package/src/breaking/paragraph.ts +8 -2
  31. package/src/fonts/context.ts +48 -0
  32. package/src/fonts/font.ts +52 -13
  33. package/src/fonts/index.ts +1 -0
  34. package/src/fonts/indic.ts +51 -42
  35. package/src/fonts/joining.ts +2 -2
  36. package/src/fonts/kerning.ts +48 -34
  37. package/src/fonts/machine.ts +133 -0
  38. package/src/fonts/normalize.ts +27 -0
  39. package/src/fonts/risks.ts +48 -0
  40. package/src/fonts/substitution.ts +15 -44
  41. package/src/fonts-inspect.ts +2 -1
  42. package/src/fonts.ts +1 -0
  43. package/src/measurer/advance.ts +46 -1
  44. package/src/measurer.ts +1 -1
  45. package/src/segmentation/line-table.ts +5 -0
  46. package/src/segmentation/line.ts +203 -0
  47. package/src/segmentation/segments.ts +18 -0
  48. package/src/segmentation.ts +3 -0
@@ -19,7 +19,8 @@ function paragraphOf(text, options) {
19
19
  text: " ",
20
20
  width: space
21
21
  });
22
- const offsets = options.hyphenate === void 0 ? [] : [...new Set(options.hyphenate(word))].filter((o) => o > 0 && o < word.length).sort((a, b) => a - b);
22
+ const free = new Set(options.breaks?.(word) ?? []);
23
+ const offsets = [.../* @__PURE__ */ new Set([...options.hyphenate?.(word) ?? [], ...free])].filter((o) => o > 0 && o < word.length).sort((a, b) => a - b);
23
24
  let start = 0;
24
25
  for (const offset of offsets) {
25
26
  const part = word.slice(start, offset);
@@ -28,7 +29,13 @@ function paragraphOf(text, options) {
28
29
  text: part,
29
30
  width: widthOf(part)
30
31
  });
31
- items.push({
32
+ items.push(free.has(offset) ? {
33
+ type: "penalty",
34
+ text: "",
35
+ width: 0,
36
+ cost: 0,
37
+ flagged: false
38
+ } : {
32
39
  type: "penalty",
33
40
  text: hyphen,
34
41
  width: hyphenWidth,
@@ -1 +1 @@
1
- {"version":3,"file":"breaking.js","names":[],"sources":["../../src/breaking/paragraph.ts","../../src/breaking/breakers.ts","../../src/breaking/measures.ts","../../src/breaking.ts"],"sourcesContent":["/**\n * The paragraph model of the breakers: a list of boxes, glue and penalties, as Knuth and Plass define it. A builder makes\n * the items of a text. The breakers read only the items, so a new rule of break opportunities is a new builder.\n */\n\n/** A width function: the width of a run of text, in any unit. The breakers add the widths and compare them. */\nexport type WidthOf = (text: string) => number;\n\n/** A box: text that the breaker does not break. */\nexport interface Box {\n readonly type: \"box\";\n readonly text: string;\n readonly width: number;\n}\n\n/** Glue: a space between two boxes. A line can end at glue that comes after a box. The line then does not show the glue. */\nexport interface Glue {\n readonly type: \"glue\";\n readonly text: string;\n readonly width: number;\n}\n\n/**\n * A penalty: a break opportunity with a cost. A line that ends at the penalty shows its text, for example a hyphen. A cost of\n * `Infinity` forbids the break, and a cost of `-Infinity` forces it.\n */\nexport interface Penalty {\n readonly type: \"penalty\";\n readonly text: string;\n readonly width: number;\n readonly cost: number;\n /** A flagged penalty is a hyphen. Total fit adds a cost to two flagged breaks in sequence. */\n readonly flagged: boolean;\n}\n\n/** An item of a paragraph. */\nexport type Item = Box | Glue | Penalty;\n\n/** A paragraph: the items in the order of the text. */\nexport interface Paragraph {\n readonly items: readonly Item[];\n}\n\n/** The options of `paragraphOf`. */\nexport interface ParagraphOptions {\n /** The width function of the boxes, the spaces and the hyphens. */\n readonly widthOf: WidthOf;\n /**\n * The hyphenation hook. It gives the offsets in a word where a break with a hyphen is possible. The default gives no\n * offset. The width of each part of a word comes from `widthOf`, so the kerning across an offset is not in the sum.\n */\n readonly hyphenate?: (word: string) => readonly number[];\n /** The text that a line shows at a hyphen break. The default is \"-\". */\n readonly hyphen?: string;\n /** The cost of a hyphen break. The default is 50, as in TeX. */\n readonly hyphenCost?: number;\n}\n\nconst whiteSpace = /\\s+/u;\n\n/**\n * This function makes the paragraph of a text with the break opportunities of CSS `white-space: normal`. Each run of white\n * space becomes one glue of the width of a space. Each word between two runs becomes a box, or boxes and hyphen penalties.\n */\nexport function paragraphOf(text: string, options: ParagraphOptions): Paragraph {\n const { widthOf } = options;\n const hyphen = options.hyphen ?? \"-\";\n const hyphenCost = options.hyphenCost ?? 50;\n const space = widthOf(\" \");\n const hyphenWidth = options.hyphenate === undefined ? 0 : widthOf(hyphen);\n const items: Item[] = [];\n for (const word of text.split(whiteSpace)) {\n if (word === \"\") continue;\n if (items.length > 0) items.push({ type: \"glue\", text: \" \", width: space });\n const offsets = options.hyphenate === undefined ? [] : [...new Set(options.hyphenate(word))].filter((o) => o > 0 && o < word.length).sort((a, b) => a - b);\n let start = 0;\n for (const offset of offsets) {\n const part = word.slice(start, offset);\n items.push({ type: \"box\", text: part, width: widthOf(part) });\n items.push({ type: \"penalty\", text: hyphen, width: hyphenWidth, cost: hyphenCost, flagged: true });\n start = offset;\n }\n const last = word.slice(start);\n items.push({ type: \"box\", text: last, width: widthOf(last) });\n }\n return { items };\n}\n\n/** A line of a broken paragraph. */\nexport interface Line {\n readonly text: string;\n /** The width of the line: its boxes, the glue between them and the text of a penalty at its end. */\n readonly width: number;\n /** The index of the first item of the line. */\n readonly start: number;\n /** The index after the last item of the line. A break at glue or at a penalty has the index of that item. */\n readonly end: number;\n}\n\n/** This function tells if a line can end at the item `index`: glue after a box, or a penalty with a cost below `Infinity`. */\nexport function isBreak(items: readonly Item[], index: number): boolean {\n const item = items[index]!;\n if (item.type === \"glue\") return index > 0 && items[index - 1]!.type === \"box\";\n return item.type === \"penalty\" && item.cost < Infinity;\n}\n\n/** This function gives the index of the first item of a line after a break at `index`. It skips the glue and the penalties. */\nexport function lineStart(items: readonly Item[], index: number): number {\n let i = index + 1;\n while (i < items.length && items[i]!.type !== \"box\") i++;\n return i;\n}\n\n/** This function gives the width of the line from the item `start` to a break at `end`, with the text of a penalty at `end`. */\nexport function lineWidth(items: readonly Item[], start: number, end: number): number {\n let width = 0;\n for (let i = start; i < end; i++) {\n const item = items[i]!;\n if (item.type !== \"penalty\") width += item.width;\n }\n const last = items[end];\n return last?.type === \"penalty\" ? width + last.width : width;\n}\n\n/**\n * This function gives the lines of a paragraph from the indices of its breaks. Each break is the index of glue or of a penalty.\n * The last line ends at the end of the items.\n */\nexport function linesOf(paragraph: Paragraph, breaks: readonly number[]): Line[] {\n const { items } = paragraph;\n const lines: Line[] = [];\n let start = 0;\n for (const end of [...breaks, items.length]) {\n let text = \"\";\n for (let i = start; i < end; i++) {\n const item = items[i]!;\n if (item.type !== \"penalty\") text += item.text;\n }\n const last = items[end];\n if (last?.type === \"penalty\") text += last.text;\n lines.push({ text, width: lineWidth(items, start, end), start, end });\n start = lineStart(items, end);\n }\n return lines;\n}\n","import { isBreak, lineStart, lineWidth, type Paragraph } from \"./paragraph.ts\";\n\n/**\n * A breaker: a strategy that chooses the breaks of a paragraph for the line width `width`. It gives the indices of the\n * items where the lines end, in order. A breaker reads only the items, so any width function and any builder work with it.\n */\nexport interface Breaker {\n readonly name: string;\n breaks(paragraph: Paragraph, width: number): number[];\n}\n\n/**\n * The greedy breaker: first fit, as a browser with `text-wrap: wrap`. Each line takes the items while they fit in the width.\n * A box that is wider than a line stays whole on its own line.\n */\nexport const greedy: Breaker = {\n name: \"greedy\",\n breaks: (paragraph, width) => greedyBreaks(paragraph, width),\n};\n\n/**\n * This function gives the breaks of the greedy breaker. After each break, it reads the items again from the start of the new\n * line, so that each break opportunity of the new line counts.\n */\nfunction greedyBreaks(paragraph: Paragraph, width: number): number[] {\n const { items } = paragraph;\n const breaks: number[] = [];\n let used = 0;\n let candidate = -1;\n const breakAt = (index: number): number => {\n breaks.push(index);\n used = 0;\n candidate = -1;\n return lineStart(items, index) - 1;\n };\n for (let i = 0; i < items.length; i++) {\n const item = items[i]!;\n if (item.type === \"box\") {\n used += item.width;\n if (used > width && candidate >= 0) i = breakAt(candidate);\n } else if (item.type === \"penalty\" && item.cost === -Infinity) {\n i = breakAt(i);\n } else if (item.type === \"glue\") {\n if (isBreak(items, i)) candidate = i;\n used += item.width;\n } else if (isBreak(items, i) && used + item.width <= width) {\n candidate = i;\n }\n }\n return breaks;\n}\n\n/** The options of the total fit breaker. */\nexport interface TotalFitOptions {\n /** The cost of each line, as `\\linepenalty` of TeX. A larger value gives fewer lines. The default is 10. */\n readonly linePenalty?: number;\n /** The cost of two hyphen breaks in sequence. The default is 3000, as `\\doublehyphendemerits` of TeX. */\n readonly flaggedCost?: number;\n}\n\n/**\n * This function gives the total fit breaker of Knuth and Plass for text with a ragged right edge. It chooses the breaks with\n * the least sum of demerits over all the lines. The demerits of a line are `(linePenalty + 100 r²)²` plus the square of the\n * cost of its penalty. The ratio `r` is the free space of the line divided by the width. The last line has `r = 0`.\n */\nexport function totalFit(options: TotalFitOptions = {}): Breaker {\n const linePenalty = options.linePenalty ?? 10;\n const flaggedCost = options.flaggedCost ?? 3000;\n return {\n name: \"total-fit\",\n breaks: (paragraph, width) => totalFitBreaks(paragraph, width, linePenalty, flaggedCost),\n };\n}\n\n/** The total fit breaker with the default options. */\nexport const knuthPlass: Breaker = totalFit();\n\n/** This function gives the breaks of the total fit breaker, by dynamic programming over the break opportunities. */\nfunction totalFitBreaks(paragraph: Paragraph, width: number, linePenalty: number, flaggedCost: number): number[] {\n const { items } = paragraph;\n // The nodes: the start of the paragraph (-1), each break opportunity, and the end (items.length)\n const nodes = [-1];\n for (let i = 0; i < items.length; i++) if (isBreak(items, i)) nodes.push(i);\n nodes.push(items.length);\n const best = new Array<number>(nodes.length).fill(Infinity);\n const previous = new Array<number>(nodes.length).fill(-1);\n best[0] = 0;\n for (let a = 0; a < nodes.length - 1; a++) {\n if (best[a] === Infinity) continue;\n const start = a === 0 ? 0 : lineStart(items, nodes[a]!);\n const flaggedBefore = a > 0 && isFlagged(paragraph, nodes[a]!);\n for (let b = a + 1; b < nodes.length; b++) {\n const end = nodes[b]!;\n const last = b === nodes.length - 1;\n const used = lineWidth(items, start, end);\n const overflow = used > width;\n // A line wider than the width is possible only when no break opportunity is inside it\n if (overflow && b > a + 1) {\n if (items[end]?.type === \"penalty\") continue;\n break;\n }\n const penalty = items[end];\n const cost = penalty?.type === \"penalty\" ? penalty.cost : 0;\n const ratio = last || overflow ? 0 : (width - used) / width;\n let demerits = (linePenalty + 100 * ratio * ratio) ** 2;\n if (cost > 0) demerits += cost * cost;\n else if (cost > -Infinity && cost < 0) demerits -= cost * cost;\n if (flaggedBefore && isFlagged(paragraph, end)) demerits += flaggedCost;\n const total = best[a]! + demerits;\n if (total < best[b]!) {\n best[b] = total;\n previous[b] = a;\n }\n // A forced break ends each line that comes to it\n if (cost === -Infinity) break;\n }\n }\n const breaks: number[] = [];\n for (let b = previous[nodes.length - 1]!; b > 0; b = previous[b]!) breaks.push(nodes[b]!);\n return breaks.reverse();\n}\n\n/** This function tells if the item `index` is a flagged penalty. */\nfunction isFlagged(paragraph: Paragraph, index: number): boolean {\n const item = paragraph.items[index];\n return item?.type === \"penalty\" && item.flagged;\n}\n\n/** The options of the balanced breaker. */\nexport interface BalancedOptions {\n /** The steps of the search for the width. The default is 32. */\n readonly steps?: number;\n}\n\n/**\n * This function gives the balanced breaker, as a browser with `text-wrap: balance`. It keeps the line count of the greedy\n * breaker, and it finds the least width that gives that count. Thus the lines have more equal widths.\n */\nexport function balancedBreaker(options: BalancedOptions = {}): Breaker {\n const steps = options.steps ?? 32;\n return {\n name: \"balanced\",\n breaks: (paragraph, width) => {\n const count = greedyBreaks(paragraph, width).length;\n let low = 0;\n let high = width;\n for (let step = 0; step < steps; step++) {\n const middle = (low + high) / 2;\n if (greedyBreaks(paragraph, middle).length === count) high = middle;\n else low = middle;\n }\n return greedyBreaks(paragraph, high);\n },\n };\n}\n\n/** The balanced breaker with the default options. */\nexport const balanced: Breaker = balancedBreaker();\n\n/** The breakers of the package, by name. */\nexport const breakers: Readonly<Record<\"greedy\" | \"total-fit\" | \"balanced\", Breaker>> = { greedy, \"total-fit\": knuthPlass, balanced };\n","import type { Line } from \"./paragraph.ts\";\n\n/**\n * This function gives the raggedness of the lines for the width `width`: the mean of `((width - line) / width)²` over the\n * lines before the last line. It is 0 for one line. `@mark1russell7/layout-contract/text` uses the same measure.\n */\nexport function raggedness(lines: readonly Line[], width: number): number {\n if (lines.length < 2) return 0;\n let sum = 0;\n for (let i = 0; i < lines.length - 1; i++) {\n const free = (width - lines[i]!.width) / width;\n sum += free * free;\n }\n return sum / (lines.length - 1);\n}\n\n/** This function gives the spread of the lines: the width of the widest line less the width of the narrowest line, the last line included. */\nexport function spread(lines: readonly Line[]): number {\n if (lines.length === 0) return 0;\n let widest = -Infinity;\n let narrowest = Infinity;\n for (const line of lines) {\n widest = Math.max(widest, line.width);\n narrowest = Math.min(narrowest, line.width);\n }\n return widest - narrowest;\n}\n","export { balanced, balancedBreaker, breakers, greedy, knuthPlass, totalFit, type BalancedOptions, type Breaker, type TotalFitOptions } from \"./breaking/breakers.ts\";\nexport { raggedness, spread } from \"./breaking/measures.ts\";\nexport { isBreak, lineStart, lineWidth, linesOf, paragraphOf, type Box, type Glue, type Item, type Line, type Paragraph, type ParagraphOptions, type Penalty, type WidthOf } from \"./breaking/paragraph.ts\";\n"],"mappings":";;AA0DA,MAAM,aAAa;;;;;AAMnB,SAAgB,YAAY,MAAc,SAAsC;CAC9E,MAAM,EAAE,YAAY;CACpB,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,QAAQ,QAAQ,GAAG;CACzB,MAAM,cAAc,QAAQ,cAAc,KAAA,IAAY,IAAI,QAAQ,MAAM;CACxE,MAAM,QAAgB,CAAC;CACvB,KAAK,MAAM,QAAQ,KAAK,MAAM,UAAU,GAAG;EACzC,IAAI,SAAS,IAAI;EACjB,IAAI,MAAM,SAAS,GAAG,MAAM,KAAK;GAAE,MAAM;GAAQ,MAAM;GAAK,OAAO;EAAM,CAAC;EAC1E,MAAM,UAAU,QAAQ,cAAc,KAAA,IAAY,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,QAAQ,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,MAAM,IAAI,KAAK,IAAI,KAAK,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC;EACzJ,IAAI,QAAQ;EACZ,KAAK,MAAM,UAAU,SAAS;GAC5B,MAAM,OAAO,KAAK,MAAM,OAAO,MAAM;GACrC,MAAM,KAAK;IAAE,MAAM;IAAO,MAAM;IAAM,OAAO,QAAQ,IAAI;GAAE,CAAC;GAC5D,MAAM,KAAK;IAAE,MAAM;IAAW,MAAM;IAAQ,OAAO;IAAa,MAAM;IAAY,SAAS;GAAK,CAAC;GACjG,QAAQ;EACV;EACA,MAAM,OAAO,KAAK,MAAM,KAAK;EAC7B,MAAM,KAAK;GAAE,MAAM;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,OAAwB;CAC/D,MAAM,OAAO,UAAU,MAAM;CAC7B,OAAO,MAAM,SAAS,aAAa,KAAK;AAC1C;;;;;AAYA,SAAgB,gBAAgB,UAA2B,CAAC,GAAY;CACtE,MAAM,QAAQ,QAAQ,SAAS;CAC/B,OAAO;EACL,MAAM;EACN,SAAS,WAAW,UAAU;GAC5B,MAAM,QAAQ,aAAa,WAAW,KAAK,CAAC,CAAC;GAC7C,IAAI,MAAM;GACV,IAAI,OAAO;GACX,KAAK,IAAI,OAAO,GAAG,OAAO,OAAO,QAAQ;IACvC,MAAM,UAAU,MAAM,QAAQ;IAC9B,IAAI,aAAa,WAAW,MAAM,CAAC,CAAC,WAAW,OAAO,OAAO;SACxD,MAAM;GACb;GACA,OAAO,aAAa,WAAW,IAAI;EACrC;CACF;AACF;;AAGA,MAAa,WAAoB,gBAAgB;;AAGjD,MAAa,WAA2E;CAAE;CAAQ,aAAa;CAAY;AAAS;;;;;;AC1JpI,SAAgB,WAAW,OAAwB,OAAuB;CACxE,IAAI,MAAM,SAAS,GAAG,OAAO;CAC7B,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;EACzC,MAAM,QAAQ,QAAQ,MAAM,EAAE,CAAE,SAAS;EACzC,OAAO,OAAO;CAChB;CACA,OAAO,OAAO,MAAM,SAAS;AAC/B;;AAGA,SAAgB,OAAO,OAAgC;CACrD,IAAI,MAAM,WAAW,GAAG,OAAO;CAC/B,IAAI,SAAS;CACb,IAAI,YAAY;CAChB,KAAK,MAAM,QAAQ,OAAO;EACxB,SAAS,KAAK,IAAI,QAAQ,KAAK,KAAK;EACpC,YAAY,KAAK,IAAI,WAAW,KAAK,KAAK;CAC5C;CACA,OAAO,SAAS;AAClB"}
1
+ {"version":3,"file":"breaking.js","names":[],"sources":["../../src/breaking/paragraph.ts","../../src/breaking/breakers.ts","../../src/breaking/measures.ts","../../src/breaking.ts"],"sourcesContent":["/**\n * The paragraph model of the breakers: a list of boxes, glue and penalties, as Knuth and Plass define it. A builder makes\n * the items of a text. The breakers read only the items, so a new rule of break opportunities is a new builder.\n */\n\n/** A width function: the width of a run of text, in any unit. The breakers add the widths and compare them. */\nexport type WidthOf = (text: string) => number;\n\n/** A box: text that the breaker does not break. */\nexport interface Box {\n readonly type: \"box\";\n readonly text: string;\n readonly width: number;\n}\n\n/** Glue: a space between two boxes. A line can end at glue that comes after a box. The line then does not show the glue. */\nexport interface Glue {\n readonly type: \"glue\";\n readonly text: string;\n readonly width: number;\n}\n\n/**\n * A penalty: a break opportunity with a cost. A line that ends at the penalty shows its text, for example a hyphen. A cost of\n * `Infinity` forbids the break, and a cost of `-Infinity` forces it.\n */\nexport interface Penalty {\n readonly type: \"penalty\";\n readonly text: string;\n readonly width: number;\n readonly cost: number;\n /** A flagged penalty is a hyphen. Total fit adds a cost to two flagged breaks in sequence. */\n readonly flagged: boolean;\n}\n\n/** An item of a paragraph. */\nexport type Item = Box | Glue | Penalty;\n\n/** A paragraph: the items in the order of the text. */\nexport interface Paragraph {\n readonly items: readonly Item[];\n}\n\n/** The options of `paragraphOf`. */\nexport interface ParagraphOptions {\n /** The width function of the boxes, the spaces and the hyphens. */\n readonly widthOf: WidthOf;\n /**\n * The hyphenation hook. It gives the offsets in a word where a break with a hyphen is possible. The default gives no\n * offset. The width of each part of a word comes from `widthOf`, so the kerning across an offset is not in the sum.\n */\n readonly hyphenate?: (word: string) => readonly number[];\n /**\n * The hook of the break places inside a word, for example `lineBreaks` of `./segmentation`. It gives offsets in a word where\n * a line can end with no hyphen and no cost. The default gives no offset. This hook wins at an offset that `hyphenate` also gives.\n */\n readonly breaks?: (word: string) => readonly number[];\n /** The text that a line shows at a hyphen break. The default is \"-\". */\n readonly hyphen?: string;\n /** The cost of a hyphen break. The default is 50, as in TeX. */\n readonly hyphenCost?: number;\n}\n\nconst whiteSpace = /\\s+/u;\n\n/**\n * This function makes the paragraph of a text with the break opportunities of CSS `white-space: normal`. Each run of white\n * space becomes one glue of the width of a space. Each word between two runs becomes a box, or boxes and hyphen penalties.\n */\nexport function paragraphOf(text: string, options: ParagraphOptions): Paragraph {\n const { widthOf } = options;\n const hyphen = options.hyphen ?? \"-\";\n const hyphenCost = options.hyphenCost ?? 50;\n const space = widthOf(\" \");\n const hyphenWidth = options.hyphenate === undefined ? 0 : widthOf(hyphen);\n const items: Item[] = [];\n for (const word of text.split(whiteSpace)) {\n if (word === \"\") continue;\n if (items.length > 0) items.push({ type: \"glue\", text: \" \", width: space });\n const free = new Set(options.breaks?.(word) ?? []);\n const offsets = [...new Set([...(options.hyphenate?.(word) ?? []), ...free])].filter((o) => o > 0 && o < word.length).sort((a, b) => a - b);\n let start = 0;\n for (const offset of offsets) {\n const part = word.slice(start, offset);\n items.push({ type: \"box\", text: part, width: widthOf(part) });\n items.push(free.has(offset) ? { type: \"penalty\", text: \"\", width: 0, cost: 0, flagged: false } : { type: \"penalty\", text: hyphen, width: hyphenWidth, cost: hyphenCost, flagged: true });\n start = offset;\n }\n const last = word.slice(start);\n items.push({ type: \"box\", text: last, width: widthOf(last) });\n }\n return { items };\n}\n\n/** A line of a broken paragraph. */\nexport interface Line {\n readonly text: string;\n /** The width of the line: its boxes, the glue between them and the text of a penalty at its end. */\n readonly width: number;\n /** The index of the first item of the line. */\n readonly start: number;\n /** The index after the last item of the line. A break at glue or at a penalty has the index of that item. */\n readonly end: number;\n}\n\n/** This function tells if a line can end at the item `index`: glue after a box, or a penalty with a cost below `Infinity`. */\nexport function isBreak(items: readonly Item[], index: number): boolean {\n const item = items[index]!;\n if (item.type === \"glue\") return index > 0 && items[index - 1]!.type === \"box\";\n return item.type === \"penalty\" && item.cost < Infinity;\n}\n\n/** This function gives the index of the first item of a line after a break at `index`. It skips the glue and the penalties. */\nexport function lineStart(items: readonly Item[], index: number): number {\n let i = index + 1;\n while (i < items.length && items[i]!.type !== \"box\") i++;\n return i;\n}\n\n/** This function gives the width of the line from the item `start` to a break at `end`, with the text of a penalty at `end`. */\nexport function lineWidth(items: readonly Item[], start: number, end: number): number {\n let width = 0;\n for (let i = start; i < end; i++) {\n const item = items[i]!;\n if (item.type !== \"penalty\") width += item.width;\n }\n const last = items[end];\n return last?.type === \"penalty\" ? width + last.width : width;\n}\n\n/**\n * This function gives the lines of a paragraph from the indices of its breaks. Each break is the index of glue or of a penalty.\n * The last line ends at the end of the items.\n */\nexport function linesOf(paragraph: Paragraph, breaks: readonly number[]): Line[] {\n const { items } = paragraph;\n const lines: Line[] = [];\n let start = 0;\n for (const end of [...breaks, items.length]) {\n let text = \"\";\n for (let i = start; i < end; i++) {\n const item = items[i]!;\n if (item.type !== \"penalty\") text += item.text;\n }\n const last = items[end];\n if (last?.type === \"penalty\") text += last.text;\n lines.push({ text, width: lineWidth(items, start, end), start, end });\n start = lineStart(items, end);\n }\n return lines;\n}\n","import { isBreak, lineStart, lineWidth, type Paragraph } from \"./paragraph.ts\";\n\n/**\n * A breaker: a strategy that chooses the breaks of a paragraph for the line width `width`. It gives the indices of the\n * items where the lines end, in order. A breaker reads only the items, so any width function and any builder work with it.\n */\nexport interface Breaker {\n readonly name: string;\n breaks(paragraph: Paragraph, width: number): number[];\n}\n\n/**\n * The greedy breaker: first fit, as a browser with `text-wrap: wrap`. Each line takes the items while they fit in the width.\n * A box that is wider than a line stays whole on its own line.\n */\nexport const greedy: Breaker = {\n name: \"greedy\",\n breaks: (paragraph, width) => greedyBreaks(paragraph, width),\n};\n\n/**\n * This function gives the breaks of the greedy breaker. After each break, it reads the items again from the start of the new\n * line, so that each break opportunity of the new line counts.\n */\nfunction greedyBreaks(paragraph: Paragraph, width: number): number[] {\n const { items } = paragraph;\n const breaks: number[] = [];\n let used = 0;\n let candidate = -1;\n const breakAt = (index: number): number => {\n breaks.push(index);\n used = 0;\n candidate = -1;\n return lineStart(items, index) - 1;\n };\n for (let i = 0; i < items.length; i++) {\n const item = items[i]!;\n if (item.type === \"box\") {\n used += item.width;\n if (used > width && candidate >= 0) i = breakAt(candidate);\n } else if (item.type === \"penalty\" && item.cost === -Infinity) {\n i = breakAt(i);\n } else if (item.type === \"glue\") {\n if (isBreak(items, i)) candidate = i;\n used += item.width;\n } else if (isBreak(items, i) && used + item.width <= width) {\n candidate = i;\n }\n }\n return breaks;\n}\n\n/** The options of the total fit breaker. */\nexport interface TotalFitOptions {\n /** The cost of each line, as `\\linepenalty` of TeX. A larger value gives fewer lines. The default is 10. */\n readonly linePenalty?: number;\n /** The cost of two hyphen breaks in sequence. The default is 3000, as `\\doublehyphendemerits` of TeX. */\n readonly flaggedCost?: number;\n}\n\n/**\n * This function gives the total fit breaker of Knuth and Plass for text with a ragged right edge. It chooses the breaks with\n * the least sum of demerits over all the lines. The demerits of a line are `(linePenalty + 100 r²)²` plus the square of the\n * cost of its penalty. The ratio `r` is the free space of the line divided by the width. The last line has `r = 0`.\n */\nexport function totalFit(options: TotalFitOptions = {}): Breaker {\n const linePenalty = options.linePenalty ?? 10;\n const flaggedCost = options.flaggedCost ?? 3000;\n return {\n name: \"total-fit\",\n breaks: (paragraph, width) => totalFitBreaks(paragraph, width, linePenalty, flaggedCost),\n };\n}\n\n/** The total fit breaker with the default options. */\nexport const knuthPlass: Breaker = totalFit();\n\n/** This function gives the breaks of the total fit breaker, by dynamic programming over the break opportunities. */\nfunction totalFitBreaks(paragraph: Paragraph, width: number, linePenalty: number, flaggedCost: number): number[] {\n const { items } = paragraph;\n // The nodes: the start of the paragraph (-1), each break opportunity, and the end (items.length)\n const nodes = [-1];\n for (let i = 0; i < items.length; i++) if (isBreak(items, i)) nodes.push(i);\n nodes.push(items.length);\n const best = new Array<number>(nodes.length).fill(Infinity);\n const previous = new Array<number>(nodes.length).fill(-1);\n best[0] = 0;\n for (let a = 0; a < nodes.length - 1; a++) {\n if (best[a] === Infinity) continue;\n const start = a === 0 ? 0 : lineStart(items, nodes[a]!);\n const flaggedBefore = a > 0 && isFlagged(paragraph, nodes[a]!);\n for (let b = a + 1; b < nodes.length; b++) {\n const end = nodes[b]!;\n const last = b === nodes.length - 1;\n const used = lineWidth(items, start, end);\n const overflow = used > width;\n // A line wider than the width is possible only when no break opportunity is inside it\n if (overflow && b > a + 1) {\n if (items[end]?.type === \"penalty\") continue;\n break;\n }\n const penalty = items[end];\n const cost = penalty?.type === \"penalty\" ? penalty.cost : 0;\n const ratio = last || overflow ? 0 : (width - used) / width;\n let demerits = (linePenalty + 100 * ratio * ratio) ** 2;\n if (cost > 0) demerits += cost * cost;\n else if (cost > -Infinity && cost < 0) demerits -= cost * cost;\n if (flaggedBefore && isFlagged(paragraph, end)) demerits += flaggedCost;\n const total = best[a]! + demerits;\n if (total < best[b]!) {\n best[b] = total;\n previous[b] = a;\n }\n // A forced break ends each line that comes to it\n if (cost === -Infinity) break;\n }\n }\n const breaks: number[] = [];\n for (let b = previous[nodes.length - 1]!; b > 0; b = previous[b]!) breaks.push(nodes[b]!);\n return breaks.reverse();\n}\n\n/** This function tells if the item `index` is a flagged penalty. */\nfunction isFlagged(paragraph: Paragraph, index: number): boolean {\n const item = paragraph.items[index];\n return item?.type === \"penalty\" && item.flagged;\n}\n\n/** The options of the balanced breaker. */\nexport interface BalancedOptions {\n /** The steps of the search for the width. The default is 32. */\n readonly steps?: number;\n}\n\n/**\n * This function gives the balanced breaker, as a browser with `text-wrap: balance`. It keeps the line count of the greedy\n * breaker, and it finds the least width that gives that count. Thus the lines have more equal widths.\n */\nexport function balancedBreaker(options: BalancedOptions = {}): Breaker {\n const steps = options.steps ?? 32;\n return {\n name: \"balanced\",\n breaks: (paragraph, width) => {\n const count = greedyBreaks(paragraph, width).length;\n let low = 0;\n let high = width;\n for (let step = 0; step < steps; step++) {\n const middle = (low + high) / 2;\n if (greedyBreaks(paragraph, middle).length === count) high = middle;\n else low = middle;\n }\n return greedyBreaks(paragraph, high);\n },\n };\n}\n\n/** The balanced breaker with the default options. */\nexport const balanced: Breaker = balancedBreaker();\n\n/** The breakers of the package, by name. */\nexport const breakers: Readonly<Record<\"greedy\" | \"total-fit\" | \"balanced\", Breaker>> = { greedy, \"total-fit\": knuthPlass, balanced };\n","import type { Line } from \"./paragraph.ts\";\n\n/**\n * This function gives the raggedness of the lines for the width `width`: the mean of `((width - line) / width)²` over the\n * lines before the last line. It is 0 for one line. `@mark1russell7/layout-contract/text` uses the same measure.\n */\nexport function raggedness(lines: readonly Line[], width: number): number {\n if (lines.length < 2) return 0;\n let sum = 0;\n for (let i = 0; i < lines.length - 1; i++) {\n const free = (width - lines[i]!.width) / width;\n sum += free * free;\n }\n return sum / (lines.length - 1);\n}\n\n/** This function gives the spread of the lines: the width of the widest line less the width of the narrowest line, the last line included. */\nexport function spread(lines: readonly Line[]): number {\n if (lines.length === 0) return 0;\n let widest = -Infinity;\n let narrowest = Infinity;\n for (const line of lines) {\n widest = Math.max(widest, line.width);\n narrowest = Math.min(narrowest, line.width);\n }\n return widest - narrowest;\n}\n","export { balanced, balancedBreaker, breakers, greedy, knuthPlass, totalFit, type BalancedOptions, type Breaker, type TotalFitOptions } from \"./breaking/breakers.ts\";\nexport { raggedness, spread } from \"./breaking/measures.ts\";\nexport { isBreak, lineStart, lineWidth, linesOf, paragraphOf, type Box, type Glue, type Item, type Line, type Paragraph, type ParagraphOptions, type Penalty, type WidthOf } from \"./breaking/paragraph.ts\";\n"],"mappings":";;AA+DA,MAAM,aAAa;;;;;AAMnB,SAAgB,YAAY,MAAc,SAAsC;CAC9E,MAAM,EAAE,YAAY;CACpB,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,QAAQ,QAAQ,GAAG;CACzB,MAAM,cAAc,QAAQ,cAAc,KAAA,IAAY,IAAI,QAAQ,MAAM;CACxE,MAAM,QAAgB,CAAC;CACvB,KAAK,MAAM,QAAQ,KAAK,MAAM,UAAU,GAAG;EACzC,IAAI,SAAS,IAAI;EACjB,IAAI,MAAM,SAAS,GAAG,MAAM,KAAK;GAAE,MAAM;GAAQ,MAAM;GAAK,OAAO;EAAM,CAAC;EAC1E,MAAM,OAAO,IAA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;;AAGjD,MAAa,WAA2E;CAAE;CAAQ,aAAa;CAAY;AAAS;;;;;;AC1JpI,SAAgB,WAAW,OAAwB,OAAuB;CACxE,IAAI,MAAM,SAAS,GAAG,OAAO;CAC7B,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;EACzC,MAAM,QAAQ,QAAQ,MAAM,EAAE,CAAE,SAAS;EACzC,OAAO,OAAO;CAChB;CACA,OAAO,OAAO,MAAM,SAAS;AAC/B;;AAGA,SAAgB,OAAO,OAAgC;CACrD,IAAI,MAAM,WAAW,GAAG,OAAO;CAC/B,IAAI,SAAS;CACb,IAAI,YAAY;CAChB,KAAK,MAAM,QAAQ,OAAO;EACxB,SAAS,KAAK,IAAI,QAAQ,KAAK,KAAK;EACpC,YAAY,KAAK,IAAI,WAAW,KAAK,KAAK;CAC5C;CACA,OAAO,SAAS;AAClB"}
@@ -1,3 +1,48 @@
1
+ import { f as hasDefaultIgnorable, i as shapingOf, m as normalizeCodePoints, s as canvasWords, t as glyphAdvances } from "./font.js";
2
+ // src/fonts/risks.ts
3
+ /** The risks of shaping: the text that the model cannot measure with trust. */
4
+ const unshaped = /[\p{sc=Beng}\p{sc=Guru}\p{sc=Gujr}\p{sc=Orya}\p{sc=Taml}\p{sc=Telu}\p{sc=Knda}\p{sc=Mlym}\p{sc=Sinh}\p{sc=Khmr}\p{sc=Mymr}\p{sc=Tibt}\p{sc=Mong}\p{sc=Nkoo}\p{sc=Mand}]+/gu;
5
+ const pictograph = String.raw`\p{ExtPict}(?:\uFE0F|[\u{1F3FB}-\u{1F3FF}])?`;
6
+ const sequences = new RegExp(String.raw`(\p{ExtPict}[\u{E0020}-\u{E007E}]+\u{E007F})|(${pictograph}(?:\u200D${pictograph})+)|([0-9#*]\uFE0F?\u20E3)|(\p{RI}\p{RI})|([\uFE00-\uFE0F\u{E0100}-\u{E01EF}])`, "gu");
7
+ const sequenceCodes = [
8
+ "tag",
9
+ "emoji-zwj",
10
+ "keycap",
11
+ "flag",
12
+ "variation-selector"
13
+ ];
14
+ const clusters = /\P{M}\p{M}*|\p{M}+/gu;
15
+ const control = /\p{Cc}/u;
16
+ /** This function gives the risks of a text in text order. An empty list is not a proof of a correct width. */
17
+ function shapingRisks(font, text, options = {}) {
18
+ const risks = [];
19
+ const add = (code, index, { length }) => risks.push({
20
+ code,
21
+ index,
22
+ length
23
+ });
24
+ const absent = (codePoint) => {
25
+ const character = String.fromCodePoint(codePoint);
26
+ return font.glyph(codePoint) === 0 && !control.test(character) && !hasDefaultIgnorable(character);
27
+ };
28
+ const hasGlyph = (codePoint) => font.glyph(codePoint) !== 0;
29
+ for (const { 0: cluster, index } of text.matchAll(clusters)) if (normalizeCodePoints(Array.from(cluster, (character) => character.codePointAt(0)), {
30
+ hasGlyph,
31
+ shortCircuit: true
32
+ }).some(absent)) add("missing-glyph", index, cluster);
33
+ for (const { 0: part, index } of text.matchAll(unshaped)) add("unshaped-script", index, part);
34
+ for (const match of text.matchAll(sequences)) add(sequenceCodes[match.slice(1).findIndex(Boolean)], match.index, match[0]);
35
+ const tests = options.kerning === false ? [] : font.contextKerning?.(shapingOf(font, options).script) ?? [];
36
+ if (tests.length > 0) {
37
+ let index = 0;
38
+ for (const word of options.shaping === "canvas" ? canvasWords(text) : [text]) {
39
+ const { glyphs } = glyphAdvances(font, word, options);
40
+ if (tests.some((test) => test(glyphs))) add("positioning", index, word);
41
+ index += word.length;
42
+ }
43
+ }
44
+ return risks.sort((a, b) => a.index - b.index);
45
+ }
1
46
  // src/fonts/engines.ts
2
47
  /**
3
48
  * The rules of the text engines of Chromium, one row for each engine. The fonts runs of typeset#27 measured each row
@@ -30,6 +75,6 @@ const engines = {
30
75
  function isEngineName(name) {
31
76
  return Object.hasOwn(engines, name);
32
77
  }
33
- export { isEngineName as n, engines as t };
78
+ export { isEngineName as n, shapingRisks as r, engines as t };
34
79
 
35
80
  //# sourceMappingURL=engines.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engines.js","names":[],"sources":["../../src/fonts/engines.ts"],"sourcesContent":["/**\n * The rules of one text engine for the widths of a font. The fields `deltas` and `metrics` are options of `readFont`, and\n * the fields `rounding` and `sum` are options of `measureWidth`. Thus a caller spreads the same row into the two calls.\n */\nexport interface EngineRules {\n /** The rounding of the `HVAR` and `gvar` deltas of an instance. */\n readonly deltas: \"round\" | \"exact\";\n /** The advance of a composite glyph: its own advance, or the advance of its component with the flag USE_MY_METRICS. */\n readonly metrics: \"own\" | \"component\";\n /** The rounding of each advance: `pixel` rounds it to whole px, and `exact` keeps the fraction. */\n readonly rounding: \"exact\" | \"pixel\";\n /**\n * The sum of the advances: `exact`, or `float32` as Blink adds the widths of the words of a canvas in single precision.\n * A sum of whole px is exact in single precision, so the rounding `pixel` needs no `float32` sum.\n */\n readonly sum: \"exact\" | \"float32\";\n}\n\n/**\n * The rules of the text engines of Chromium, one row for each engine. The fonts runs of typeset#27 measured each row\n * against the canvas, and the T1d diagnosis of the sum measured the field `sum`. A new engine is a new row.\n */\nexport const engines: { readonly freetype: EngineRules; readonly coretext: EngineRules; readonly directwrite: EngineRules } = {\n /** FreeType, as Chromium on Linux uses it: rounded deltas, and each advance in whole px. */\n freetype: { deltas: \"round\", metrics: \"own\", rounding: \"pixel\", sum: \"exact\" },\n /** CoreText on macOS: it keeps the fraction of the deltas. */\n coretext: { deltas: \"exact\", metrics: \"own\", rounding: \"exact\", sum: \"float32\" },\n /** DirectWrite on Windows: a composite glyph has the advance of its USE_MY_METRICS component. */\n directwrite: { deltas: \"round\", metrics: \"component\", rounding: \"exact\", sum: \"float32\" },\n};\n\n/** The name of a text engine of the table `engines`. */\nexport type EngineName = keyof typeof engines;\n\n/** This function tells if a text is the name of an engine of the table `engines`. */\nexport function isEngineName(name: string): name is EngineName {\n return Object.hasOwn(engines, name);\n}\n"],"mappings":";;;;;AAsBA,MAAa,UAAiH;;CAE5H,UAAU;EAAE,QAAQ;EAAS,SAAS;EAAO,UAAU;EAAS,KAAK;CAAQ;;CAE7E,UAAU;EAAE,QAAQ;EAAS,SAAS;EAAO,UAAU;EAAS,KAAK;CAAU;;CAE/E,aAAa;EAAE,QAAQ;EAAS,SAAS;EAAa,UAAU;EAAS,KAAK;CAAU;AAC1F;;AAMA,SAAgB,aAAa,MAAkC;CAC7D,OAAO,OAAO,OAAO,SAAS,IAAI;AACpC"}
1
+ {"version":3,"file":"engines.js","names":[],"sources":["../../src/fonts/risks.ts","../../src/fonts/engines.ts"],"sourcesContent":["/** The risks of shaping: the text that the model cannot measure with trust. */\nimport { glyphAdvances, shapingOf, type Font, type MeasureOptions } from \"./font.ts\";\nimport { hasDefaultIgnorable, normalizeCodePoints } from \"./normalize.ts\";\nimport { canvasWords } from \"./words.ts\";\n\n/** The kinds of risk. */\nexport type ShapingRiskCode = \"missing-glyph\" | \"unshaped-script\" | \"emoji-zwj\" | \"variation-selector\" | \"keycap\" | \"flag\" | \"tag\" | \"positioning\";\n\n/** One part of a text that the model does not shape as HarfBuzz does, in UTF-16 units. */\nexport interface ShapingRisk {\n readonly code: ShapingRiskCode;\n readonly index: number;\n readonly length: number;\n}\n\nconst unshaped = /[\\p{sc=Beng}\\p{sc=Guru}\\p{sc=Gujr}\\p{sc=Orya}\\p{sc=Taml}\\p{sc=Telu}\\p{sc=Knda}\\p{sc=Mlym}\\p{sc=Sinh}\\p{sc=Khmr}\\p{sc=Mymr}\\p{sc=Tibt}\\p{sc=Mong}\\p{sc=Nkoo}\\p{sc=Mand}]+/gu;\nconst pictograph = String.raw`\\p{ExtPict}(?:\\uFE0F|[\\u{1F3FB}-\\u{1F3FF}])?`;\n// The longest forms come first\nconst sequences = new RegExp(String.raw`(\\p{ExtPict}[\\u{E0020}-\\u{E007E}]+\\u{E007F})|(${pictograph}(?:\\u200D${pictograph})+)|([0-9#*]\\uFE0F?\\u20E3)|(\\p{RI}\\p{RI})|([\\uFE00-\\uFE0F\\u{E0100}-\\u{E01EF}])`, \"gu\");\nconst sequenceCodes: readonly ShapingRiskCode[] = [\"tag\", \"emoji-zwj\", \"keycap\", \"flag\", \"variation-selector\"];\nconst clusters = /\\P{M}\\p{M}*|\\p{M}+/gu;\nconst control = /\\p{Cc}/u;\n\n/** This function gives the risks of a text in text order. An empty list is not a proof of a correct width. */\nexport function shapingRisks(font: Font, text: string, options: MeasureOptions = {}): ShapingRisk[] {\n const risks: ShapingRisk[] = [];\n const add = (code: ShapingRiskCode, index: number, { length }: string): number => risks.push({ code, index, length });\n const absent = (codePoint: number): boolean => {\n const character = String.fromCodePoint(codePoint);\n return font.glyph(codePoint) === 0 && !control.test(character) && !hasDefaultIgnorable(character);\n };\n const hasGlyph = (codePoint: number): boolean => font.glyph(codePoint) !== 0;\n for (const { 0: cluster, index } of text.matchAll(clusters)) {\n if (normalizeCodePoints(Array.from(cluster, (character) => character.codePointAt(0)!), { hasGlyph, shortCircuit: true }).some(absent)) add(\"missing-glyph\", index, cluster);\n }\n for (const { 0: part, index } of text.matchAll(unshaped)) add(\"unshaped-script\", index, part);\n for (const match of text.matchAll(sequences)) add(sequenceCodes[match.slice(1).findIndex(Boolean)]!, match.index, match[0]);\n const tests = options.kerning === false ? [] : font.contextKerning?.(shapingOf(font, options).script) ?? [];\n if (tests.length > 0) {\n let index = 0;\n for (const word of options.shaping === \"canvas\" ? canvasWords(text) : [text]) {\n const { glyphs } = glyphAdvances(font, word, options);\n if (tests.some((test) => test(glyphs))) add(\"positioning\", index, word);\n index += word.length;\n }\n }\n return risks.sort((a, b) => a.index - b.index);\n}\n","/**\n * The rules of one text engine for the widths of a font. The fields `deltas` and `metrics` are options of `readFont`, and\n * the fields `rounding` and `sum` are options of `measureWidth`. Thus a caller spreads the same row into the two calls.\n */\nexport interface EngineRules {\n /** The rounding of the `HVAR` and `gvar` deltas of an instance. */\n readonly deltas: \"round\" | \"exact\";\n /** The advance of a composite glyph: its own advance, or the advance of its component with the flag USE_MY_METRICS. */\n readonly metrics: \"own\" | \"component\";\n /** The rounding of each advance: `pixel` rounds it to whole px, and `exact` keeps the fraction. */\n readonly rounding: \"exact\" | \"pixel\";\n /**\n * The sum of the advances: `exact`, or `float32` as Blink adds the widths of the words of a canvas in single precision.\n * A sum of whole px is exact in single precision, so the rounding `pixel` needs no `float32` sum.\n */\n readonly sum: \"exact\" | \"float32\";\n}\n\n/**\n * The rules of the text engines of Chromium, one row for each engine. The fonts runs of typeset#27 measured each row\n * against the canvas, and the T1d diagnosis of the sum measured the field `sum`. A new engine is a new row.\n */\nexport const engines: { readonly freetype: EngineRules; readonly coretext: EngineRules; readonly directwrite: EngineRules } = {\n /** FreeType, as Chromium on Linux uses it: rounded deltas, and each advance in whole px. */\n freetype: { deltas: \"round\", metrics: \"own\", rounding: \"pixel\", sum: \"exact\" },\n /** CoreText on macOS: it keeps the fraction of the deltas. */\n coretext: { deltas: \"exact\", metrics: \"own\", rounding: \"exact\", sum: \"float32\" },\n /** DirectWrite on Windows: a composite glyph has the advance of its USE_MY_METRICS component. */\n directwrite: { deltas: \"round\", metrics: \"component\", rounding: \"exact\", sum: \"float32\" },\n};\n\n/** The name of a text engine of the table `engines`. */\nexport type EngineName = keyof typeof engines;\n\n/** This function tells if a text is the name of an engine of the table `engines`. */\nexport function isEngineName(name: string): name is EngineName {\n return Object.hasOwn(engines, name);\n}\n"],"mappings":";;;AAeA,MAAM,WAAW;AACjB,MAAM,aAAa,OAAO,GAAG;AAE7B,MAAM,YAAY,IAAI,OAAO,OAAO,GAAG,iDAAiD,WAAW,WAAW,WAAW,iFAAiF,IAAI;AAC9M,MAAM,gBAA4C;CAAC;CAAO;CAAa;CAAU;CAAQ;AAAoB;AAC7G,MAAM,WAAW;AACjB,MAAM,UAAU;;AAGhB,SAAgB,aAAa,MAAY,MAAc,UAA0B,CAAC,GAAkB;CAClG,MAAM,QAAuB,CAAC;CAC9B,MAAM,OAAO,MAAuB,OAAe,EAAE,aAA6B,MAAM,KAAK;EAAE;EAAM;EAAO;CAAO,CAAC;CACpH,MAAM,UAAU,cAA+B;EAC7C,MAAM,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EAAO,UAAU;EAAS,KAAK;CAAU;;CAE/E,aAAa;EAAE,QAAQ;EAAS,SAAS;EAAa,UAAU;EAAS,KAAK;CAAU;AAC1F;;AAMA,SAAgB,aAAa,MAAkC;CAC7D,OAAO,OAAO,OAAO,SAAS,IAAI;AACpC"}
@@ -150,6 +150,10 @@ interface Font {
150
150
  /** The source of the advances of this instance. The default instance and a font that is not variable use `hmtx`. */
151
151
  readonly advanceSource: AdvanceSource;
152
152
  readonly numGlyphs: number;
153
+ /** This value tells if the font has a GPOS table. */
154
+ readonly hasPositioning?: boolean;
155
+ /** This value tells if GDEF has glyph classes. */
156
+ readonly hasGlyphClasses?: boolean;
153
157
  /** This function gives the glyph of a code point, or 0 when the font has no glyph for it. */
154
158
  glyph(codePoint: number): number;
155
159
  /** This function gives the advance of a glyph in font units, as the shaper uses it. A mark has the advance 0. */
@@ -158,6 +162,8 @@ interface Font {
158
162
  glyphClass(glyph: number): number;
159
163
  /** This function gives the pair lookups of the kerning for an OpenType script tag, for example `latn`. */
160
164
  kerning(script: string): readonly PairLookup[];
165
+ /** This function gives a test for each lookup of `kern` and `dist` that the model does not apply. */
166
+ contextKerning?(script: string): readonly ((glyphs: readonly number[]) => boolean)[];
161
167
  /** This function gives the GSUB lookups of a list of feature tags for an OpenType script tag, in the order of the lookup list. */
162
168
  substitutions(script: string, features: readonly string[]): readonly SubstitutionLookup[];
163
169
  /** This function gives the same font at another instance. It uses the tables that are already read. */
@@ -1 +1 @@
1
- {"version":3,"file":"font.d.ts","names":[],"sources":["../../src/fonts/substitution.ts","../../src/fonts/variations.ts","../../src/fonts/kerning.ts","../../src/fonts/font.ts"],"mappings":";;;;;cAQa;;;;;UA6CI;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;WAES;;;UAIM;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;EAMT,MAAM,kBAAkB,kBAAkB;;;;;;EAM1C,WAAW,kBAAkB,OAAO,aAAa,cAAc;;;;;EAK/D,WAAW;;;;;;EAMX,4BAA4B;;;UC3Gb;WACN;WACA;WACA;WACA;;;KAIC,WAAW,SAAS;;UCLf;WACN;WACA;;WAEA;;WAEA;;WAEA;;;UAIM;WACN;;;;;WAKA,QAAQ;;EAEjB,KAAK,eAAe,iBAAiB;;;;;EAKrC,QAAQ,QAAQ,sBAAsB;;;UAIvB;WACN;WACA;;;UCvBM;;WAEN,aAAa;;;;;WAKb,WAAW;;;;;WAKX;;;;;WAKA;;;;;WAKA;;;KAIC;;UAGK;;;;;WAKN;WACA;;WAEA,eAAe;;WAEf,UAAU;;WAEV;;WAEA,eAAe;WACf;;EAET,MAAM;;EAEN,QAAQ;;EAER,WAAW;;EAEX,QAAQ,0BAA0B;;EAElC,cAAc,gBAAgB,uCAAuC;;EAErE,GAAG,UAAU,WAAW;;;iBAIV,SAAS,OAAO,YAAY,UAAS,cAAmB;;UA8JvD;;WAEN;;;;;WAKA;;WAEA;;;;;;WAMA;;;;;;WAMA;;;;;WAKA;;;;;WAKA;;;;;WAKA;;;;;;iBAYK,aAAa;;;;;;;iBAuEb,cAAc,MAAM,MAAM,cAAc,UAAS;EAAwB;EAAkB;;;;;;iBAkG3F,aAAa,MAAM,MAAM,cAAc,cAAc,UAAS"}
1
+ {"version":3,"file":"font.d.ts","names":[],"sources":["../../src/fonts/substitution.ts","../../src/fonts/variations.ts","../../src/fonts/kerning.ts","../../src/fonts/font.ts"],"mappings":";;;;;cAQa;;;;;UA6CI;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;WAES;;;UAIM;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;EAMT,MAAM,kBAAkB,kBAAkB;;;;;;EAM1C,WAAW,kBAAkB,OAAO,aAAa,cAAc;;;;;EAK/D,WAAW;;;;;;EAMX,4BAA4B;;;UC3Gb;WACN;WACA;WACA;WACA;;;KAIC,WAAW,SAAS;;UCLf;WACN;WACA;;WAEA;;WAEA;;WAEA;;;UAIM;WACN;;;;;WAKA,QAAQ;;EAEjB,KAAK,eAAe,iBAAiB;;;;;EAKrC,QAAQ,QAAQ,sBAAsB;;;UAIvB;WACN;WACA;;;UCtBM;;WAEN,aAAa;;;;;WAKb,WAAW;;;;;WAKX;;;;;WAKA;;;;;WAKA;;;KAIC;;UAGK;;;;;WAKN;WACA;;WAEA,eAAe;;WAEf,UAAU;;WAEV;;WAEA,eAAe;WACf;;WAEA;;WAEA;;EAET,MAAM;;EAEN,QAAQ;;EAER,WAAW;;EAEX,QAAQ,0BAA0B;;EAElC,gBAAgB,4BAA4B;;EAE5C,cAAc,gBAAgB,uCAAuC;;EAErE,GAAG,UAAU,WAAW;;;iBAIV,SAAS,OAAO,YAAY,UAAS,cAAmB;;UAuKvD;;WAEN;;;;;WAKA;;WAEA;;;;;;WAMA;;;;;;WAMA;;;;;WAKA;;;;;WAKA;;;;;WAKA;;;;;;iBAYK,aAAa;;;;;;;iBAwFb,cAAc,MAAM,MAAM,cAAc,UAAS;EAAwB;EAAkB;;;;;;iBAwG3F,aAAa,MAAM,MAAM,cAAc,cAAc,UAAS"}