import { Font, Fontkit, Glyph, TypeFeatures } from '../../types/fontkit.js'; import PDFHexString from '../objects/PDFHexString.js'; import PDFRef from '../objects/PDFRef.js'; import PDFContext from '../PDFContext.js'; import { Cache } from '../../utils/index.js'; /** * Parses font bytes once per fontkit and byte range, and returns a new view of the parsed font on * every call. Views share the directory and decoded tables (as fontkit's own `getVariation` does), * but each has its own glyphs, layout engine and cmap processor: a glyph keeps the code points it * was first created for, which go into the ToUnicode map, so sharing glyphs would let one * document's text change another's, and keep every glyph ever created alive with the bytes. * Bytes are looked up by their ArrayBuffer and range (embedFont wraps an ArrayBuffer in a new * Uint8Array on every call), and reparsed if their leading bytes changed since. * * @internal Exported so that @pdfme/schemas measures text with the same parse that embedding * uses; not meant to be called by applications. */ export declare const parseFont: (fontkit: Fontkit, fontData: Uint8Array) => Font; /** * A note of thanks to the developers of https://github.com/foliojs/pdfkit, as * this class borrows from: * https://github.com/devongovett/pdfkit/blob/e71edab0dd4657b5a767804ba86c94c58d01fbca/lib/image/jpeg.coffee */ declare class CustomFontEmbedder { static for(fontkit: Fontkit, fontData: Uint8Array, customName?: string, fontFeatures?: TypeFeatures): Promise; readonly font: Font; readonly scale: number; readonly fontData: Uint8Array; readonly fontName: string; readonly customName: string | undefined; readonly fontFeatures: TypeFeatures | undefined; protected baseFontName: string; protected glyphCache: Cache; private readonly shapedGlyphsById; protected constructor(font: Font, fontData: Uint8Array, customName?: string, fontFeatures?: TypeFeatures); /** * Encode the JavaScript string into this font. (JavaScript encodes strings in * Unicode, but embedded fonts use their own custom encodings) */ encodeText(text: string): PDFHexString; widthOfTextAtSize(text: string, size: number): number; /** * Layout `text` as one or more fontkit runs. Thai/Lao spans are shaped * separately so GSUB mark variants are selected even when Latin/CJK leads. * A script tag is never passed — each run has one strong script, so fontkit * auto-detection matches the script we would have specified. */ protected layoutGlyphs(text: string): Glyph[]; /** * GSUB can emit glyphs that are not in `font.characterSet` (e.g. Sarabun * tone gid 736). Retain those objects so `computeWidths()` and * `embedUnicodeCmap()` include them when the full font is embedded. */ protected registerShapedGlyphs(glyphs: Glyph[]): void; heightOfFontAtSize(size: number, options?: { descender?: boolean; }): number; sizeOfFontAtHeight(height: number): number; embedIntoContext(context: PDFContext, ref?: PDFRef): Promise; protected embedFontDict(context: PDFContext, ref?: PDFRef): Promise; protected isCFF(): boolean; protected embedCIDFontDict(context: PDFContext): Promise; protected embedFontDescriptor(context: PDFContext): Promise; protected serializeFont(): Promise; protected embedFontStream(context: PDFContext): Promise; protected embedUnicodeCmap(context: PDFContext): PDFRef; protected glyphId(glyph?: Glyph): number; protected computeWidths(): (number | number[])[]; private allGlyphsInFontSortedById; } export default CustomFontEmbedder;