SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Sketch library: include the built-in font in vendored sources (#12162) (#12174)
Thijs Damsma4699b9cc89e6
diff --git a/ATTRIBUTION.md b/ATTRIBUTION.mdindex c7cb555b0d..305f0e6310 100644--- a/ATTRIBUTION.md+++ b/ATTRIBUTION.md@@ -82,7 +82,6 @@ Editable drawing code, native projects and shipped exports are collected under `| assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf | IBM Corp. (IBM Plex Mono) | https://github.com/IBM/plex (via google/fonts), unmodified; licence text in assets/fonts/ibm-plex-mono/OFL.txt; the interface monospace font | SIL OFL 1.1 || assets/fonts/ibm-plex-sans/IBMPlexSans-Variable.ttf | IBM Corp. (IBM Plex Sans, variable wdth and wght) | https://github.com/IBM/plex (via google/fonts), unmodified; licence text in assets/fonts/ibm-plex-sans/OFL.txt; the default interface font | SIL OFL 1.1 || docs/book/src/generated/tool-preview.png | SolidCraft contributors | rendered by `cargo xtask book` (`solidcraft-cli snapshot docs/book/scripts/tool-preview.json`; gitignored) | MIT OR Apache-2.0 |-| assets/fonts/liberation-sans/LiberationSans-Regular.ttf | Red Hat, Inc. (Liberation Fonts 2.x; digitized data Google) | https://github.com/liberationfonts (Debian fonts-liberation), unmodified; licence text in assets/fonts/liberation-sans/OFL.txt; used for sketch Text outlines | SIL OFL 1.1 || assets/fonts/biz-udp-gothic/BIZUDPGothic-Regular.ttf | The BIZ UDGothic Project Authors | https://github.com/googlefonts/morisawa-biz-ud-gothic (Google Fonts), unmodified; licence text in assets/fonts/biz-udp-gothic/OFL.txt; used for web UI Japanese font | SIL OFL 1.1 || assets/fonts/craft-ui-sc/CraftUI-SC.otf | Adobe / Google Inc. (Noto Sans SC); SolidCraft subset | https://github.com/notofonts/noto-cjk Sans/SubsetOTF/SC Regular, glyph-subset for assets/locales/zh.json and renamed Craft UI SC (OFL reserved-name); licence text in assets/fonts/craft-ui-sc/OFL.txt; web UI Simplified Chinese | SIL OFL 1.1 || assets/fonts/craft-ui-tc/CraftUI-TC.otf | Adobe / Google Inc. (Noto Sans TC); SolidCraft subset | https://github.com/notofonts/noto-cjk Sans/SubsetOTF/TC Regular, glyph-subset for assets/locales/zh-TW.json and renamed Craft UI TC (OFL reserved-name); licence text in assets/fonts/craft-ui-tc/OFL.txt; web UI Traditional Chinese | SIL OFL 1.1 |@@ -147,7 +146,6 @@ Editable drawing code, native projects and shipped exports are collected under `| assets/fonts/craft-ui-tc/OFL.txt | Adobe / Google Inc. (Noto CJK); SolidCraft header | Accompanying OFL for CraftUI-TC.otf | SIL OFL 1.1 || assets/fonts/ibm-plex-mono/OFL.txt | IBM Corp. | Unmodified accompanying font licence | SIL OFL 1.1 || assets/fonts/ibm-plex-sans/OFL.txt | IBM Corp. | Unmodified accompanying font licence | SIL OFL 1.1 |-| assets/fonts/liberation-sans/OFL.txt | Red Hat, Inc.; Liberation Fonts contributors | Unmodified accompanying font licence | SIL OFL 1.1 || assets/icons/app/linux/exports/hicolor/128x128/apps/io.tangencylabs.solidcraft.png | SolidCraft contributors | Generated from assets/icons/app/shared/source/app_icon.rs with the original CLI/ICO encoders | MIT OR Apache-2.0 || assets/icons/app/linux/exports/hicolor/16x16/apps/io.tangencylabs.solidcraft.png | SolidCraft contributors | Generated from assets/icons/app/shared/source/app_icon.rs with the original CLI/ICO encoders | MIT OR Apache-2.0 || assets/icons/app/linux/exports/hicolor/24x24/apps/io.tangencylabs.solidcraft.png | SolidCraft contributors | Generated from assets/icons/app/shared/source/app_icon.rs with the original CLI/ICO encoders | MIT OR Apache-2.0 |diff --git a/assets/README.md b/assets/README.mdindex 7628444aeb..dbf0fcd745 100644--- a/assets/README.md+++ b/assets/README.md@@ -23,7 +23,7 @@ assets/appearances/library.rs # built-in visual presetsmaterials/library.rs # physical defaults and coloursshaders/viewport.wgsl # original viewport shader- fonts/{liberation-sans,biz-udp-gothic}/ # unmodified fonts and OFL licences+ fonts/biz-udp-gothic/ # unmodified font and OFL licencelocales/{en,de,ja,ko}.json # shared offline catalogsplatforms/{macos,linux,windows}/ # bundle, freedesktop and WiX templatesplatforms/macos/dmg/ # disk image window: layout, dmgbuild settings, background art@@ -87,7 +87,9 @@ The CLI still supports arbitrary PNG/ICO exports with `solidcraft-cli icon`.Resources remain compiled by their owning layer through existing APIs:`ui-egui::icons::paint_icon` and `Tokens` at L5, model presets in L2 `doc`, and sketch-fonts at L1. State, projection, interaction, commands and GPU bindings stay in+fonts at L1. The sketch crate owns its built-in Liberation Sans font and OFL+licence under `crates/sketch/assets/fonts/liberation-sans/`, so Cargo source+packages and vendored builds include both files. State, projection, interaction, commands and GPU bindings stay intheir current modules. Embedded data uses `CARGO_MANIFEST_DIR`; application codeneeds no runtime resource registry or repository lookup.diff --git a/attribution/pending/sketch-packaged-font.md b/attribution/pending/sketch-packaged-font.mdnew file mode 100644index 0000000000..693e19b00b--- /dev/null+++ b/attribution/pending/sketch-packaged-font.md@@ -0,0 +1,2 @@+| crates/sketch/assets/fonts/liberation-sans/LiberationSans-Regular.ttf | Red Hat, Inc. (Liberation Fonts 2.x; digitized data Google) | https://github.com/liberationfonts (Debian fonts-liberation), unmodified; licence text in crates/sketch/assets/fonts/liberation-sans/OFL.txt; used for sketch Text outlines | SIL OFL 1.1 |+| crates/sketch/assets/fonts/liberation-sans/OFL.txt | Red Hat, Inc.; Liberation Fonts contributors | Unmodified accompanying font licence | SIL OFL 1.1 |diff --git a/assets/fonts/liberation-sans/LiberationSans-Regular.ttf b/crates/sketch/assets/fonts/liberation-sans/LiberationSans-Regular.ttfsimilarity index 100%rename from assets/fonts/liberation-sans/LiberationSans-Regular.ttfrename to crates/sketch/assets/fonts/liberation-sans/LiberationSans-Regular.ttfdiff --git a/assets/fonts/liberation-sans/OFL.txt b/crates/sketch/assets/fonts/liberation-sans/OFL.txtsimilarity index 100%rename from assets/fonts/liberation-sans/OFL.txtrename to crates/sketch/assets/fonts/liberation-sans/OFL.txtdiff --git a/crates/sketch/src/font_tests.rs b/crates/sketch/src/font_tests.rsindex 1fd162d899..54c01750c4 100644--- a/crates/sketch/src/font_tests.rs+++ b/crates/sketch/src/font_tests.rs@@ -442,7 +442,7 @@ fn installed_families_are_listed_by_name_once_without_the_built_in_one() {// sorted; the built-in family is not among the installed ones, broken files and other files are skipped.std::fs::write(folder.0.join("copy.ttf"), tiny_font()).unwrap();std::fs::copy(- PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets/fonts/liberation-sans/LiberationSans-Regular.ttf"),+ PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("assets/fonts/liberation-sans/LiberationSans-Regular.ttf"),folder.0.join("lib.ttf"),).unwrap();diff --git a/crates/sketch/src/fonts.rs b/crates/sketch/src/fonts.rsindex 889da62bf3..50fe9e0724 100644--- a/crates/sketch/src/fonts.rs+++ b/crates/sketch/src/fonts.rs@@ -8,7 +8,7 @@ use std::sync::{Arc, Mutex, OnceLock};use crate::model::{Result, SketchError};-static DEFAULT_FONT: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/fonts/liberation-sans/LiberationSans-Regular.ttf"));+static DEFAULT_FONT: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/fonts/liberation-sans/LiberationSans-Regular.ttf"));/// Family name of the built-in font (also what an empty or absent font name means).pub const DEFAULT_FONT_FAMILY: &str = "Liberation Sans";diff --git a/crates/sketch/src/text.rs b/crates/sketch/src/text.rsindex 946a0f18f3..b9101ddc7e 100644--- a/crates/sketch/src/text.rs+++ b/crates/sketch/src/text.rs@@ -3,7 +3,7 @@//! OpenType (CFF) cubic Béziers are cubic control splines, both exact. A glyph's counters (the//! holes of A, B, 8…) are loops inside its outline; profile detection makes them holes.//!-//! The default font is embedded (Liberation Sans, SIL OFL 1.1; see `assets/fonts/liberation-sans/OFL.txt` and+//! The default font is embedded (Liberation Sans, SIL OFL 1.1; see `crates/sketch/assets/fonts/liberation-sans/OFL.txt` and//! ATTRIBUTION.md); [`crate::fonts`] finds others by file path or installed family name. [`TextMetrics`] measures//! text by the rule that draws it. A line with right-to-left characters (Arabic, Hebrew…) is ordered by the//! Unicode bidirectional algorithm and shaped with the font's own rules, so letters join and marks sit where the font@@ -590,7 +590,7 @@ mod tests {#[test]fn a_font_file_gives_the_same_outlines_and_unknown_fonts_are_errors() {- let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../assets/fonts/liberation-sans/LiberationSans-Regular.ttf");+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("assets/fonts/liberation-sans/LiberationSans-Regular.ttf");let by_file = text_geometry_in(Some(&path.to_string_lossy()), "A7_L", Vec2::ZERO, 8.0, 0.0).unwrap();assert_eq!(by_file, text_geometry("A7_L", Vec2::ZERO, 8.0, 0.0).unwrap());let e = text_geometry_in(Some("No Such Family 12345"), "A", Vec2::ZERO, 8.0, 0.0).unwrap_err().to_string();diff --git a/xtask/src/licences.rs b/xtask/src/licences.rsindex 462cab6514..095b8ec3cf 100644--- a/xtask/src/licences.rs+++ b/xtask/src/licences.rs@@ -167,7 +167,7 @@ fn render(root: &Path, crates: &[Crate]) -> String {let font_rule = "=".repeat(80);out += &format!("\n{font_rule}\nBundled fonts (SIL Open Font License, Version 1.1)\n{font_rule}\n\n\- - LiberationSans-Regular.ttf (assets/fonts/liberation-sans/LiberationSans-Regular.ttf)\n \+ - LiberationSans-Regular.ttf (crates/sketch/assets/fonts/liberation-sans/LiberationSans-Regular.ttf)\n \Copyright 2012 Red Hat, Inc. (Liberation Fonts 2.x; digitized data Google)\n \Source: https://github.com/liberationfonts\n\n\- BIZUDPGothic-Regular.ttf (assets/fonts/biz-udp-gothic/BIZUDPGothic-Regular.ttf)\n \@@ -187,7 +187,7 @@ fn render(root: &Path, crates: &[Crate]) -> String {Source: https://github.com/IBM/plex\n\n");let ofl_path = root.join("assets/fonts/biz-udp-gothic/OFL.txt");- let fallback_path = root.join("assets/fonts/liberation-sans/OFL.txt");+ let fallback_path = root.join("crates/sketch/assets/fonts/liberation-sans/OFL.txt");let ofl_text = std::fs::read_to_string(&ofl_path).or_else(|_| std::fs::read_to_string(&fallback_path)).unwrap_or_default();let ofl_clean = ofl_text.replace("\r\n", "\n").trim().to_string();if !ofl_clean.is_empty() {