
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@nowline/export-core
Advanced tools
Shared building blocks for Nowline's exporters — fonts, units, page sizes, and common types.
Shared types, helpers, and font infrastructure used by every Nowline export package. Intentionally small: zero heavy dependencies, browser-safe types, and a single Node-only side (the platform font probe) that's lazy-loaded.
License: Apache 2.0
Part of: lolay/nowline monorepo
Spec: specs/handoffs/m2c.md § 1, § 10
pnpm add @nowline/export-core
@nowline/export-core is a peer of every @nowline/export-* package —
install it once and the format packages will use the same types and font
resolution as the CLI.
ExportInputs — the bundle every format exporter consumes: parsed AST,
resolved-include result, positioned model, source path, and today. This
is the single shape cli/src/commands/render.ts builds once and hands to
each export*() function.PdfPageSize, PdfPresetName, PdfOrientation, PdfLength,
PdfLengthUnit — used by both @nowline/export-pdf and the CLI argument
parser.FontSource, FontRole, ResolvedFont, ResolvedFontPair — see
Font resolution below.import { parseLength, lengthToPoints } from '@nowline/export-core';
parseLength('0.5in'); // { value: 0.5, unit: 'in' }
lengthToPoints({ value: 0.5, unit: 'in' }); // 36
lengthToPoints({ value: 12, unit: 'pt' }); // 12
Supported units: pt, in, mm, cm. Bare numbers parse as points.
import { parsePageSize, resolvePage, fitContent } from '@nowline/export-core';
parsePageSize('letter'); // { kind: 'preset', name: 'letter' }
parsePageSize('8.5x11in'); // { kind: 'custom', wPt: 612, hPt: 792 }
parsePageSize('content'); // { kind: 'content' }
const page = resolvePage(pageSize, orientation, marginPt, contentBox);
const scale = fitContent(page, contentBox);
resolvePage() flips dimensions when orientation: 'auto' chooses
landscape over portrait based on the model's aspect ratio. fitContent()
returns the scale factor that fits the content inside (page − 2 × margin) without exceeding 1:1 (a small roadmap doesn't bloat to fill the
page).
resolveFonts() is the single entry point for picking a sans/mono pair for
a render. The five-step precedence chain is documented in
specs/handoffs/m2c.md § 10:
fontSans: '/path/to/Foo.ttf' (or alias 'sf',
'helvetica', 'dejavu').NOWLINE_FONT_SANS, NOWLINE_FONT_MONO.headless: true skips the platform probe and uses the
bundled DejaVu pair. Also automatically selected when running inside a
container with no fontconfig.import { resolveFonts } from '@nowline/export-core';
const result = await resolveFonts({
fontSans: undefined, // null/undefined = use precedence chain
fontMono: undefined,
headless: false,
});
result.sans; // { source: 'probe', name: 'SF Pro', bytes: Uint8Array(...) }
result.mono; // { source: 'probe', name: 'SF Mono', bytes: Uint8Array(...) }
result.sansFellBackToBundled; // boolean — true if step 5 fired
result.monoFellBackToBundled;
Variable fonts (e.g., SF Pro on macOS Ventura+) are detected by inspecting
the OpenType fvar table and instanced at wght: 400 to produce
deterministic, single-instance bytes — fontkit is not a runtime
dependency.
DejaVu Sans (assets/fonts/DejaVuSans.ttf) and DejaVu Sans Mono
(assets/fonts/DejaVuSansMono.ttf) ship with this package. They're used as
the always-available fallback in step 5 of the resolver.
The DejaVu license (Bitstream Vera + public-domain additions) is
assets/fonts/LICENSE-DejaVu.txt. It is MIT-compatible; redistribution is
permitted with notice retained in the package files. SF Pro / SF Mono are
not shipped — they're picked up at render time on macOS only and embedded
into the output (PDF subset, PNG raster). See
specs/handoffs/m2c.md § 10 for the full font licensing notes.
Every helper in this package is deterministic given identical inputs:
parsePageSize, parseLength, resolvePage, fitContent, validateMargin
are pure functions of their arguments.resolveFonts returns byte-identical font bytes across calls (variable
fonts are instanced before being returned).clearBundledCache() resets
it for tests.Apache-2.0. Shipped with bundled DejaVu fonts (Bitstream Vera license,
assets/fonts/LICENSE-DejaVu.txt).
FAQs
Shared building blocks for Nowline's exporters — fonts, units, page sizes, and common types.
The npm package @nowline/export-core receives a total of 27 weekly downloads. As such, @nowline/export-core popularity was classified as not popular.
We found that @nowline/export-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.