Skip to content
Apexify.jsDocs
Apexify.js version v5.4.5

Node / Text Rendering · guide

Font, alignment & transforms

Current Apexify.js 6.0.0 documentation for Font, alignment & transforms.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

Placement is anchored at (x, y) using Canvas textAlign and textBaseline. Optional rotation spins the entire block around (x, y) before lines are laid out.


Font configuration (font)

Prefer the nested font object; legacy top-level aliases remain.

FieldPurpose
font.sizePixels (default 16).
font.familyInstalled face family (e.g. Arial). Passed through to the CSS font string as "${size}px \"${family}\"".
font.nameLogical font family name used together with font.path when registering the file (GlobalFonts.registerFromPath).
font.pathPath to .ttf, .otf, .woff — resolved relative to process.cwd() unless absolute.

Legacy aliases: fontSize, fontFamily, fontName, fontPath (nested font.* wins when both are set).

SOURCEtypescript
typescript
Studio
await painter.createText(  {    text: 'Hello',    x: 120,    y: 96,    font: { size: 42, path: './fonts/Inter-Bold.ttf', name: 'InterDisplay' },    decorations: { bold: false, italic: false },  },  buffer);

When font.path is set, registerTextFontFromPath runs before each layer paints. Registration failures console.warn and drawing continues with the fallback family string.


Weight & slant (decorations)

FieldEffect
decorations.boldPrefix bold on the CSS font string.
decorations.italicPrefix italic.

Legacy bold / italic at the top level work the same way; decorations wins if both are provided (resolveTextDecorations).


Placement (placement)

Prefer placement; flat textAlign, textBaseline, and rotation are aliases (resolveTextPlacement).

FieldTypeRole
textAlignTextAlignModeleft, center, right, start, end — Canvas ctx.textAlign.
textBaselineTextBaselineModealphabetic (default), top, hanging, middle, ideographic, bottom — Canvas ctx.textBaseline.
rotationnumber (degrees)Rotates **around (x, y): translate(x,y) → rotate → translate(-x,-y).
SOURCEtypescript
typescript
Studio
await painter.createText(  {    text: 'Rotated label',    x: 400,    y: 240,    placement: {      textAlign: 'center',      textBaseline: 'middle',      rotation: -12,    },    font: { size: 36, family: 'Arial' },    fill: { color: '#1e293b' },  },  buffer);

Fill opacity (fill.opacity)

placement.rotation runs first (applyTextTransformations), then fill.opacity clamps ctx.globalAlpha to [0, 1]. Use fill.opacity (or legacy opacity) for uniform transparency over highlight/glow/shadow/stroke/fill/decoration passes within that layer.


Implementation reference

Font string assembly and spacing hooks live in setupTextFont; alignment in setupTextAlignment (lib-next/text/text-layout.ts).


Next steps