reamkit 1.33.2 → 1.34.1

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 (71) hide show
  1. package/README.md +13 -10
  2. package/dist/esm/core/converter/facade.js +1 -0
  3. package/dist/esm/core/converter/ream.d.ts +6 -6
  4. package/dist/esm/core/converter/ream.js +11 -5
  5. package/dist/esm/core/document-model/index.d.ts +1 -1
  6. package/dist/esm/core/document-model/types.d.ts +15 -0
  7. package/dist/esm/core/drawingml/text-warp.d.ts +34 -0
  8. package/dist/esm/core/drawingml/text-warp.js +49 -1
  9. package/dist/esm/core/font/index.d.ts +1 -1
  10. package/dist/esm/core/font/index.js +8 -0
  11. package/dist/esm/core/font/indic-shaper.d.ts +47 -0
  12. package/dist/esm/core/font/indic-shaper.js +1146 -0
  13. package/dist/esm/core/font/indic-table.d.ts +12 -0
  14. package/dist/esm/core/font/indic-table.js +463 -0
  15. package/dist/esm/core/font/measure.d.ts +45 -4
  16. package/dist/esm/core/font/measure.js +253 -14
  17. package/dist/esm/core/font/opentype-lookups.d.ts +214 -0
  18. package/dist/esm/core/font/opentype-lookups.js +1112 -0
  19. package/dist/esm/core/fonts/families.d.ts +4 -0
  20. package/dist/esm/core/fonts/families.js +43 -12
  21. package/dist/esm/core/fonts/provider.js +1 -0
  22. package/dist/esm/core/fonts/remote-fonts.d.ts +4 -2
  23. package/dist/esm/core/fonts/remote-fonts.js +36 -0
  24. package/dist/esm/core/fonts/scripts.d.ts +19 -0
  25. package/dist/esm/core/fonts/scripts.js +96 -1
  26. package/dist/esm/core/numbering/apply.js +12 -8
  27. package/dist/esm/core/style-cascade/index.d.ts +1 -1
  28. package/dist/esm/core/style-cascade/index.js +2 -2
  29. package/dist/esm/core/style-cascade/resolver.d.ts +9 -0
  30. package/dist/esm/core/style-cascade/resolver.js +31 -3
  31. package/dist/esm/core/style-cascade/table.js +3 -8
  32. package/dist/esm/excel/xlsx-to-pdf.js +1 -0
  33. package/dist/esm/index.js +1 -0
  34. package/dist/esm/layout/line-paint.d.ts +5 -4
  35. package/dist/esm/layout/line-paint.js +6 -5
  36. package/dist/esm/layout/page-doc.d.ts +26 -0
  37. package/dist/esm/layout/styled-layout.d.ts +8 -1
  38. package/dist/esm/layout/styled-layout.js +459 -112
  39. package/dist/esm/layout/undrawn.d.ts +18 -0
  40. package/dist/esm/layout/undrawn.js +59 -0
  41. package/dist/esm/pdf/cid-font.d.ts +5 -0
  42. package/dist/esm/pdf/cid-font.js +8 -2
  43. package/dist/esm/pdf/styled-page-emitter.js +117 -28
  44. package/dist/esm/pdf/text-page-renderer.js +1 -0
  45. package/dist/esm/pdf-reader/content.d.ts +1 -1
  46. package/dist/esm/pdf-reader/content.js +48 -13
  47. package/dist/esm/pdf-reader/embedded-fonts.js +1 -0
  48. package/dist/esm/pdf-reader/encodings.d.ts +9 -0
  49. package/dist/esm/pdf-reader/encodings.js +66 -1
  50. package/dist/esm/pdf-reader/face-outlines.js +1 -0
  51. package/dist/esm/pdf-reader/text.d.ts +10 -0
  52. package/dist/esm/pdf-reader/text.js +25 -3
  53. package/dist/esm/pdf-reader/vector.js +2 -2
  54. package/dist/esm/pptx/embedded-fonts.js +1 -0
  55. package/dist/esm/pptx/sp-helpers.js +4 -1
  56. package/dist/esm/svg/svg-text.js +30 -7
  57. package/dist/esm/word/doc/doc-reader.js +148 -57
  58. package/dist/esm/word/doc/doc-text.d.ts +80 -11
  59. package/dist/esm/word/doc/doc-text.js +438 -75
  60. package/dist/esm/word/document-parser.js +48 -28
  61. package/dist/esm/word/docx-to-pdf.d.ts +5 -5
  62. package/dist/esm/word/docx-to-pdf.js +9 -7
  63. package/dist/esm/word/docx-writer.js +3 -5
  64. package/dist/esm/word/font-embed.js +1 -0
  65. package/dist/esm/word/font-table.js +1 -0
  66. package/dist/esm/word/numbering-parser.js +3 -0
  67. package/dist/esm/word/paragraph-properties.js +2 -2
  68. package/dist/esm/word/run-properties.js +2 -2
  69. package/dist/esm/word/xml-helpers.d.ts +18 -0
  70. package/dist/esm/word/xml-helpers.js +48 -1
  71. package/package.json +7 -2
package/README.md CHANGED
@@ -31,8 +31,8 @@ format is sniffed from the bytes; no fonts to wire up — an open
31
31
  metric-compatible substitute font (Arimo for sans, Tinos for serif, Cousine for
32
32
  monospace, plus Carlito/Caladea for Calibri/Cambria — the same families LibreOffice
33
33
  substitutes) is fetched automatically based on the document's referenced fonts,
34
- with a Noto face for the Japanese, Korean, Chinese, Arabic, Hebrew or Thai text
35
- the document holds:
34
+ with a Noto face for the Japanese, Korean, Chinese, Arabic, Hebrew, Thai or
35
+ Indic (Hindi, Bengali, Tamil and six more scripts) text the document holds:
36
36
 
37
37
  ```ts
38
38
  import { Ream } from 'reamkit';
@@ -196,11 +196,12 @@ bars, icon sets, and `expression` rules evaluated by a ~140-function formula
196
196
  engine), **sparklines** and **Excel tables**, DrawingML shapes and
197
197
  charts, OMML math, Type0+CIDFontType2 embedding with subsetting, Knuth-Plass
198
198
  line breaking, Liang hyphenation, OpenType ligatures/kerning + Arabic cursive
199
- joining, BiDi (UAX #9), hyperlinks (PDF link annotations + HTML anchors,
200
- scheme-allowlisted), tagged PDF, PDF/A-1/2/3 (a/b/u), PDF/UA-1, AES-256
201
- encryption, digital signatures (PKCS#7/ECDSA/PAdES/RFC 3161), SVG page
202
- preview, flowed HTML export, and **docx + xlsx output** (write WordprocessingML
203
- / SpreadsheetML back out, incl. round-trips). Reads OOXML Transitional and Strict.
199
+ joining + Indic shaping (GSUB/GPOS, as HarfBuzz shapes), BiDi (UAX #9),
200
+ hyperlinks (PDF link annotations + HTML anchors, scheme-allowlisted), tagged
201
+ PDF, PDF/A-1/2/3 (a/b/u), PDF/UA-1, AES-256 encryption, digital signatures
202
+ (PKCS#7/ECDSA/PAdES/RFC 3161), SVG page preview, flowed HTML export, and
203
+ **docx + xlsx output** (write WordprocessingML / SpreadsheetML back out, incl.
204
+ round-trips). Reads OOXML Transitional and Strict.
204
205
 
205
206
  A Word document is laid out by Word's own rules, each measured in Word: a line
206
207
  as tall as Word sets its faces, two paragraphs standing the larger of their
@@ -274,9 +275,11 @@ hyperlinks — then converts onward to PDF, SVG, HTML, Markdown or DOCX like any
274
275
 
275
276
  **Reads legacy `.doc`, `.xls` and `.ppt`, too.** The binary Word / Excel /
276
277
  PowerPoint 97–2003 formats (OLE2/CFB) parse through a shared container reader: a
277
- `.doc` yields its text with run and paragraph formatting, tables (with cell
278
- borders, vertical merges and background shading), inline images, fields,
279
- headers/footers and lists (numbered or bulleted, in their number format);
278
+ `.doc` yields its text with run and paragraph formatting (through its style sheet
279
+ and font table), page, column and line breaks, sections with their own page
280
+ size, margins and headers/footers, page numbers, tables (with cell
281
+ borders, vertical merges and background shading), inline images, fields
282
+ and lists (numbered or bulleted, in their number format);
280
283
  an `.xls` yields the grid with styling, embedded
281
284
  images, charts, drawing shapes, cell hyperlinks, the page-setup print model,
282
285
  defined names (named ranges, print area, repeated titles), cell comments, data
@@ -1,5 +1,6 @@
1
1
  import { fetchFontSet } from "../fonts/remote-fonts.js";
2
2
  import { FontRegistry } from "../font/font-registry.js";
3
+ import "../font/index.js";
3
4
  import { FEATURES } from "../ir/features.js";
4
5
  import { ConversionLossError } from "../ir/loss.js";
5
6
  import { layoutStyledDocument } from "../../layout/styled-layout.js";
@@ -47,11 +47,11 @@ export interface ReamParseOptions {
47
47
  }
48
48
  /**
49
49
  * Options for {@link Ream.convert} and {@link Ream.convertWithReport}. Extends
50
- * the low-level {@link StyledRenderOptions} (minus the font `registry` and
51
- * `styles`, which Ream builds itself) with font resolution and source-touching
52
- * conveniences.
50
+ * the low-level {@link StyledRenderOptions} (minus the font `registry`, the
51
+ * `styles` and the `losses` sink, which Ream builds itself) with font
52
+ * resolution and source-touching conveniences.
53
53
  */
54
- export interface ReamConvertOptions extends Omit<StyledRenderOptions, 'registry' | 'styles'> {
54
+ export interface ReamConvertOptions extends Omit<StyledRenderOptions, 'registry' | 'styles' | 'losses'> {
55
55
  /** Explicit font bytes per variant (regular/bold/italic/bold-italic). */
56
56
  readonly fonts?: FontBytesByVariant;
57
57
  /** Shorthand for supplying a single regular-variant font as raw bytes. */
@@ -197,8 +197,8 @@ export declare class Ream {
197
197
  private resolveFonts;
198
198
  /**
199
199
  * Fetch one face per writing system the document holds text in — the curated
200
- * families are Latin, and Han, Kana, Hangul, Arabic and the geometric symbols
201
- * are a notdef box in every one of them.
200
+ * families are Latin, and Han, Kana, Hangul, Arabic, the scripts of India and
201
+ * the geometric symbols are a notdef box in every one of them.
202
202
  *
203
203
  * Only the regular weight is fetched: Noto Sans SC is ten megabytes, and a
204
204
  * bold run in it is better stroked (see `SyntheticFace`) than downloaded four
@@ -2,6 +2,7 @@ import { fetchFontSet, fetchScriptFont, resolveFamilyKey } from "../fonts/remote
2
2
  import { scriptsInFlow } from "../fonts/scripts.js";
3
3
  import { FontRegistry } from "../font/font-registry.js";
4
4
  import { createFontMeasure } from "../font/measure.js";
5
+ import "../font/index.js";
5
6
  import { ConversionLossError } from "../ir/loss.js";
6
7
  import { layoutStyledDocument } from "../../layout/styled-layout.js";
7
8
  import { signPdf } from "../../pdf/signature.js";
@@ -218,10 +219,14 @@ var Ream = class Ream {
218
219
  registry,
219
220
  ...registriesByFamily ? { registriesByFamily } : {}
220
221
  };
221
- const laid = this.sheet ? layoutSheetImages(this.sheet, faces, sheetOptions, renderOptions) : layoutStyledDocument(flow.body, {
222
+ const laid = this.sheet ? layoutSheetImages(this.sheet, faces, sheetOptions, {
223
+ ...renderOptions,
224
+ losses
225
+ }) : layoutStyledDocument(flow.body, {
222
226
  ...faces,
223
227
  ...flowRenderOptions(flow),
224
- ...renderOptions
228
+ ...renderOptions,
229
+ losses
225
230
  });
226
231
  const svg = writeSvg(laid);
227
232
  losses.push(...svg.losses);
@@ -251,7 +256,8 @@ var Ream = class Ream {
251
256
  ...info ? { info } : {},
252
257
  ...attachments.length > 0 ? { attachments } : {},
253
258
  ...signature ? { signaturePlaceholder: signature } : {},
254
- ...renderOptions
259
+ ...renderOptions,
260
+ losses
255
261
  };
256
262
  let pdf = styled.encrypt ? await renderStyledPdfEncrypted(paginated.body, styled) : renderStyledPdf(paginated.body, styled);
257
263
  if (signature) pdf = await signPdf(pdf, signature);
@@ -306,8 +312,8 @@ var Ream = class Ream {
306
312
  }
307
313
  /**
308
314
  * Fetch one face per writing system the document holds text in — the curated
309
- * families are Latin, and Han, Kana, Hangul, Arabic and the geometric symbols
310
- * are a notdef box in every one of them.
315
+ * families are Latin, and Han, Kana, Hangul, Arabic, the scripts of India and
316
+ * the geometric symbols are a notdef box in every one of them.
311
317
  *
312
318
  * Only the regular weight is fetched: Noto Sans SC is ten megabytes, and a
313
319
  * bold run in it is better stroked (see `SyntheticFace`) than downloaded four
@@ -5,4 +5,4 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
- export type { AbstractNumbering, Alignment, Border, BorderStyle, BodyElement, Comment, CellBorders, CellMerge, DocumentInfo, CellMargins, CellProperties, CellShading, CellDataBar, CellIcon, CellNoteFlag, CellIconShape, CellSparkline, Chart, ChartBlock, ChartDataLabels, ChartDataPoint, ChartLabelPosition, ChartLineStyle, ChartMarker, ChartMarkerSymbol, ChartSeries, ChartSurface, ChartTextStyle, ChartTextStyles, ChartType, CustomGeometry, CustomPathCmd, DocumentModel, FontFamilyMap, HeaderFooterReference, HeaderFooterType, ImageBlock, ImageCrop, InlineImage, MathAccent, MathBar, MathDelimiter, MathEqArray, MathFraction, MathFunc, MathGroupChr, MathLimit, MathMatrix, MathNary, MathNode, MathRadical, MathRow, MathRun, MathScript, Numbering, NumberingFormat, NumberingInstance, NumberingLevel, PictureBullet, PictureOutline, NumberingReference, PageMargins, PageSize, Paragraph, ParagraphProperties, FrameProperties, RelativeSize, TabStop, Run, RunProperties, TextOutline, Ligatures, RowConditionalFormat, RowProperties, Section, FloatAnchor, SectionColumns, SectionProperties, ShapeBlock, ShapeShadow, ShapeDash, ShapeFill, ShapeFillKind, ShapeGeometry, ShapeGroupChild, ShapeLine, LineEnd, ShapeTextBody, ShapeTransform, Style, StyleSheet, StyleType, Table, TableCell, TableLook, TableOverlay, TableProperties, TableStyleCondition, TableStyleConditionType, TableStyleLayer, TableRow, UnderlineStyle, VerticalAlign, } from './types.js';
8
+ export type { AbstractNumbering, Alignment, Border, BorderStyle, BodyElement, Comment, CellBorders, CellMerge, DocumentInfo, CellMargins, CellProperties, CellShading, CellDataBar, CellIcon, CellNoteFlag, CellIconShape, CellSparkline, Chart, ChartBlock, ChartDataLabels, ChartDataPoint, ChartLabelPosition, ChartLineStyle, ChartMarker, ChartMarkerSymbol, ChartSeries, ChartSurface, ChartTextStyle, ChartTextStyles, ChartType, CustomGeometry, CustomPathCmd, DocumentModel, FontFamilyMap, HeaderFooterReference, HeaderFooterType, ImageBlock, ImageCrop, InlineImage, MathAccent, MathBar, MathDelimiter, MathEqArray, MathFraction, MathFunc, MathGroupChr, MathLimit, MathMatrix, MathNary, MathNode, MathRadical, MathRow, MathRun, MathScript, Numbering, NumberingFormat, NumberingInstance, NumberingLevel, NumberingSuffix, PictureBullet, PictureOutline, NumberingReference, PageMargins, PageSize, Paragraph, ParagraphProperties, FrameProperties, RelativeSize, TabStop, Run, RunProperties, TextOutline, Ligatures, RowConditionalFormat, RowProperties, Section, FloatAnchor, SectionColumns, SectionProperties, ShapeBlock, ShapeShadow, ShapeDash, ShapeFill, ShapeFillKind, ShapeGeometry, ShapeGroupChild, ShapeLine, LineEnd, ShapeTextBody, ShapeTransform, Style, StyleSheet, StyleType, Table, TableCell, TableLook, TableOverlay, TableProperties, TableStyleCondition, TableStyleConditionType, TableStyleLayer, TableRow, UnderlineStyle, VerticalAlign, } from './types.js';
@@ -495,6 +495,13 @@ export interface Run {
495
495
  * `"•"`). Tagged PDF wraps its glyphs in a Lbl structure element (§14.8.4.3.3).
496
496
  */
497
497
  readonly listMarker?: true;
498
+ /**
499
+ * §17.9.29 `w:suff="space"` — the run (a `listMarker` one, its text a single
500
+ * space) is the space a list level puts after its marker. Word sets it at a
501
+ * fixed width for the marker's size, whatever the marker's face, and never
502
+ * stretches it in a justified line.
503
+ */
504
+ readonly listMarkerSpace?: true;
498
505
  /** When set, the run renders this image inline in the line; `text` is ignored. */
499
506
  readonly inlineImage?: InlineImage;
500
507
  /** When set, the run is an inline OfficeMath object; `text` is ignored. */
@@ -589,9 +596,17 @@ export interface NumberingLevel {
589
596
  * numbering: "Sect I.01" becomes "Sect 1.01".
590
597
  */
591
598
  readonly isLegal?: boolean;
599
+ /**
600
+ * §17.9.29 `w:suff` — what separates the marker from the paragraph's text:
601
+ * a tab (the default, and what an absent value means), one space, or
602
+ * nothing at all.
603
+ */
604
+ readonly suffix?: NumberingSuffix;
592
605
  readonly paragraphProperties: ParagraphProperties;
593
606
  readonly runProperties: RunProperties;
594
607
  }
608
+ /** §17.18.53 `ST_LevelSuffix` — the character between a list marker and its text. */
609
+ export type NumberingSuffix = 'tab' | 'space' | 'nothing';
595
610
  /** §17.9.21 `w:numPicBullet` — the image a level uses in place of a bullet. */
596
611
  export interface PictureBullet {
597
612
  /** Content-addressed bytes. A bullet whose picture does not resolve is not one. */
@@ -46,6 +46,40 @@ export interface WarpFrame {
46
46
  * draw — the pinched end of a fade, or a preset this file cannot bend.
47
47
  */
48
48
  export declare function warpGlyphMatrix(frame: WarpFrame, glyphX: number, advance: number, baselineY: number): readonly [number, number, number, number, number, number] | undefined;
49
+ /** One glyph of a shaped run, set on a warp's curve: its id and its {@link warpGlyphMatrix}. */
50
+ export interface WarpedGlyph {
51
+ readonly gid: number;
52
+ /** Where the glyph stands in the run it came from. */
53
+ readonly index: number;
54
+ readonly matrix: readonly [number, number, number, number, number, number];
55
+ }
56
+ /**
57
+ * The glyphs of a run the Indic shaper set, each placed on the warp's curve.
58
+ *
59
+ * Such a run cannot be set character by character the way other text on a
60
+ * curve is: its glyphs stand in an order of their own (the short i of हि
61
+ * before the ha), one glyph may stand for several characters, and a mark is
62
+ * set off its pen position by the face's anchors. So the curve takes the
63
+ * shaper's glyphs. Each advances by its shaped advance, the run rescaled to
64
+ * the width the layout measured it at. A glyph's x offset moves it along the
65
+ * line before the warp maps it, and its y offset lifts it off the baseline in
66
+ * its own frame, so a mark rises and leans with the letter it sits on.
67
+ *
68
+ * @param frame The two frames, from the laid-out line.
69
+ * @param run The run's glyphs, advances and offsets, in font units.
70
+ * @param x Where the run starts in the un-warped block.
71
+ * @param widthPt The width the layout measured the run at.
72
+ * @param emPt Points per font unit at the run's size: the size over the em.
73
+ * @param baselineY The line's baseline in the un-warped block.
74
+ * @returns Each glyph and its matrix, in the shaper's order; a glyph the warp
75
+ * leaves no room for is left out.
76
+ */
77
+ export declare function warpGlyphRun(frame: WarpFrame, run: {
78
+ readonly gids: ReadonlyArray<number>;
79
+ readonly advances: ReadonlyArray<number>;
80
+ readonly xOffsets?: ReadonlyArray<number>;
81
+ readonly yOffsets?: ReadonlyArray<number>;
82
+ }, x: number, widthPt: number, emPt: number, baselineY: number): Array<WarpedGlyph>;
49
83
  /**
50
84
  * The two edges of a warp at one position across its box.
51
85
  *
@@ -252,6 +252,54 @@ function warpGlyphMatrix(frame, glyphX, advance, baselineY) {
252
252
  if (ring) return ringMatrix(frame, ring, u, v, glyphX);
253
253
  return envelopeMatrix(frame, u, v, glyphX, advance);
254
254
  }
255
+ /**
256
+ * The glyphs of a run the Indic shaper set, each placed on the warp's curve.
257
+ *
258
+ * Such a run cannot be set character by character the way other text on a
259
+ * curve is: its glyphs stand in an order of their own (the short i of हि
260
+ * before the ha), one glyph may stand for several characters, and a mark is
261
+ * set off its pen position by the face's anchors. So the curve takes the
262
+ * shaper's glyphs. Each advances by its shaped advance, the run rescaled to
263
+ * the width the layout measured it at. A glyph's x offset moves it along the
264
+ * line before the warp maps it, and its y offset lifts it off the baseline in
265
+ * its own frame, so a mark rises and leans with the letter it sits on.
266
+ *
267
+ * @param frame The two frames, from the laid-out line.
268
+ * @param run The run's glyphs, advances and offsets, in font units.
269
+ * @param x Where the run starts in the un-warped block.
270
+ * @param widthPt The width the layout measured the run at.
271
+ * @param emPt Points per font unit at the run's size: the size over the em.
272
+ * @param baselineY The line's baseline in the un-warped block.
273
+ * @returns Each glyph and its matrix, in the shaper's order; a glyph the warp
274
+ * leaves no room for is left out.
275
+ */
276
+ function warpGlyphRun(frame, run, x, widthPt, emPt, baselineY) {
277
+ let total = 0;
278
+ for (const a of run.advances) total += a;
279
+ const along = total > 0 ? widthPt / total : emPt;
280
+ const out = [];
281
+ let pen = x;
282
+ for (let i = 0; i < run.gids.length; i++) {
283
+ const adv = (run.advances[i] ?? 0) * along;
284
+ const m = warpGlyphMatrix(frame, pen + (run.xOffsets?.[i] ?? 0) * along, adv, baselineY);
285
+ pen += adv;
286
+ if (!m) continue;
287
+ const dy = (run.yOffsets?.[i] ?? 0) * emPt;
288
+ out.push({
289
+ gid: run.gids[i],
290
+ index: i,
291
+ matrix: [
292
+ m[0],
293
+ m[1],
294
+ m[2],
295
+ m[3],
296
+ m[4] + m[2] * dy,
297
+ m[5] + m[3] * dy
298
+ ]
299
+ });
300
+ }
301
+ return out;
302
+ }
255
303
  /** The glyph matrix for a warp that hangs text between a top and a bottom edge. */
256
304
  function envelopeMatrix(frame, u, v, glyphX, advance) {
257
305
  const edges = textWarpEdges(frame.preset, u, frame.adjust);
@@ -340,4 +388,4 @@ function textWarpEdges(preset, u, adj) {
340
388
  return env.at(Math.min(1, Math.max(0, u)), a);
341
389
  }
342
390
  //#endregion
343
- export { isTextWarp, textWarpEdges, warpGlyphMatrix };
391
+ export { isTextWarp, textWarpEdges, warpGlyphMatrix, warpGlyphRun };
@@ -7,7 +7,7 @@ export { pickVariant } from './font-registry.js';
7
7
  export { parseGposKerning, parseGsubLigatures, shapeText } from './opentype-layout.js';
8
8
  export type { KerningMap, LigatureMap, ShapedRun } from './opentype-layout.js';
9
9
  export { hasSubstitutable, lettersForLigature, substituteLetters } from './ligatures.js';
10
- export { createFontMeasure } from './measure.js';
10
+ export { createFontMeasure, shapeGlyphs } from './measure.js';
11
11
  export type { FontMeasure } from './measure.js';
12
12
  export { buildTrueType, editableEmbedding, MAX_BUILT_GLYPHS } from './ttf-build.js';
13
13
  export type { BuiltFace, BuiltGlyph, BuiltKernPair, BuiltLigature, GlyphSeg, } from './ttf-build.js';
@@ -0,0 +1,8 @@
1
+ import "./opentype-layout.js";
2
+ import { parseTtf } from "./ttf-parser.js";
3
+ import { glyphClosure, subsetTtf } from "./ttf-subset.js";
4
+ import { FontRegistry, pickVariant } from "./font-registry.js";
5
+ import { hasSubstitutable, lettersForLigature, substituteLetters } from "./ligatures.js";
6
+ import { createFontMeasure, shapeGlyphs } from "./measure.js";
7
+ import { MAX_BUILT_GLYPHS, buildTrueType, editableEmbedding } from "./ttf-build.js";
8
+ export { FontRegistry, MAX_BUILT_GLYPHS, buildTrueType, createFontMeasure, editableEmbedding, glyphClosure, hasSubstitutable, lettersForLigature, parseTtf, pickVariant, shapeGlyphs, subsetTtf, substituteLetters };
@@ -0,0 +1,47 @@
1
+ import { ParsedTtf } from './ttf-parser.js';
2
+ /**
3
+ * Whether a string holds a letter of one of the scripts this shapes.
4
+ *
5
+ * @param text The text.
6
+ * @returns `true` when one of its characters is in their blocks.
7
+ */
8
+ export declare function hasIndic(text: string): boolean;
9
+ /**
10
+ * Where the syllables of the scripts of India begin in a text, by the grammar
11
+ * the shaper cuts them with: a syllable is the unit a reph, a conjunct or a
12
+ * vowel sign is shaped within, and shaped in two halves it falls apart.
13
+ *
14
+ * @param text The text.
15
+ * @returns Per code point: whether a syllable — or anything that is not one —
16
+ * begins at it.
17
+ */
18
+ export declare function syllableStarts(text: string): Array<boolean>;
19
+ /** The glyphs of a shaped run, in drawing order, with where each is drawn. */
20
+ export interface IndicRun {
21
+ readonly gids: Array<number>;
22
+ /** Per glyph: the index, in code points, of the first character of its cluster. */
23
+ readonly clusters: Array<number>;
24
+ /**
25
+ * Per glyph: the indices, in code points, of the characters it stands for,
26
+ * least first. A conjunct stands for its letters and viramas, a reph for its
27
+ * Ra and virama, each part of a vowel sign drawn in two for the sign, and a
28
+ * dotted circle the shaper put in for nothing.
29
+ */
30
+ readonly sources: Array<ReadonlyArray<number>>;
31
+ /** Per glyph, in font units. */
32
+ readonly advances: Array<number>;
33
+ readonly xOffsets: Array<number>;
34
+ readonly yOffsets: Array<number>;
35
+ }
36
+ /**
37
+ * Shape a run of text in one face, when the face has OpenType layout for the
38
+ * script of India its text is in.
39
+ *
40
+ * @param parsed The face.
41
+ * @param text The text.
42
+ * @param kern Whether to apply the face's `kern` feature (the layout profile decides).
43
+ * @returns The shaped glyphs, or `undefined` when the text holds no letter of
44
+ * those scripts or the face has no layout for them — the caller's
45
+ * own shaping applies then.
46
+ */
47
+ export declare function shapeIndic(parsed: ParsedTtf, text: string, kern?: boolean): IndicRun | undefined;