Skip to content
pixi-silk
GitHub repository
Text

Text themes

The theme.json of pixi-silk/i18n: the base style, styles that tags select, which properties change live and which need a new compile, and the units of each effect.

Updated pixi-silk 1.5.2View as Markdown

Designers own theme.json. Strings never carry styling: a translator writes <gold>1,250</gold>, and the theme says what gold looks like in every language.

{
  "$silk": 2,
  "base": { "fill": "#F3EBD8", "shadow": { "color": "#000", "alpha": 0.45, "offset": [0, 2], "softness": 0.6 } },
  "styles": {
    "title": { "weight": 700, "fill": "#FFE7A8", "outline": { "width": 2, "color": "#3B2507" } },
    "gold": { "fill": "#FFC53D", "outline": { "width": 1.5, "color": "#5A3A00" }, "glow": { "color": "#FFB000", "strength": 0.35 } },
    "terms": { "fill": "#79C8FF", "underline": { "thickness": 0.06, "offset": 0.12 }, "interactive": true }
  }
}

base styles untagged text. Every style in styles is a tag. Nested tags combine: the inner tag overrides only the properties it sets.

What changes live#

KindPropertiesAt runtime
Paintfill, alpha, outline, glow, shadow, underline, strike, weightBiastheme.set changes them with no relayout
Layoutsize, letterSpacingtheme.set lays the messages out again. Baked advances do not depend on size
Approximatedweighttheme.set thickens or thins the glyphs with the weight bias, and warns. Compile again for the real face
Shapefamily, featuresNeed silk compile again. theme.set warns
BehaviourinteractiveTaps on the span arrive as tagtap
import type { SilkTheme } from 'pixi-silk/i18n/pixi';

declare const theme: SilkTheme;

theme.set('gold', { fill: '#FFF4B0', glow: { color: '#FFE066', strength: 0.5 } });

Units#

  • outline.width, glow.width and shadow.offset are pixels at scale 1.
  • shadow.softness runs from 0 (hard) to 1 (4 pixels of blur).
  • underline and strike thickness and offset are in em of the text size.
  • weightBias is in em, from -0.05 to 0.05.

Effects reach only as far as the distance field around each glyph. The compiler sizes the field from the theme and the smallest text size (atlas.minSize, default 24), and warns when an effect would be cut. Prefer a short glow at small sizes.

API reference: SilkTheme