VectorCraft: An open-source, vector art tool written by scratch in pure Rust
SVG export: a Japanese face's numbered weight (W0–W9) is its font-weight, W6 600 (#2873)
bflatasticeec304dde166
diff --git a/crates/svg/tests/font_weights.rs b/crates/svg/tests/font_weights.rsindex f642930c5..31d358c61 100644--- a/crates/svg/tests/font_weights.rs+++ b/crates/svg/tests/font_weights.rs@@ -55,6 +55,13 @@ fn every_style_is_written_with_its_numeric_weight() {("Extrabold", Some("800")),("Black", Some("900")),("Heavy", Some("900")),+ // Japanese faces' numbered weights (#2873); W4 is the regular weight.+ ("W0", Some("100")),+ ("W3", Some("300")),+ ("W4", None),+ ("W6", Some("600")),+ ("W9", Some("900")),+ ("Wide", None),] {let want = want.map(str::to_string);assert_eq!(weights(style), (want.clone(), want), "{style}");diff --git a/crates/text/src/fontdb.rs b/crates/text/src/fontdb.rsindex 3acf0fd04..f56eaa371 100644--- a/crates/text/src/fontdb.rs+++ b/crates/text/src/fontdb.rs@@ -1568,8 +1568,16 @@ fn norm(s: &str) -> String {norm_chars(s).collect()}-/// Weight implied by a style name (400 = regular).+/// Weight implied by a style name (400 = regular). Japanese faces number their weights W0–W9+/// (Hiragino, Morisawa…), W6 weighing 600 as its weight class does (#2873).pub fn style_weight(style: &str) -> f32 {+ let numbered = style.split(|c: char| !c.is_ascii_alphanumeric()).find_map(|part| match part.as_bytes() {+ [b'W' | b'w', d @ b'0'..=b'9'] => Some(f32::from(d - b'0') * 100.0),+ _ => None,+ });+ if let Some(w) = numbered {+ return w.max(100.0);+ }let s = norm(style);const TABLE: &[(&str, f32)] = &[("extralight", 200.0),diff --git a/docs/mcp.md b/docs/mcp.mdindex 5082f849e..24482fa25 100644--- a/docs/mcp.md+++ b/docs/mcp.md@@ -467,7 +467,7 @@ lists every option with its default. `encoding` is `utf8`, `utf16` (big-endian a(presentation attributes only; filters, masks, blend modes and embedded fonts left out, symbols as art, each witha warning). `embedFonts: true` embeds the fonts type uses as `@font-face` rules subset to the characters used; afont whose licence (OS/2 `fsType`) forbids subsetting is embedded whole, one that forbids embedding is left out-with a warning. Type names its faces by numeric `font-weight` (600 for Semibold, 300 for Light, `bold` for 700),+with a warning. Type names its faces by numeric `font-weight` (600 for Semibold and for a Japanese face's W6, 300 for Light, `bold` for 700),embedded or not. `svgz` takes the same options and writes the SVG gzipped (`.svgz` files also open,place and paste). `run_command document.save {path: "x.svg", svg: {…}}` saves as SVG (or `.svgz`).