Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

LR10: a page's fonts as Chrome finds them, in svg and canvas text. An @font-face face is found by its own weight and style, not its file's (Google serves one variable Inter as every weight, whose file says 400, so 500 drew as 400 and 600 as raea's bundled 700); a face given twice (document.fonts.load and the page's @font-face) is added once; a page's faces of a family shadow the app's bundled ones, as @font-face shadows a local font (raea's static Inter 400 beside Google's 400 read to canvas text as a family split by unicode-range); and a character's advance is read at the weight asked for (a space's moves with a variable face). The canvas has letterSpacing and wordSpacing, shaped by the host. snapcn: title-sweep 3.7 -> 0.3, spec-sweep 4.4 -> 0.3, sky-lockup 15.7 -> 0.3; the corpus 12 of 33 (7 before LR10)

shinyobjectz44ca3f16d657
diff --git a/sdk/ui/src/canvas/context.ts b/sdk/ui/src/canvas/context.ts
index 2db17d7a..e5c63ad6 100644
--- a/sdk/ui/src/canvas/context.ts
+++ b/sdk/ui/src/canvas/context.ts
@@ -1,7 +1,7 @@
// CanvasRenderingContext2D.
import * as wire from "../wire";
import { base64, encodePng } from "./png";
-import { COMPOSITES, CanvasHost, Gradient, ID, ImageData_, Paint, Path, Path2D_, S, State, fresh, measure, mul, paintOf, parseColor, parseFilter, parseFont, unb64 } from "./all";
+import { COMPOSITES, CanvasHost, Gradient, ID, ImageData_, Paint, Path, Path2D_, S, State, fresh, measure, mul, paintOf, parseColor, parseFilter, parseFont, parseSpacing, unb64 } from "./all";
export class CanvasRenderingContext2D_ {
private s: State = fresh();
@@ -234,6 +234,28 @@ export class CanvasRenderingContext2D_ {
set font(v: string) {
if (parseFont(v)) this.s.font = v;
}
+ // tracking and word spacing, as Chrome's canvas has them (snapcn's sky-lockup measures its words with letterSpacing
+ // set: layout-reads LR10); an em is the font's as it is when it's set
+ get letterSpacing() {
+ return `${this.s.letterSpacing}px`;
+ }
+ set letterSpacing(v: string) {
+ const n = parseSpacing(v, this.s.font);
+ if (n !== null) this.s.letterSpacing = n;
+ }
+ get wordSpacing() {
+ return `${this.s.wordSpacing}px`;
+ }
+ set wordSpacing(v: string) {
+ const n = parseSpacing(v, this.s.font);
+ if (n !== null) this.s.wordSpacing = n;
+ }
+ /** the font the host shapes text in: the CSS font's parts, and the spacing when there is any */
+ private get shaped() {
+ const f = parseFont(this.s.font)!;
+ const { letterSpacing, wordSpacing } = this.s;
+ return letterSpacing || wordSpacing ? { ...f, letterSpacing, wordSpacing } : f;
+ }
get textAlign() {
return this.s.align;
}
@@ -411,7 +433,7 @@ export class CanvasRenderingContext2D_ {
this.push(["clear", p.d, { ...this.state(), shadow: null }]);
}
private text(kind: "fill" | "stroke", text: string, x: number, y: number, maxWidth?: number) {
- const f = parseFont(this.s.font)!;
+ const f = this.shaped;
const align = this.side;
const paint = kind === "fill" ? paintOf(this.s.fill, this.s.ts) : paintOf(this.s.stroke, this.s.ts);
this.push(["text", kind, String(text), x, y, f, align, this.s.baseline, maxWidth ?? null, paint, kind === "stroke" ? this.strokeParams() : null, this.state()]);
@@ -427,7 +449,7 @@ export class CanvasRenderingContext2D_ {
return this.s.align === "start" ? "left" : this.s.align === "end" ? "right" : this.s.align;
}
measureText(text: string) {
- return measure(this.s.font, String(text), this.side, this.s.baseline);
+ return measure(this.shaped, String(text), this.side, this.s.baseline);
}
drawImage(img: { src?: string; currentSrc?: string; _canvas2d?: CanvasRenderingContext2D_; width?: number; height?: number; naturalWidth?: number; naturalHeight?: number }, ...a: number[]) {
let s: (number | null)[];
diff --git a/sdk/ui/src/canvas/measure.ts b/sdk/ui/src/canvas/measure.ts
index 3b2319c9..a93f344f 100644
--- a/sdk/ui/src/canvas/measure.ts
+++ b/sdk/ui/src/canvas/measure.ts
@@ -3,6 +3,9 @@
import * as wire from "../wire";
import { S, metrics, parseFont } from "./all";
+/** A CSS font's parts, and the context's letterSpacing and wordSpacing in px when it has any. */
+export type Shaped = NonNullable<ReturnType<typeof parseFont>> & { letterSpacing?: number; wordSpacing?: number };
+
/** The host's TextMetrics, where it shapes text (canvas.measure); asked no more once it says it can't. */
let shapes = true;
function hostMetrics(font: unknown, text: string, align: string, baseline: string) {
@@ -17,8 +20,9 @@ function hostMetrics(font: unknown, text: string, align: string, baseline: strin
/** measureText's answer for `text` in a CSS `font`, from the point the context's textAlign (left, center or right)
* and textBaseline put it at. */
-export function measure(font: string, text: string, align = "left", baseline = "alphabetic") {
- const f = parseFont(font)!;
+export function measure(font: string | Shaped, text: string, align = "left", baseline = "alphabetic") {
+ const f: Shaped = typeof font === "string" ? parseFont(font)! : font;
+ // the host shapes the spacing in (systems/canvas measure.rs)
const shaped = hostMetrics(f, text, align, baseline);
if (shaped) return shaped;
const fam = f.family.replace(/["']/g, "").split(",")[0].trim().toLowerCase();
@@ -28,6 +32,8 @@ export function measure(font: string, text: string, align = "left", baseline = "
let w = 0;
for (const ch of text) w += host?.get(ch) ?? (m ? (m.adv[ch] ?? m.dflt) / m.em : 0.6);
w *= f.size;
+ // after every character, the last one's too, as Chrome tracks a canvas's text; and after every space
+ w += (f.letterSpacing ?? 0) * [...text].length + (f.wordSpacing ?? 0) * (text.match(/ /g)?.length ?? 0);
return { width: w, actualBoundingBoxLeft: 0, actualBoundingBoxRight: w, fontBoundingBoxAscent: f.size * 0.8, fontBoundingBoxDescent: f.size * 0.2, actualBoundingBoxAscent: f.size * 0.7, actualBoundingBoxDescent: 0 };
}
diff --git a/sdk/ui/src/canvas/paths.ts b/sdk/ui/src/canvas/paths.ts
index e7ccfd8c..dda6bcc7 100644
--- a/sdk/ui/src/canvas/paths.ts
+++ b/sdk/ui/src/canvas/paths.ts
@@ -108,6 +108,9 @@ export type State = {
alpha: number;
comp: string;
font: string;
+ /** ctx.letterSpacing and ctx.wordSpacing, px */
+ letterSpacing: number;
+ wordSpacing: number;
align: CanvasTextAlign;
baseline: CanvasTextBaseline;
shadowColor: RGBA;
@@ -123,7 +126,7 @@ export type State = {
export const fresh = (): State => ({
ts: ID, fill: [0, 0, 0, 1], stroke: [0, 0, 0, 1], lineWidth: 1, lineCap: "butt", lineJoin: "miter", miterLimit: 10, dash: [], dashOffset: 0,
- alpha: 1, comp: "source-over", font: "10px sans-serif", align: "start", baseline: "alphabetic", shadowColor: [0, 0, 0, 0], shadowBlur: 0, shadowX: 0,
+ alpha: 1, comp: "source-over", font: "10px sans-serif", letterSpacing: 0, wordSpacing: 0, align: "start", baseline: "alphabetic", shadowColor: [0, 0, 0, 0], shadowBlur: 0, shadowX: 0,
shadowY: 0, smooth: true, filter: "none", filters: [], clip: [],
});
@@ -138,6 +141,16 @@ export function parseFont(f: string): { size: number; family: string; weight: st
return { size, family: m[7].trim(), weight: m[3] === "bold" ? "700" : m[3] && /\d/.test(m[3]) ? m[3] : "400", style: m[1] === "italic" || m[4] === "italic" ? "italic" : "normal" };
}
+/** ctx.letterSpacing or ctx.wordSpacing as px: a CSS length (px, em of the context's font as it is, rem), or null for
+ * one a browser ignores */
+export function parseSpacing(v: string, font: string): number | null {
+ const m = String(v).match(/^\s*(-?(?:\d+\.?\d*|\.\d+))(px|em|rem)?\s*$/);
+ if (!m) return null;
+ const n = parseFloat(m[1]);
+ if (!m[2]) return n === 0 ? 0 : null;
+ return m[2] === "px" ? n : m[2] === "rem" ? n * 16 : n * (parseFont(font)?.size ?? 10);
+}
+
/** Fonts' advances as the host measured them: family -> {em, advance per char, default advance} (`fonts` event). */
export const metrics = new Map<string, { em: number; adv: Record<string, number>; dflt: number }>();
diff --git a/systems/canvas/Cargo.toml b/systems/canvas/Cargo.toml
index ee2ae711..bbed2afd 100644
--- a/systems/canvas/Cargo.toml
+++ b/systems/canvas/Cargo.toml
@@ -19,5 +19,6 @@ resvg = { version = "=0.48.1", default-features = false, features = ["text"] }
tiny-skia = { version = "=0.12.0", default-features = false, features = ["std", "simd"] }
# read's pixels across the wire
base64 = "0.22"
-# which file of a family split by unicode-range has a glyph (subsets.rs)
-ttf-parser = { version = "0.25", default-features = false, features = ["std"] }
+# which file of a family split by unicode-range has a glyph (subsets.rs), and a character's advance at the weight asked
+# for (measure.rs: a variable face's HVAR)
+ttf-parser = { version = "0.25", default-features = false, features = ["std", "variable-fonts"] }
diff --git a/systems/canvas/src/measure.rs b/systems/canvas/src/measure.rs
index 5b2ab90d..04bf9ac8 100644
--- a/systems/canvas/src/measure.rs
+++ b/systems/canvas/src/measure.rs
@@ -33,8 +33,14 @@ pub(crate) fn text_doc(opt: &usvg::Options, font: &Value, text: &str, at: (f32,
}).collect(),
None => escape(text),
};
+ // the context's letterSpacing and wordSpacing (px): usvg spaces after every letter, the last one's too, as Chrome's
+ // canvas does (vendor/usvg)
+ let spacing: String = [("letter-spacing", "letterSpacing"), ("word-spacing", "wordSpacing")]
+ .iter()
+ .filter_map(|(attr, key)| font[key].as_f64().filter(|v| *v != 0.0).map(|v| format!(" {attr}=\"{v}\"")))
+ .collect();
format!(
- "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{w}\" height=\"{h}\"><text x=\"{}\" y=\"{}\" font-size=\"{}\" font-family=\"{fam}\" font-weight=\"{}\" font-style=\"{}\" text-anchor=\"{anchor}\" dominant-baseline=\"{base}\" {paint}>{esc}</text></svg>",
+ "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{w}\" height=\"{h}\"><text x=\"{}\" y=\"{}\" font-size=\"{}\" font-family=\"{fam}\" font-weight=\"{}\" font-style=\"{}\" text-anchor=\"{anchor}\" dominant-baseline=\"{base}\"{spacing} {paint}>{esc}</text></svg>",
at.0,
at.1,
crate::paint::f(&font["size"]),
@@ -111,7 +117,9 @@ pub fn advances(opt: &usvg::Options, args: &Value) -> Value {
break;
}
db.with_face_data(id, |data, index| {
- let Ok(f) = ttf_parser::Face::parse(data, index) else { return };
+ let Ok(mut f) = ttf_parser::Face::parse(data, index) else { return };
+ // a variable face at the weight asked for, as usvg draws it (a space's advance moves with it)
+ f.set_variation(ttf_parser::Tag::from_bytes(b"wght"), f32::from(weight));
let em = f64::from(f.units_per_em());
for (c, slot) in chars.iter().zip(out.iter_mut()).filter(|(_, s)| s.is_none()) {
if let Some(a) = f.glyph_index(*c).and_then(|g| f.glyph_hor_advance(g)) {
@@ -157,5 +165,10 @@ mod tests {
assert!(g(&mt(" ", "left"), "width") > 50.0 && g(&mt(" ", "left"), "actualBoundingBoxRight") == 0.0);
assert!((g(&mt(" H ", "left"), "width") - g(&h, "width") - g(&mt(" ", "left"), "width")).abs() < 0.01, "{}", mt(" H ", "left"));
assert_eq!(g(&mt("", "left"), "width"), 0.0);
+ // letterSpacing after every character, the last one's too, and wordSpacing after each space, as Chrome
+ let spaced = |ls: f64, ws: f64| g(&metrics(&opt, &json!({"font": {"family": "Arial", "size": 100, "weight": "400", "style": "normal", "letterSpacing": ls, "wordSpacing": ws}, "text": "im im", "align": "left", "baseline": "alphabetic"})), "width");
+ let plain = spaced(0.0, 0.0);
+ assert!((spaced(-2.0, 0.0) - (plain - 10.0)).abs() < 0.01, "{plain} {}", spaced(-2.0, 0.0));
+ assert!((spaced(0.0, 7.0) - (plain + 7.0)).abs() < 0.01, "{plain} {}", spaced(0.0, 7.0));
}
}
diff --git a/systems/fonts/src/google.rs b/systems/fonts/src/google.rs
index a2c7343b..1d8a10c8 100644
--- a/systems/fonts/src/google.rs
+++ b/systems/fonts/src/google.rs
@@ -86,8 +86,9 @@ pub fn load_now(family: &str) -> usize {
return faces.len();
}
let faces = Arc::new(fetch(family));
- for (ttf, _, _) in faces.iter() {
- blitz_dom::util::add_svg_font(ttf.to_vec(), Some(family));
+ for (ttf, weight, italic) in faces.iter() {
+ // each at the weight and style its @font-face gives it (one variable file is every weight of a family)
+ blitz_dom::util::add_svg_font(ttf.to_vec(), Some(family), Some((*weight as u16, *italic)));
}
known.insert(family.to_string(), faces.clone());
faces.len()
@@ -132,7 +133,7 @@ pub fn face_now(family: &str, url: &str) -> usize {
let Ok(bytes) = raea_io_net::cache::read(url) else { return 0 };
let ttf = if bytes.starts_with(b"wOF2") { wuff::decompress_woff2(&bytes).ok() } else { Some(bytes) };
let Some(ttf) = ttf else { return 0 };
- blitz_dom::util::add_svg_font(ttf, Some(family));
+ blitz_dom::util::add_svg_font(ttf, Some(family), None);
LOADED.lock().unwrap().push(key);
1
}
diff --git a/systems/fonts/src/lib.rs b/systems/fonts/src/lib.rs
index fda8043b..9eb0763c 100644
--- a/systems/fonts/src/lib.rs
+++ b/systems/fonts/src/lib.rs
@@ -82,7 +82,7 @@ fn build(dir: &Path) -> (FontContext, Own) {
let named = p.file_name().and_then(|f| index.get(f.to_str()?));
// SVG text and a canvas's text (usvg's font database) have the bundled faces too, by the same family name: a
// composition's canvas measured and drew Inter in a fallback face (layout-reads LR6)
- blitz_dom::util::add_svg_font(ttf.clone(), named.map(|(family, _, _)| family.as_str()));
+ blitz_dom::util::add_bundled_svg_font(ttf.clone(), named.map(|(family, _, _)| family.as_str()), named.map(|(_, weight, italic)| (*weight as u16, *italic)));
let info = named.map(|(family, weight, italic)| FontInfoOverride {
family_name: Some(family.as_str()),
weight: Some(FontWeight::new(*weight)),
diff --git a/vendor/blitz-dom/src/document.rs b/vendor/blitz-dom/src/document.rs
index 68d23a05..c4d3ce30 100644
--- a/vendor/blitz-dom/src/document.rs
+++ b/vendor/blitz-dom/src/document.rs
@@ -1435,7 +1435,11 @@ impl BaseDocument {
Resource::Font(bytes, overrides) => {
// raea: SVG text has the page's faces too
#[cfg(feature = "svg")]
- crate::util::add_svg_font(bytes.to_vec(), overrides.family_name.as_deref());
+ crate::util::add_svg_font(
+ bytes.to_vec(),
+ overrides.family_name.as_deref(),
+ overrides.weight.map(|w| (w as u16, matches!(overrides.style, Some(parley::fontique::FontStyle::Italic)))),
+ );
let font = Blob::new(Arc::new(bytes));
// Build a `FontInfoOverride` from the `@font-face` descriptors
diff --git a/vendor/blitz-dom/src/util.rs b/vendor/blitz-dom/src/util.rs
index 2e04f2dc..2793bd4e 100644
--- a/vendor/blitz-dom/src/util.rs
+++ b/vendor/blitz-dom/src/util.rs
@@ -50,21 +50,70 @@ pub(crate) static FONT_DB: LazyLock<Mutex<Arc<fontdb::Database>>> = LazyLock::ne
Mutex::new(Arc::new(db))
});
-/// raea: a face for SVG text (a page's @font-face, an app's bundled faces), as HTML text has it; `family` is the name
-/// the page knows it by (an @font-face's font-family), which the face is found by first
+/// raea: the faces the app bundles, by family in lower case: a page's own faces of a family take its place, as an
+/// @font-face shadows a local font of the same name in Chrome
#[cfg(feature = "svg")]
-pub fn add_svg_font(bytes: Vec<u8>, family: Option<&str>) {
+static BUNDLED: LazyLock<Mutex<std::collections::HashMap<String, Vec<fontdb::ID>>>> = LazyLock::new(Default::default);
+
+/// raea: a face the page gives SVG text (its @font-face's), as HTML text has it; `family` is the name the page knows
+/// it by (an @font-face's font-family), which the face is found by first. `face`: the @font-face's weight and whether
+/// it's italic. SVG text finds a face by them, as Chrome does, not by the file's own: Google serves one variable file
+/// as each of Inter's weights, whose own weight is 400, so a 500 found a 400 face (or the bundled static 400) and 600
+/// the bundled static 700, and the text drew at 400 or 700 (layout-reads LR10). The app's bundled faces of the family
+/// leave once the page gives its own.
+#[cfg(feature = "svg")]
+pub fn add_svg_font(bytes: Vec<u8>, family: Option<&str>, face: Option<(u16, bool)>) {
+ add_face(bytes, family, face, false);
+}
+
+/// raea: a face the app bundles for SVG text (raea-sys-fonts' faces), found by `family` until a page gives its own
+#[cfg(feature = "svg")]
+pub fn add_bundled_svg_font(bytes: Vec<u8>, family: Option<&str>, face: Option<(u16, bool)>) {
+ add_face(bytes, family, face, true);
+}
+
+#[cfg(feature = "svg")]
+fn add_face(bytes: Vec<u8>, family: Option<&str>, face: Option<(u16, bool)>, bundled: bool) {
+ // once each: a face given again (document.fonts.load and the page's @font-face both give Google's) would be two
+ // faces of one weight and style, which canvas text takes for a family split by unicode-range (raea-sys-canvas
+ // subsets.rs)
+ {
+ use std::hash::{Hash, Hasher};
+ static SEEN: LazyLock<Mutex<std::collections::HashSet<u64>>> = LazyLock::new(Default::default);
+ let mut h = std::collections::hash_map::DefaultHasher::new();
+ (&bytes, family, face).hash(&mut h);
+ if !SEEN.lock().unwrap().insert(h.finish()) {
+ return;
+ }
+ }
let mut db = FONT_DB.lock().unwrap();
let db = Arc::make_mut(&mut db);
- let ids = db.load_font_source(fontdb::Source::Binary(Arc::new(bytes)));
- let Some(family) = family else { return };
- for id in ids {
- if let Some(mut info) = db.face(id).cloned() {
+ let mut bundled_ids = BUNDLED.lock().unwrap();
+ // the page's own faces of a family: the bundled ones of that name go
+ if let (false, Some(family)) = (bundled, family) {
+ for id in bundled_ids.remove(&family.to_lowercase()).unwrap_or_default() {
db.remove_face(id);
- info.families.insert(0, (family.to_string(), fontdb::Language::English_UnitedStates));
- db.push_face_info(info);
}
}
+ let mut ids = db.load_font_source(fontdb::Source::Binary(Arc::new(bytes))).to_vec();
+ if family.is_some() || face.is_some() {
+ for id in std::mem::take(&mut ids) {
+ if let Some(mut info) = db.face(id).cloned() {
+ db.remove_face(id);
+ if let Some(family) = family {
+ info.families.insert(0, (family.to_string(), fontdb::Language::English_UnitedStates));
+ }
+ if let Some((weight, italic)) = face {
+ info.weight = fontdb::Weight(weight);
+ info.style = if italic { fontdb::Style::Italic } else { fontdb::Style::Normal };
+ }
+ ids.push(db.push_face_info(info));
+ }
+ }
+ }
+ if let (true, Some(family)) = (bundled, family) {
+ bundled_ids.entry(family.to_lowercase()).or_default().extend(ids);
+ }
}
/// Which kind of CSS image layer list (`background-image` or `mask-image`) to
@@ -247,17 +296,9 @@ fn base64_decode(s: &str) -> Option<Vec<u8>> {
/// Parse an SVG image.
#[cfg(feature = "svg")]
pub(crate) fn parse_svg_image(source: &[u8]) -> Result<crate::node::SvgImageData, usvg::Error> {
- // raea: its own @font-face faces join the SVG faces first (once each), so its text is drawn in them
- {
- use std::hash::{Hash, Hasher};
- static SEEN: LazyLock<Mutex<std::collections::HashSet<u64>>> = LazyLock::new(Default::default);
- for (family, bytes) in svg_font_faces(source) {
- let mut h = std::collections::hash_map::DefaultHasher::new();
- (&family, &bytes).hash(&mut h);
- if SEEN.lock().unwrap().insert(h.finish()) {
- add_svg_font(bytes, Some(&family));
- }
- }
+ // raea: its own @font-face faces join the SVG faces first (add_svg_font takes each once), so its text is drawn in them
+ for (family, bytes) in svg_font_faces(source) {
+ add_svg_font(bytes, Some(&family), None);
}
let options = usvg::Options {
fontdb: Arc::clone(&FONT_DB.lock().unwrap()),
@@ -284,6 +325,40 @@ impl ToColorColor for AbsoluteColor {
mod svg_tests {
use super::parse_svg_image;
+ /// raea: a face is found by its @font-face weight, not its file's, and a page's faces of a family shadow the app's
+ /// bundled ones (Google's variable Inter beside raea's bundled static Inter drew 500 as 400, layout-reads LR10)
+ #[cfg(target_os = "macos")]
+ #[test]
+ fn an_svg_face_is_found_at_its_font_face_weight() {
+ use super::{add_bundled_svg_font, add_svg_font, fontdb, svg_fonts};
+ let family = "raea lr10 weight";
+ let stat = std::fs::read("/System/Library/Fonts/Supplemental/Arial.ttf").unwrap();
+ let var = std::fs::read("/System/Library/Fonts/SFNS.ttf").unwrap();
+ add_bundled_svg_font(stat, Some(family), Some((400, false)));
+ let named = |db: &fontdb::Database| db.faces().filter(|f| f.families.iter().any(|(n, _)| n == family)).count();
+ assert_eq!(named(&svg_fonts()), 1, "the bundled face, until the page gives its own");
+ for w in [400, 500, 600] {
+ add_svg_font(var.clone(), Some(family), Some((w, false)));
+ }
+ let db = svg_fonts();
+ assert_eq!(named(&db), 3, "the page's three; the bundled one has gone");
+ let at = |w: u16| {
+ let q = fontdb::Query { families: &[fontdb::Family::Name(family)], weight: fontdb::Weight(w), ..Default::default() };
+ let id = db.query(&q).unwrap();
+ let face = db.face(id).unwrap();
+ (face.weight.0, face.post_script_name.clone())
+ };
+ let (w, name) = at(500);
+ assert_eq!(w, 500, "{name}");
+ assert!(!name.contains("Arial"), "500 found the static 400: {name}");
+ assert_eq!(at(600).0, 600);
+ // given again, it isn't a second face of that weight
+ let count = |db: &fontdb::Database| db.faces().filter(|f| f.families.iter().any(|(n, _)| n == family) && f.weight.0 == 500).count();
+ assert_eq!(count(&db), 1);
+ add_svg_font(var, Some(family), Some((500, false)));
+ assert_eq!(count(&svg_fonts()), 1);
+ }
+
#[test]
fn svg_without_xmlns_parses() {
let src = br#"<svg viewBox="0 0 24 24"><path d="M0 0h24v24H0z"/></svg>"#;