> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ploterr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Paper styles

> The built-in drawing styles and the rules that select one.

A paper style sets how a drawing looks: line weights, colours, hatches and text. Floorkit has four built-in styles, and you can add your own. `resolvePaperStyle` changes a style id or a partial style into a full style.

## Import

```typescript theme={null}
import {
  resolvePaperStyle,
  mergeStyle,
  resolveSheetPolicy,
  resolveViewportPolicy,
  documentStyleOf,
  PAPER_STYLES,
  DEFAULT_PAPER_STYLE_ID,
  ISO_128,
  INK_SKETCH,
  GRAPHITE,
  NAPKIN,
} from '@opengeometry/floorkit';
```

## Example

```typescript theme={null}
import { resolvePaperStyle } from '@opengeometry/floorkit';

const resolved = resolvePaperStyle({ extends: 'ink-sketch', ink: '#183047' });
if (resolved) {
  console.log(resolved.style, resolved.unresolved);
}
const none = resolvePaperStyle(undefined); // undefined
```

## Notes

* The built-in styles are `ISO_128`, `INK_SKETCH`, `GRAPHITE` and `NAPKIN`.
* Your style replaces a built-in style that has the same id.
* An unknown id gives the default style, and the id appears in `unresolved`.
* With no input, the function returns `undefined`.

## resolvePaperStyle

Flatten a style input against a registry.

```typescript theme={null}
function resolvePaperStyle(
  input: PaperStyleInput | undefined,
  registry?: PaperStyleRegistry,
): ResolvedPaperStyle | undefined;
```

## mergeStyle

Merge one style over another, at the depth each field means: - `classes` / `edgeClasses`: key by key, then field by field on the class, then field by field on each `byKind` entry — so an overlay that says `&#123; classes: &#123; WALL: &#123; ink &#125; &#125; &#125;` keeps WALL's weight, fill and hatch.

```typescript theme={null}
function mergeStyle(base: PaperStyle, over: PaperStyle): PaperStyle;
```

## resolveSheetPolicy

The policy a sheet renders under: `deps.paperStyle` (caller) → the sheet → the document.

```typescript theme={null}
function resolveSheetPolicy(sheet: Sheet, deps: PaperRenderDeps): SheetPolicy | undefined;
```

## resolveViewportPolicy

The policy one viewport renders under.

```typescript theme={null}
function resolveViewportPolicy(
  sheet: Sheet,
  viewport: Viewport,
  deps: PaperRenderDeps,
  sheetPolicy: SheetPolicy | undefined,
): SheetPolicy | undefined;
```

## documentStyleOf

A document's style fields, for `PaperRenderDeps.documentStyle`.

```typescript theme={null}
function documentStyleOf(doc: DocumentStyleFields): DocumentStyleFields | undefined;
```

## PAPER\_STYLES

The presets that ship, keyed by id.

```typescript theme={null}
const PAPER_STYLES: Readonly<Record<BuiltinPaperStyleId, PaperStyle>>;
```

## DEFAULT\_PAPER\_STYLE\_ID

```typescript theme={null}
const DEFAULT_PAPER_STYLE_ID: BuiltinPaperStyleId;
```

## ISO\_128

```typescript theme={null}
const ISO_128: PaperStyle;
```

## INK\_SKETCH

Freehand ink — a drafted plan in technical pen on vellum, in the register Francis Ching teaches: a compressed four-rung hierarchy, warm near-black ink that lightens as the line thins, solid poché pulled a hair in from its line, crossed corners with a short placed start and a longer lifted finish, a second strike on the heavy lines, and upper-case lettering with a little tracking.

```typescript theme={null}
const INK_SKETCH: PaperStyle;
```

## GRAPHITE

Soft graphite on trace — a design-development plan in pencil on canary trace: every weight one rung heavier than ink (a pencil line is wider than a pen's), warm greys that lighten as the line thins, a light warm poché with one sparse pass of scrubbed hatch over it (a tone, not a material), wider re-strike offsets than ink, longer softer tapers, a re-struck door swing, and larger upper-case lettering.

```typescript theme={null}
const GRAPHITE: PaperStyle;
```

## NAPKIN

Napkin sketch — the parti drawing: a fineliner on a paper napkin, drawn fast.

```typescript theme={null}
const NAPKIN: PaperStyle;
```

## Types

### PaperStyleInput

```typescript theme={null}
type PaperStyleInput = PaperStyleId | PaperStyle;
```

### ResolvedPaperStyle

```typescript theme={null}
interface ResolvedPaperStyle {
  style: PaperStyle;
  unresolved: string[];
}
```

<ResponseField name="style" type="PaperStyle" required>
  Flattened: every `extends` walked and merged, no `extends` left.
</ResponseField>

<ResponseField name="unresolved" type="string[]" required>
  Every reference that did not resolve, in the order it was met.
</ResponseField>

### PaperRenderDeps

Dependencies the emitters (and, later, the screen renderer) need that aren't part of the serializable document: the kernel-backed drawing extractor that resolves each viewport to vector data, and (optionally) the title-block template registry used to render a sheet's title block.

```typescript theme={null}
interface PaperRenderDeps {
  resolveSavedRasterView?: (
    viewId: string,
    viewport?: import('../model/viewport').Viewport,
  ) => import('../model/raster-view').RasterDrawing | undefined;
  extractor: DrawingExtractor;
  resolveSavedView?: (viewId: string) => VectorDrawing;
  templates?: TitleblockTemplateRegistry;
  unitSystem?: UnitSystem;
  projectName?: string;
  date?: string;
  dimensionStyles?: DimensionStyleRegistry;
  paperStyle?: PaperStyleInput;
  paperStyles?: PaperStyleRegistry;
  documentStyle?: DocumentStyleFields;
}
```

<ResponseField name="resolveSavedRasterView" type="(viewId: string, viewport?: import('../model/viewport').Viewport) => import('../model/raster-view').RasterDrawing | undefined">
  Resolve prepared named raster content; return undefined for a vector view.
</ResponseField>

<ResponseField name="extractor" type="DrawingExtractor" required />

<ResponseField name="resolveSavedView" type="(viewId: string) => VectorDrawing">
  Draw a named project view; absent keeps bare paper renderers inline-only.
</ResponseField>

<ResponseField name="templates" type="TitleblockTemplateRegistry" />

<ResponseField name="unitSystem" type="UnitSystem">
  Which conventions to format numbers with.
</ResponseField>

<ResponseField name="projectName" type="string">
  Fills the title block's `projectName` auto-field, which nothing populated.
</ResponseField>

<ResponseField name="date" type="string">
  ISO date (YYYY-MM-DD) for the title block's `date` auto-field. Absent means today, which makes a
  rendered sheet non-reproducible — a batch export or a golden test pins it here.
</ResponseField>

<ResponseField name="dimensionStyles" type="DimensionStyleRegistry">
  Mirrors `PaperDocument.dimensionStyles`; set from it by the exporter and the renderer, for the
  same reason `unitSystem` is.
</ResponseField>

<ResponseField name="paperStyle" type="PaperStyleInput">
  A caller's paper style — an id or an inline overlay — for this render only. Narrower than anything
  stored: it outranks the viewport's, the sheet's and the document's own style.
</ResponseField>

<ResponseField name="paperStyles" type="PaperStyleRegistry">
  Extra presets a host registers, resolvable by id alongside the builtins. A document's own
  `paperStyles` outrank these.
</ResponseField>

<ResponseField name="documentStyle" type="DocumentStyleFields" />

### DocumentStyleFields

The style-bearing fields of a document, lifted into the render deps.

```typescript theme={null}
interface DocumentStyleFields {
  styleId?: PaperStyleId;
  styleOverride?: PaperStyle;
  paperStyles?: PaperStyleRegistry;
}
```

### BuiltinPaperStyleId

The presets that ship.

```typescript theme={null}
type BuiltinPaperStyleId = 'iso-128' | 'ink-sketch' | 'graphite' | 'napkin';
```

## Related

* [`DimensionStyleRegistry`](/floorkit/api/annotations/dimension-styles#dimensionstyleregistry)
* [`DrawingExtractor`](/floorkit/api/drawings/draw-project-view#drawingextractor)
* [`PaperStyle`](/floorkit/api/drawings/sheet-documents#paperstyle)
* [`PaperStyleId`](/floorkit/api/drawings/sheet-documents#paperstyleid)
* [`PaperStyleRegistry`](/floorkit/api/drawings/sheet-documents#paperstyleregistry)
* [`RasterDrawing`](/floorkit/api/views/prepare-project-raster-views#rasterdrawing)
* [`Sheet`](/floorkit/api/drawings/sheet-documents#sheet)
* [`SheetPolicy`](/floorkit/api/drawings/viewport-placement#sheetpolicy)
* [`TitleblockTemplateRegistry`](/floorkit/api/drawings/titleblock-registry#titleblocktemplateregistry)
* [`UnitSystem`](/floorkit/api/annotations/dimension-geometry#unitsystem)
* [`VectorDrawing`](/floorkit/api/drawings/draw-project-view#vectordrawing)
* [`Viewport`](/floorkit/api/drawings/sheet-documents#viewport)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.