Langage
Icons, images and fonts
SVG icons declared once or taken from a pinned library, images and bundled fonts, all checked before generation and used as decorative or labelled view nodes or by typography.
Declaring an icon
icon "arrow-forward" {
source = "assets/icons/arrow-forward.svg"
view_box = [0, 0, 24, 24]
rendering = "template"
direction = "mirror"
keywords = ["next", "continue", "forward"]
license = "Original work for the DSF fixture corpus."
}
| Attribute | Meaning |
|---|---|
source |
An SVG file, relative to the package. Inline geometry (path { data = "M…" }) is also allowed. |
rendering |
template takes the current foreground color; original keeps the file’s colors. |
direction |
mirror flips the icon in right-to-left layouts; preserve never flips it. |
native "apple" { symbol = "…" } |
An optional platform symbol. It needs a portable source too, unless target_only = true (DSF-R009). |
Using an icon
icon "arrow" {
source = icon.arrow-forward
size = token.unit.base
decorative = true
}
An icon node is either decorative = true or has a label (DSF-A002).
What is checked
SVG files are parsed by an XML tokenizer and must follow a restricted profile, an
allowlist: svg, g, path, circle, ellipse, rect, line, polyline, polygon,
defs, linearGradient, radialGradient, stop, clipPath, mask, symbol, use,
title and desc. Attribute values are checked after character references are replaced.
Only files that pass reach the generators.
| ID | Rejected |
|---|---|
DSF-R001, DSF-R007 |
Absolute paths, paths or symbolic links leaving the package. |
DSF-R002 |
Missing file. |
DSF-R003 |
Any other element (script, style, foreignObject, SMIL animation, …), on* event attributes, processing instructions. |
DSF-R004 |
External references (href outside the document, url(…) other than #id, javascript:, data:), CSS escapes, image-set(…), @ rules in style. |
DSF-R005 |
DTDs and entity declarations. |
DSF-R006 |
Files over 1 MiB or with more than 10,000 elements. |
DSF-R010 |
Malformed XML, or not exactly one svg root. |
Icon libraries
A library is vendored inside the package and pinned to a version. Nothing is fetched at build time.
icon_library "lumen" {
manifest = "vendor/lumen-icons/library.dsf"
version = "2.1.0"
}
icon "chevron-forward" {
library = icon_library.lumen
name = "chevron-forward"
rendering = "template"
}
The library’s manifest lists its icons, each with a SHA-256 digest of its file:
icon_library_manifest "lumen" {
version = "2.1.0"
license = "Original work for the DSF fixture corpus."
icon "chevron-forward" {
file = "icons/chevron-forward.svg"
integrity = "sha256-nE7XJvk94amqO/Zpl+GAR7T4SIGEJ284wqsZedQTEEU="
view_box = [0, 0, 24, 24]
keywords = ["next", "disclosure"]
direction = "mirror"
}
}
| ID | Rejected |
|---|---|
DSF-R008 |
A file whose digest is missing, not sha256-<base64>, or does not match its bytes. Checked before the SVG is parsed. |
DSF-R011 |
A manifest whose version differs from the pinned one, or that lacks the icon or its file. |
A library icon then follows the same SVG profile, and generators bundle it like any other icon.
Images
image "avatar" {
source = "assets/images/avatar.png"
description = "A blue diagonal gradient standing for a profile picture."
license = "Original work for the DSF fixture corpus."
}
An image is a PNG, JPEG or WebP file (up to 4 MiB, 16,384 pixels on a side and 40
megapixels) or an SVG that follows the icon profile. The extension names the format, and the
file must carry that format’s signature: a renamed file is DSF-R012. The compiler reads a
raster image’s size from its header and never decodes it.
image "avatar" {
source = image.avatar
width = dp(48)
height = dp(48)
fit = "cover"
label = "Profile picture"
}
Like an icon node, an image node is either decorative = true or has a label
(DSF-A002). fit is contain (the default: the whole image), cover (the box filled, the
image cut) or fill (stretched); without a size, the node takes the image’s own size.
SwiftUI bundles the file as a package resource, Angular embeds it in an <img> as a data:
URL, and the documentation previews it.
Fonts
font "fixture-sans" {
family = "DSF Fixture Sans"
license = "CC0-1.0. Original work for the DSF fixture corpus."
files = [
{
source = "assets/fonts/dsf-fixture-sans.woff2"
weight = 400
style = "normal"
},
{
source = "assets/fonts/dsf-fixture-sans.ttf"
weight = 600
},
]
}
A font bundles one family: WOFF2, WOFF, TrueType or OpenType files (checked by signature,
DSF-R012), one per weight and style. license is required because the files are
redistributed with the generated code, and the family cannot be a generic one such as
serif (DSF-T004). A typography token selects the font by its family name:
token "label" {
type = "typography"
value = {
font_family = ["DSF Fixture Sans", "sans-serif"]
font_size = dp(13)
font_weight = 600
letter_spacing = dp(0)
line_height = 1.25
}
}
SwiftUI registers the bundled files with Core Text before a family is first looked up
(DSFonts.register(), which an app may also call at launch). Angular adds @font-face
rules to tokens.css, and the documentation serves the files with its pages. Only files of
the package, or of a package it imports, are ever bundled.