/reamkit:supply-fontsfrom reamkit
Configures font sources for Ream PDF/SVG conversions when offline, air-gapped, or using custom typefaces. Diagnoses missing glyphs and failed font downloads.
Ships in reamkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Only convert('pdf') and convert('svg') lay out pages, and only they need
font bytes. HTML, Markdown, DOCX and XLSX never load a font; if the output can
be one of those, no font setup is needed.
With none of fonts, fontBytes or fontProviders passed:
.docx w:embed font, a deck's embedded
font, a PDF's own font programs) is used for its own runs, by exact name.Steps 2 and 3 download .ttf files from
https://cdn.jsdelivr.net/npm/@expo-google-fonts/… with the global fetch and
keep them in memory per URL for the life of the process. A download that fails
is not cached, so the next conversion tries again.
| Situation | Do this |
|---|---|
| Network allowed, no typeface requirement | Nothing: the default above |
| No network (or a CSP), but the automatic choice is wanted | fontFetch serving a mirror of the CDN files |
| All text must use your typeface | fonts: { regular, bold, italic, boldItalic } |
| A Chromium page; use the family where the user has it installed | fontProviders: [localFontProvider(), remoteFontProvider()] |
A browser page with connect-src restrictions | Allow https://cdn.jsdelivr.net, or fontFetch to your own origin |
fontFetch replaces fetch for every font download and keeps the per-family
and per-script selection. It receives the CDN URL and must resolve to an object
with ok and arrayBuffer(), which a Response already is.
Browser or edge, from a mirror on your own origin:
import { Ream } from 'reamkit';
const CDN = 'https://cdn.jsdelivr.net/npm/@expo-google-fonts/';
const pdf = await Ream.parse(bytes).convert('pdf', {
fontFetch: (url) => fetch(url.replace(CDN, '/fonts/expo-google-fonts/')),
});
Node.js with no network, from files on disk:
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { Ream, type FetchLike } from 'reamkit';
const CDN = 'https://cdn.jsdelivr.net/npm/@expo-google-fonts/';
const FONT_DIR = '/srv/fonts/expo-google-fonts';
const fontFetch: FetchLike = async (url) => {
try {
const file = await readFile(join(FONT_DIR, url.slice(CDN.length)));
const bytes = new Uint8Array(file); // a copy that owns its whole ArrayBuffer
return { ok: true, arrayBuffer: async () => bytes.buffer };
} catch {
return { ok: false, arrayBuffer: async () => new ArrayBuffer(0) };
}
};
const pdf = await Ream.parse(bytes).convert('pdf', { fontFetch });
To learn which files to mirror, run representative documents once with the
network on and a fontFetch that logs each url before calling fetch(url);
keep the same relative paths under the mirror. A missing regular face makes the
conversion reject; a missing bold or italic face or a missing script face does
not (see Common mistakes).
import { readFile } from 'node:fs/promises';
import { Ream } from 'reamkit';
const load = async (path: string) => new Uint8Array(await readFile(path));
const fonts = {
regular: await load('fonts/NotoSans-Regular.ttf'),
bold: await load('fonts/NotoSans-Bold.ttf'),
italic: await load('fonts/NotoSans-Italic.ttf'),
boldItalic: await load('fonts/NotoSans-BoldItalic.ttf'),
};
const pdf = await Ream.parse(bytes).convert('pdf', { fonts }); // zero network I/O
Every run is set in these faces whatever family it names; fonts the document
embeds still draw their own runs. Only regular is required: a missing variant
falls back to the nearest face given. fontBytes: regularTtf is shorthand for
fonts: { regular: regularTtf }. Pass TrueType bytes (.ttf); WOFF and WOFF2
containers are not unpacked.
In Chromium (Local Font Access), a provider chain draws each family the document names in the installed face of that name, and the rest in the automatic substitutes:
import { Ream, localFontProvider, remoteFontProvider } from 'reamkit';
const { bytes: pdf, losses } = await Ream.parse(bytes).convertWithReport('pdf', {
fontProviders: [localFontProvider(), remoteFontProvider()],
});
The chain is asked for the document's default faces, then once per family the
document names (and does not embed), then for the face of each writing system
its text holds; the first provider that answers a request wins it. Chromium asks
the user for permission to read local fonts; until it is granted, and where the
API is missing (Safari, Firefox, Node), every local request falls through to the
next provider, as does a family that is not installed. A face whose OS/2
fsType forbids embedding is never used.
remoteFontProvider({ fetch }) takes the same function as fontFetch. Each
face below your own records a substituted fonts.substitution loss naming
the family, the face and the provider:
Calibri rendered with Calibri (provider: local).
const { bytes: pdf, losses } = await Ream.parse(bytes).convertWithReport('pdf', { fonts });
const fontLosses = losses.filter(
(l) => l.feature === 'text' || l.feature === 'font' || l.feature === 'fonts.substitution',
);
dropped on text: characters no face on hand has a glyph for. They are
drawn as empty boxes and are missing from the PDF's text layer.substituted on font: a script face or a companion face could not be
downloaded; that text falls to another face, or to boxes.substituted on fonts.substitution: a fontProviders chain answered with a
remote or local face instead of yours, once for the default faces and once
per family (Times New Roman rendered with tinos (provider: remote)).fonts for a document in a script those fonts lackfonts and fontBytes replace the whole automatic selection, the per-script
Noto faces included, and so does a fontProviders chain that starts with
callerFontProvider. A Japanese, Arabic or Hindi paragraph rendered with a
Latin-only fonts set comes out as boxes, reported as a dropped text loss.
Pass fonts that cover the document's scripts, or use fontFetch to keep the
automatic per-script faces offline. Source: resolveFonts in
src/core/converter/ream.ts, src/layout/undrawn.ts.
A server, sandbox or function without network access rejects every PDF and SVG
conversion with Failed to download font from https://cdn.jsdelivr.net/… (the
network error is its cause). It works on a developer machine and fails in
production. Choose fonts or fontFetch before deploying. Source:
fetchTtf in src/core/fonts/remote-fonts.ts.
callerFontProvider before other providersfontProviders is asked per family the document names and per writing system,
and the first provider that answers a request wins it. callerFontProvider
answers every request with your bytes, so no provider after it is ever asked:
in [callerFontProvider(myFonts), localFontProvider(), remoteFontProvider()]
the installed faces and the substitutes are never used, and the document is
set in myFonts as fonts: myFonts would set it. Put it last:
import { Ream, callerFontProvider, localFontProvider } from 'reamkit';
const pdf = await Ream.parse(bytes).convert('pdf', {
// The installed face where the family is installed, your bytes for the rest.
fontProviders: [localFontProvider(), callerFontProvider({ regular: brandRegular })],
});
Source: resolveFacesViaChain in src/core/fonts/chain-faces.ts,
callerFontProvider in src/core/fonts/provider.ts.
Only the regular face of the main substitute family is required. A bold or
italic face that does not download is simply absent, and a script face that
does not download records a substituted font loss and leaves its text in
boxes. Read the losses, or use strict: true to turn them into a
ConversionLossError.
fontFetch that throws on
unexpected URLs) and confirm it resolves.losses contains no dropped text entry; if it does, its detail names
the code points (U+0928, …) and its where the page the first is on.localFontProvider, losses has a (provider: local) entry for each
installed family; none means the permission was not granted, the family is
not installed under that name, or a provider before it answered.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
ream, pdf-conversion, svg-conversion, font-management, offline-fonts
npx claudepluginhub alex-krassavin/reamkit --plugin reamkit4 skills in this plugin
/convert-documentsUse when converting Word, Excel, PowerPoint or PDF files (.docx, .xlsx, .pptx, .pdf and legacy .doc, .xls, .ppt) to PDF, SVG, HTML, Markdown, DOCX or XLSX with reamkit (Ream) in a browser, Node.js, serverless or edge runtime: reading the bytes, choosing a target, opening a password-protected file, reading a PDF back as an editable document, and checking what the conversion lost.
/documents-to-markdownUse when extracting the text of user-uploaded documents (Word, Excel, PowerPoint, PDF or legacy .doc, .xls, .ppt files) as Markdown with reamkit (Ream) for a language-model prompt, a chat attachment, retrieval/RAG or search indexing, or a docs site, including what to do with pictures, slides, sheets and scanned PDFs.
/pdf-complianceUse when producing archival PDF/A (1a/1b, 2a/2b/2u, 3a/3b/3u), accessible PDF/UA-1 or tagged PDF, digitally signed, password-encrypted or bookmarked PDF with reamkit (Ream), embedding the source file or other attachments, setting PDF metadata, or matching Word's or LibreOffice's pagination.
Other plugins' skills for the same job