diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9e5501a..cb4ec50b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: uses: storytold/craft-common-actions/.github/workflows/gate.yml@main with: # Same craft-fonts commit as release.yml. - craft-fonts-ref: 3d9ab3a132ed0eff457e424226a435a901da30d3 + craft-fonts-ref: aced4137c022f1f587624d48e81ec77e1914a9cc os: '["ubuntu-24.04","windows-latest"]' toolchain: "1.96.0" packages: >- diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index ae8422b6..9f64bbdd 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -32,5 +32,5 @@ jobs: # Intentionally tracked at @main (not SHA-pinned) so org-wide CI improvements, security fixes, and build optimizations propagate without PR churn across all craftapp repos. uses: storytold/craft-common-actions/.github/workflows/freebsd.yml@main with: - craft-fonts-ref: 3d9ab3a132ed0eff457e424226a435a901da30d3 + craft-fonts-ref: aced4137c022f1f587624d48e81ec77e1914a9cc run-package-check: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c7dcab7a..3ed14bca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: with: app-name: texturecraft app-title: "TextureCraft" - craft-fonts-ref: 3d9ab3a132ed0eff457e424226a435a901da30d3 + craft-fonts-ref: aced4137c022f1f587624d48e81ec77e1914a9cc web-craft-fonts: true version: ${{ inputs.version }} secrets: diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 6cce4af8..af23b7a0 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -33,7 +33,7 @@ These come from Rust crate dependencies (not files in this repository) and keep |---|---|---|---|---| | Phosphor Icons (regular), via the `egui-phosphor` crate (vendored in `vendor/egui-phosphor` for egui 0.37) | Every UI icon (tools, layers, panels) | Phosphor Icons (Helena Zhang, Tobias Fried) | https://phosphoricons.com, https://github.com/amPerl/egui-phosphor | MIT (icons); crate MIT OR Apache-2.0 | | egui default fonts (Ubuntu-Light, Hack, Noto Emoji, emoji-icon-font), via `epaint_default_fonts` | UI text | Canonical / Source Foundry / Google / Jessie Jung | https://github.com/emilk/egui | Ubuntu Font Licence 1.0, MIT + Bitstream Vera License, OFL 1.1, MIT | -| Only in builds made with `CRAFT_FONTS_DIR`: IBM Plex Sans (variable) and IBM Plex Mono Regular (desktop and web), from storytold/craft-fonts' Latin catalog (`crates/ui-egui/build.rs`) | Interface text and values | IBM Corp. | https://github.com/storytold/craft-fonts (pinned sources in its `fonts/latin-manifest.txt` and `ATTRIBUTION.md`) | OFL 1.1 | +| Only in builds made with `CRAFT_FONTS_DIR`: Inter Regular and SemiBold (desktop and web), from storytold/craft-fonts' Latin catalog (`crates/ui-egui/build.rs`) | Interface text | The Inter Project Authors | https://github.com/storytold/craft-fonts (pinned sources in its `fonts/latin-manifest.txt` and `ATTRIBUTION.md`) | OFL 1.1 | | Only in builds made with `CRAFT_FONTS_DIR`: BIZ UDPGothic Regular (desktop and web) and Noto Sans CJK SC Regular (desktop), from storytold/craft-fonts (`crates/ui-egui/build.rs`) | Japanese and Chinese UI text | The BIZ UDGothic Project Authors (Morisawa Inc.); The Noto Project Authors | https://github.com/storytold/craft-fonts (pinned sources in its `fonts/manifest.txt` and `ATTRIBUTION.md`) | OFL 1.1 | Without craft-fonts, Chinese, Japanese and Korean UI text uses the operating system's fonts at run diff --git a/Cargo.lock b/Cargo.lock index f4f81afa..ab888cae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -773,7 +773,7 @@ dependencies = [ "objc2-app-kit 0.3.2", "objc2-foundation 0.3.2", "serde", - "skrifa", + "skrifa 0.44.0", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -1153,7 +1153,7 @@ dependencies = [ "profiling", "self_cell", "serde", - "skrifa", + "skrifa 0.44.0", "smallvec", "unicode-bidi", "unicode-general-category", @@ -1309,9 +1309,9 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "font-types" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c92d9081c7ab3bd83ef1eecdfad090f3d966e3ce74106779664114cfe1a6274" +checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d" dependencies = [ "bytemuck", "serde", @@ -1527,7 +1527,7 @@ dependencies = [ "hashbrown 0.17.1", "log", "peniko", - "skrifa", + "skrifa 0.44.0", "smallvec", "vello_common", ] @@ -1692,7 +1692,7 @@ checksum = "c03d949a14aa089bbb282f7dd76a498a7f684428e4257202efc119ec010376f9" dependencies = [ "bitflags 2.13.2", "bytemuck", - "read-fonts", + "read-fonts 0.41.0", "smallvec", ] @@ -3218,6 +3218,19 @@ dependencies = [ "once_cell", ] +[[package]] +name = "read-fonts" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4edc8db0d972de88e53a085b1f01fb3fbdae7bb0cb7a0ce2b2f8285a412fe3ef" +dependencies = [ + "bytemuck", + "foldhash 0.2.0", + "font-types", + "once_cell", + "yoke", +] + [[package]] name = "reborrow" version = "0.5.5" @@ -3600,6 +3613,18 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" +[[package]] +name = "skera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531045338e36ad05b9652912a47ba38a935d0eaa0293c3e33d8112cfa414c14b" +dependencies = [ + "hashbrown 0.17.1", + "skrifa 0.48.0", + "thiserror 2.0.21", + "write-fonts", +] + [[package]] name = "skrifa" version = "0.44.0" @@ -3607,7 +3632,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68" dependencies = [ "bytemuck", - "read-fonts", + "read-fonts 0.41.0", +] + +[[package]] +name = "skrifa" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5213b4825bac3587046330052d61bfac7bd3bd0d203c758d7c2ef726fcea034" +dependencies = [ + "bytemuck", + "read-fonts 0.45.1", ] [[package]] @@ -3952,6 +3987,8 @@ dependencies = [ "rfd", "serde", "serde_json", + "skera", + "skrifa 0.48.0", "sys-locale", "texturecraft-engine", "texturecraft-render", @@ -5124,6 +5161,17 @@ dependencies = [ "wayland-protocols-wlr", ] +[[package]] +name = "write-fonts" +version = "0.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55716cfa7e8bcdb90289e07dfac478ccb2e3ec0f9a604fe682c7a03a7984d705" +dependencies = [ + "font-types", + "log", + "read-fonts 0.45.1", +] + [[package]] name = "write16" version = "1.0.0" diff --git a/NOTICE b/NOTICE index 21479f10..a6c9da4b 100644 --- a/NOTICE +++ b/NOTICE @@ -21,7 +21,7 @@ Every other bundled asset is original to TextureCraft (generated in code or draw project). Builds made with craft-fonts (CRAFT_FONTS_DIR; all official releases) also embed the fonts listed -in https://github.com/storytold/craft-fonts/blob/main/ATTRIBUTION.md (IBM Plex Sans, IBM Plex Mono +in https://github.com/storytold/craft-fonts/blob/main/ATTRIBUTION.md (Inter and BIZ UDPGothic on desktop and web, Noto Sans CJK SC on desktop), under the SIL Open Font License 1.1. Their licence texts ship with the package as OFL-.txt. diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 1ed4413a..a9f8257e 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -30,6 +30,12 @@ sys-locale = "0.3" # Floating panels open as OS windows. craft-ui = { workspace = true, features = ["native-windows"] } +# build.rs: the interface faces lose their Private Use Area, where the icon font draws (the +# versions craft-libs' craft-fonts-build subsets with). +[build-dependencies] +skera = "0.8" +skrifa = { version = "0.48", default-features = false, features = ["std"] } + # Browser file I/O (web_files.rs): async pickers and Blob downloads. [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = "0.2" diff --git a/crates/ui-egui/build.rs b/crates/ui-egui/build.rs index 9383827c..4888d580 100644 --- a/crates/ui-egui/build.rs +++ b/crates/ui-egui/build.rs @@ -1,7 +1,8 @@ //! Embeds the optional craft-fonts UI fonts (storytold/craft-fonts) when `CRAFT_FONTS_DIR` points -//! at a checkout: IBM Plex Sans and Mono for the interface (from its Latin catalog) and the CJK +//! at a checkout: Inter for the interface (from its Latin catalog) and the CJK //! faces; without it `CRAFT_FONTS` is empty and the UI uses egui's and the system's fonts. The -//! recipe follows craft-fonts' `docs/integration.md`; no font file is committed here. +//! recipe follows craft-fonts' `docs/integration.md`; no font file is committed here. The Latin +//! faces are embedded without their Private Use Area ([`without_private_use`]). use std::fmt::Write as _; use std::path::PathBuf; @@ -10,12 +11,12 @@ use std::path::PathBuf; /// has a download budget: of the CJK faces only the Japanese one, ~4.5 MB). const MANIFESTS: &[(&str, Faces, Faces)] = &[ ("fonts/manifest.txt", &[("BIZ UDPGothic", "Regular"), ("Noto Sans CJK SC", "Regular")], &[("BIZ UDPGothic", "Regular")]), - // The interface font: one variable file for every weight (0.5 MB), and the numbers' face. + // The interface font, regular and semibold (0.8 MB). (LATIN_MANIFEST, LATIN, LATIN), ]; /// Newer than the core catalog: a checkout without it keeps the default interface font. const LATIN_MANIFEST: &str = "fonts/latin-manifest.txt"; -const LATIN: Faces = &[("IBM Plex Sans", "Variable"), ("IBM Plex Mono", "Regular")]; +const LATIN: Faces = &[("Inter", "Regular"), ("Inter", "SemiBold")]; /// (family, style) pairs of a manifest. type Faces = &'static [(&'static str, &'static str)]; @@ -58,8 +59,14 @@ fn craft_fonts(dir: &std::path::Path, rel: &str, desktop: &[(&str, &str)], web: if !wanted.contains(&(*family, *style)) { continue; } - let path = dir.join(file).canonicalize().map_err(|e| format!("{file}: {e}"))?; + let mut path = dir.join(file).canonicalize().map_err(|e| format!("{file}: {e}"))?; println!("cargo::rerun-if-changed={}", path.display()); + if rel == LATIN_MANIFEST { + let bytes = std::fs::read(&path).map_err(|e| format!("{file}: {e}"))?; + let out = PathBuf::from(std::env::var_os("OUT_DIR").unwrap_or_default()).join(path.file_name().unwrap_or_default()); + std::fs::write(&out, without_private_use(&bytes).map_err(|e| format!("{file}: {e}"))?).map_err(|e| format!("{}: {e}", out.display()))?; + path = out; + } let scripts: Vec = scripts.split(',').map(|s| format!("{:?}", s.trim())).collect(); let _ = writeln!( out, @@ -70,3 +77,33 @@ fn craft_fonts(dir: &std::path::Path, rel: &str, desktop: &[(&str, &str)], web: } Ok(out) } + +/// `font` without the characters of the Private Use Area (U+E000–U+F8FF): the icon font (Phosphor) +/// draws there, and Inter, ahead of it in the fallback list, has alternates of its own there that +/// would show instead of the icons. Everything else (layout features, hinting) is kept, as +/// craft-libs' `craft-fonts-build` subsets. +fn without_private_use(font: &[u8]) -> Result, String> { + use skera::{Plan, SubsetFlags, subset_font}; + use skrifa::raw::collections::IntSet; + use skrifa::raw::types::NameId; + use skrifa::{FontRef, GlyphId, MetadataProvider, Tag}; + let font = FontRef::new(font).map_err(|e| e.to_string())?; + let mut unicodes = IntSet::::empty(); + unicodes.extend(font.charmap().mappings().map(|(c, _)| c).filter(|c| !(0xE000..=0xF8FF).contains(c))); + let mut name_ids = IntSet::::empty(); + name_ids.insert_range(NameId::new(0)..=NameId::new(6)); + let mut languages = IntSet::::empty(); + languages.insert(0x0409); + let plan = Plan::new( + &IntSet::::empty(), + &unicodes, + &font, + SubsetFlags::default(), + &IntSet::::empty(), + &IntSet::::all(), + &IntSet::::all(), + &name_ids, + &languages, + ); + subset_font(&font, &plan).map_err(|e| e.to_string()) +} diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index d6d58f2e..b314e4ef 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -99,6 +99,9 @@ pub(crate) fn layers(app: &mut TextureCraftApp, ui: &mut Ui) { let tk = Tokens::get(ui.ctx()); // Wraps in a narrow column instead of widening the rows below past the panel. ui.horizontal_wrapped(|ui| { + // The menu buttons as compact as the icon buttons beside them. + ui.spacing_mut().button_padding.x = 4.0; + ui.spacing_mut().item_spacing.x = 4.0; let chans = app.session.doc.project.texture_set(app.session.ts()).map(|t| t.channel_list()).unwrap_or_default(); egui::ComboBox::from_id_salt("layer_channel").width(86.0).selected_text(tr(app.ui.layer_channel.label())).show_ui(ui, |ui| { for c in chans { diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index dadc7ef4..ed23f88a 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -280,10 +280,10 @@ fn area_id() -> Id { } /// The dock look: every panel group is a card on the window's frame colour, its tab strip -/// without hard lines, the shown tab a pill, titles in the medium weight. +/// without hard lines, the shown tab a pill. fn style(ui: &Ui, t: &Tokens) -> DockStyle { let mut s = DockStyle::from_ui(ui); - s.gap = 6.0; + s.gap = f32::from(crate::theme::GUTTER); // Smallest panel extent a divider drag leaves. s.min_pane = 60.0; s.background = t.panel; @@ -295,7 +295,7 @@ fn style(ui: &Ui, t: &Tokens) -> DockStyle { s.accent = t.accent; s.floating_background = t.panel; s.floating_stroke = egui::Stroke::new(1.0, t.button_border); - s.font = crate::theme::medium(12.5); + s.font = egui::FontId::proportional(12.5); s.min_tab_width = 54.0; s.tab_height = 30.0; // Panels arrange in a split tree around the viewport; floating title bars only move windows. diff --git a/crates/ui-egui/src/fonts.rs b/crates/ui-egui/src/fonts.rs index 2170fd70..cba9733b 100644 --- a/crates/ui-egui/src/fonts.rs +++ b/crates/ui-egui/src/fonts.rs @@ -138,12 +138,7 @@ impl UiFonts { let Some(data) = self.data(*s) else { continue }; let name = format!("cjk-{}", s.iso()); defs.font_data.insert(name.clone(), data); - for family in [ - FontFamily::Proportional, - FontFamily::Monospace, - FontFamily::Name(crate::theme::MEDIUM.into()), - FontFamily::Name(crate::theme::SEMIBOLD.into()), - ] { + for family in [FontFamily::Proportional, FontFamily::Monospace, FontFamily::Name(crate::theme::SEMIBOLD.into())] { defs.families.entry(family).or_default().push(name.clone()); } } diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 28b33de8..ae3d7083 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -398,12 +398,10 @@ impl eframe::App for TextureCraftApp { toolbar::rail(self, ui); } let hide = self.ui.hide_ui; - egui::CentralPanel::default() - .frame(egui::Frame::NONE.fill({ - let tk = theme::Tokens::get(&ctx); - if hide { tk.viewport } else { tk.chrome } - })) - .show(ui, |ui| if hide { viewport::central(self, ui) } else { docking::show(self, ui) }); + let tk = theme::Tokens::get(&ctx); + // The dock keeps the cards' gutter from the bars and rails around it. + let frame = if hide { egui::Frame::NONE.fill(tk.viewport) } else { egui::Frame::NONE.fill(tk.chrome).inner_margin(theme::GUTTER) }; + egui::CentralPanel::default().frame(frame).show(ui, |ui| if hide { viewport::central(self, ui) } else { docking::show(self, ui) }); windows::show(self, &ctx); toasts(self, &ctx); let end = now_ms(); @@ -441,19 +439,22 @@ pub fn now_ms() -> f64 { fn banner(app: &mut TextureCraftApp, ui: &mut egui::Ui) { let Some(text) = app.banner else { return }; let tk = theme::Tokens::get(ui.ctx()); - egui::Panel::top("banner").frame(egui::Frame::NONE.fill(tk.row_selected).inner_margin(egui::Margin::symmetric(10, 5))).show(ui, |ui| { - ui.horizontal(|ui| { - ui.label(egui::RichText::new(egui_phosphor::regular::INFO).color(tk.accent)); - // The text wraps in the width the dismiss button leaves. - let width = (ui.available_width() - 28.0).max(80.0); - ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| { - ui.add(egui::Label::new(egui::RichText::new(i18n::tr(text)).color(tk.text_strong)).wrap()); + egui::Panel::top("banner").show_separator_line(false).frame(egui::Frame::NONE.fill(tk.row_selected).inner_margin(egui::Margin::symmetric(10, 5))).show( + ui, + |ui| { + ui.horizontal(|ui| { + ui.label(egui::RichText::new(egui_phosphor::regular::INFO).color(tk.accent)); + // The text wraps in the width the dismiss button leaves. + let width = (ui.available_width() - 28.0).max(80.0); + ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| { + ui.add(egui::Label::new(egui::RichText::new(i18n::tr(text)).color(tk.text_strong)).wrap()); + }); + if widgets::icon_button(ui, egui_phosphor::regular::X, i18n::tr("Dismiss"), false, 18.0).clicked() { + app.banner = None; + } }); - if widgets::icon_button(ui, egui_phosphor::regular::X, i18n::tr("Dismiss"), false, 18.0).clicked() { - app.banner = None; - } - }); - }); + }, + ); } fn toasts(app: &mut TextureCraftApp, ctx: &egui::Context) { diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index 62c7a122..fd2898b0 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -258,11 +258,15 @@ impl Tokens { } } -/// The corner radius of [`card`]s. +/// The corner radius of floating windows and menus. pub const CARD_RADIUS: u8 = 8; +/// The window-frame gap between neighbouring cards and dock groups (the dock's own gap). +pub const GUTTER: i8 = 6; + /// The tool bar, the tool shelf, the rail and side panels are cards: `body` drawn `padding` inside -/// the panel colour with soft corners, `margin` of the window's frame colour around it. +/// the panel colour, `margin` of the window's frame colour around it. Square like the dock's +/// groups, so the frame reads as one set of tiles with even gutters. pub fn card(ui: &mut egui::Ui, t: &Tokens, margin: egui::Margin, padding: egui::Margin, body: impl FnOnce(&mut egui::Ui) -> R) -> R { egui::Frame::NONE .fill(t.chrome) @@ -270,7 +274,6 @@ pub fn card(ui: &mut egui::Ui, t: &Tokens, margin: egui::Margin, padding: egu .show(ui, |ui| { egui::Frame::NONE .fill(t.panel) - .corner_radius(CARD_RADIUS) .inner_margin(padding) .show(ui, |ui| { ui.set_min_size(ui.available_size()); @@ -281,55 +284,39 @@ pub fn card(ui: &mut egui::Ui, t: &Tokens, margin: egui::Margin, padding: egu .inner } -/// Interface text in the medium weight (500): titles of panels, sections and dialogs. -pub fn medium(size: f32) -> FontId { - FontId::new(size, FontFamily::Name(MEDIUM.into())) -} - -/// Interface text in the semibold weight (600): headings and emphasis. +/// Interface text in the semibold weight: headings and window titles. pub fn semibold(size: f32) -> FontId { FontId::new(size, FontFamily::Name(SEMIBOLD.into())) } -/// The weight families: the interface font at 500 and 600, the regular font without it. -pub(crate) const MEDIUM: &str = "ui-medium"; +/// The semibold family: Inter SemiBold, the regular font without it. pub(crate) const SEMIBOLD: &str = "ui-semibold"; -/// The app's fonts: IBM Plex Sans (regular, medium, semibold from one variable file) and Plex Mono -/// when built with craft-fonts, egui's defaults otherwise, and the Phosphor icon font -/// (`fonts::UiFonts` adds CJK). +/// The app's fonts: Inter (regular and semibold) when built with craft-fonts, egui's defaults +/// otherwise, egui's monospace face for values, and the Phosphor icon font (`fonts::UiFonts` +/// adds CJK). pub fn font_definitions() -> egui::FontDefinitions { use std::sync::Arc; let mut fonts = egui::FontDefinitions::default(); - let face = |family: &str, style: &str| crate::fonts::CRAFT_FONTS.iter().find(|f| f.family == family && f.style == style && !f.bytes.is_empty()); - let mut weights: Vec<&str> = Vec::new(); - if let Some(sans) = face("IBM Plex Sans", "Variable") { - for (name, wght) in [("plex-sans", 400.0), ("plex-sans-500", 500.0), ("plex-sans-600", 600.0)] { - let mut data = egui::FontData::from_static(sans.bytes); - data.tweak.coords = egui::epaint::text::VariationCoords::new([(b"wght", wght)]); - fonts.font_data.insert(name.into(), Arc::new(data)); - weights.push(name); - } + let face = |style: &str| crate::fonts::CRAFT_FONTS.iter().find(|f| f.family == "Inter" && f.style == style && !f.bytes.is_empty()); + // Inter is drawn a little under its size, as in VectorCraft: its letters are wide. + let inter = |bytes: &'static [u8]| Arc::new(egui::FontData::from_static(bytes).tweak(egui::FontTweak { scale: 0.92, ..Default::default() })); + let mut semibold = None; + if let (Some(regular), Some(bold)) = (face("Regular"), face("SemiBold")) { + fonts.font_data.insert("inter".into(), inter(regular.bytes)); + fonts.font_data.insert("inter-semibold".into(), inter(bold.bytes)); if let Some(list) = fonts.families.get_mut(&FontFamily::Proportional) { - list.insert(0, "plex-sans".into()); - } - } - if let Some(mono) = face("IBM Plex Mono", "Regular") { - fonts.font_data.insert("plex-mono".into(), Arc::new(egui::FontData::from_static(mono.bytes))); - if let Some(list) = fonts.families.get_mut(&FontFamily::Monospace) { - list.insert(0, "plex-mono".into()); + list.insert(0, "inter".into()); } + semibold = Some("inter-semibold"); } egui_phosphor::add_to_fonts(&mut fonts, egui_phosphor::Variant::Regular); - // The weight families: the regular family with its first face swapped for the weight. - let regular = fonts.families.get(&FontFamily::Proportional).cloned().unwrap_or_default(); - for (family, weight) in [(MEDIUM, weights.get(1)), (SEMIBOLD, weights.get(2))] { - let mut list = regular.clone(); - if let (Some(w), Some(first)) = (weight, list.first_mut()) { - *first = (*w).to_string(); - } - fonts.families.insert(FontFamily::Name(family.into()), list); + // The semibold family: the regular family with its first face swapped for the weight. + let mut list = fonts.families.get(&FontFamily::Proportional).cloned().unwrap_or_default(); + if let (Some(w), Some(first)) = (semibold, list.first_mut()) { + *first = w.to_string(); } + fonts.families.insert(FontFamily::Name(SEMIBOLD.into()), list); fonts } @@ -344,14 +331,14 @@ pub fn apply(ctx: &egui::Context, b: Brightness, accent: Accent) { let t = Tokens::for_brightness(b).with_accent(accent); ctx.data_mut(|d| d.insert_temp(egui::Id::NULL, t)); ctx.all_styles_mut(|s| { - // One type scale: 11 small print, 12.5 body and controls, 14 headings (semibold), and - // values in the monospace face. + // VectorCraft's type scale: 11 small print, 13 body and controls, 15 headings (semibold), + // 11.5 values in the monospace face. s.text_styles = [ (TextStyle::Small, FontId::new(11.0, FontFamily::Proportional)), - (TextStyle::Body, FontId::new(12.5, FontFamily::Proportional)), - (TextStyle::Button, FontId::new(12.5, FontFamily::Proportional)), - (TextStyle::Heading, semibold(14.0)), - (TextStyle::Monospace, FontId::new(12.0, FontFamily::Monospace)), + (TextStyle::Body, FontId::new(13.0, FontFamily::Proportional)), + (TextStyle::Button, FontId::new(13.0, FontFamily::Proportional)), + (TextStyle::Heading, semibold(15.0)), + (TextStyle::Monospace, FontId::new(11.5, FontFamily::Monospace)), ] .into(); // A 2-4-6-8-12 spacing scale: 6 between items, 4 between rows, controls 24 high. @@ -375,7 +362,9 @@ pub fn apply(ctx: &egui::Context, b: Brightness, accent: Accent) { v.popup_shadow = egui::epaint::Shadow { offset: [0, 4], blur: 14, spread: 0, color: Color32::from_black_alpha(if t.dark { 120 } else { 60 }) }; v.window_shadow = egui::epaint::Shadow { offset: [0, 8], blur: 28, spread: 0, color: Color32::from_black_alpha(if t.dark { 140 } else { 70 }) }; v.selection.bg_fill = t.accent_dim; - v.selection.stroke = Stroke::new(1.0, t.accent); + // Selected options and selected text are lettered in the strong colour: the accent on its + // own tint is hard to read. + v.selection.stroke = Stroke::new(1.0, t.text_strong); v.hyperlink_color = t.accent; let w = &mut v.widgets; craft_ui::theme::WidgetPalette { noninteractive: t.panel, inactive: t.button, hovered: t.row_hover, active: t.tool_active, open: t.row_hover } @@ -394,9 +383,9 @@ pub fn apply(ctx: &egui::Context, b: Brightness, accent: Accent) { }); } -/// A section caption inside a panel: medium weight, strong colour, as written (no capitals). +/// A section caption inside a panel: semibold in the strong colour, as written (no capitals). pub fn caption(text: &str) -> egui::RichText { - egui::RichText::new(text).font(medium(12.5)).strong() + egui::RichText::new(text).font(semibold(12.5)).strong() } #[cfg(test)] @@ -439,6 +428,7 @@ mod tests { assert!(contrast(t.text, t.panel) >= 7.0, "{b:?}: text on panel"); assert!(contrast(t.text_dim, t.panel) >= 4.5, "{b:?}: dim text on panel"); assert!(contrast(t.text, t.row_selected) >= 4.5, "{b:?} {a:?}: text on a selected row"); + assert!(contrast(t.text_strong, t.accent_dim) >= 4.5, "{b:?} {a:?}: a selected option's lettering"); assert!(contrast(t.danger, t.panel) >= 3.0 && contrast(t.warning, t.panel) >= 3.0, "{b:?}: warnings on panel"); assert!(contrast(t.accent, t.panel) >= 2.5, "{b:?} {a:?}: accent on panel"); assert!(contrast(Color32::WHITE, t.accent_strong) >= 2.5, "{b:?} {a:?}: white on accent button"); diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 1635da6a..03ef13d0 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -11,7 +11,7 @@ use crate::docking::Panel; use crate::i18n::{tr, trf}; use crate::keymap::tip; use crate::state::{Mode, ViewLayout}; -use crate::theme::{Tokens, card}; +use crate::theme::{GUTTER, Tokens, card}; use crate::widgets::{bar_slider, icon_button}; pub fn tool_icon(t: Tool) -> &'static str { @@ -30,8 +30,8 @@ pub fn tool_icon(t: Tool) -> &'static str { pub fn top_bar(app: &mut TextureCraftApp, ui: &mut egui::Ui) { let tk = Tokens::get(ui.ctx()); - egui::Panel::top("tool_bar").exact_size(40.0).frame(egui::Frame::NONE).show(ui, |ui| { - card(ui, &tk, egui::Margin { left: 6, right: 6, top: 6, bottom: 0 }, egui::Margin::symmetric(8, 0), |ui| { + egui::Panel::top("tool_bar").exact_size(40.0).show_separator_line(false).frame(egui::Frame::NONE).show(ui, |ui| { + card(ui, &tk, egui::Margin { left: GUTTER, right: GUTTER, top: GUTTER, bottom: 0 }, egui::Margin::symmetric(8, 0), |ui| { ui.horizontal_centered(|ui| { ui.spacing_mut().item_spacing.x = 10.0; if app.ui.mode == Mode::Baking { @@ -166,8 +166,8 @@ pub fn path_controls(app: &mut TextureCraftApp, ui: &mut egui::Ui) { pub fn tool_shelf(app: &mut TextureCraftApp, ui: &mut egui::Ui) { let tk = Tokens::get(ui.ctx()); - egui::Panel::left("tool_shelf").resizable(false).exact_size(40.0).frame(egui::Frame::NONE).show(ui, |ui| { - card(ui, &tk, egui::Margin { left: 6, right: 0, top: 6, bottom: 6 }, egui::Margin::symmetric(3, 6), |ui| { + egui::Panel::left("tool_shelf").resizable(false).exact_size(40.0).show_separator_line(false).frame(egui::Frame::NONE).show(ui, |ui| { + card(ui, &tk, egui::Margin { left: GUTTER, right: 0, top: GUTTER, bottom: GUTTER }, egui::Margin::symmetric(3, 6), |ui| { ui.spacing_mut().item_spacing.y = 3.0; let painting = app.ui.mode == Mode::Painting; for t in Tool::ALL { @@ -211,8 +211,8 @@ pub fn tool_shelf(app: &mut TextureCraftApp, ui: &mut egui::Ui) { pub fn rail(app: &mut TextureCraftApp, ui: &mut egui::Ui) { let tk = Tokens::get(ui.ctx()); - egui::Panel::right("rail").resizable(false).exact_size(38.0).frame(egui::Frame::NONE).show(ui, |ui| { - card(ui, &tk, egui::Margin { left: 0, right: 6, top: 6, bottom: 6 }, egui::Margin::symmetric(3, 6), |ui| { + egui::Panel::right("rail").resizable(false).exact_size(38.0).show_separator_line(false).frame(egui::Frame::NONE).show(ui, |ui| { + card(ui, &tk, egui::Margin { left: 0, right: GUTTER, top: GUTTER, bottom: GUTTER }, egui::Margin::symmetric(3, 6), |ui| { ui.spacing_mut().item_spacing.y = 4.0; if icon_button(ui, ic::EXPORT, &tip(&app.ui.keymap, tr("Export textures"), "ui.export"), app.ui.windows.export, 26.0).clicked() { app.ui.windows.export = !app.ui.windows.export; @@ -233,47 +233,51 @@ pub fn rail(app: &mut TextureCraftApp, ui: &mut egui::Ui) { pub fn status_bar(app: &mut TextureCraftApp, ui: &mut egui::Ui) { let tk = Tokens::get(ui.ctx()); - egui::Panel::bottom("status_bar").exact_size(22.0).frame(egui::Frame::NONE.fill(tk.chrome).inner_margin(egui::Margin::symmetric(10, 0))).show(ui, |ui| { - ui.horizontal_centered(|ui| { - if let Some(p) = app.bake_progress() { - ui.add(egui::ProgressBar::new(p).desired_width(160.0).desired_height(10.0).text(RichText::new(tr("Baking")).size(10.0))); - if ui.small_button(tr("Cancel")).clicked() { - app.cancel_bake(); + egui::Panel::bottom("status_bar") + .exact_size(22.0) + .show_separator_line(false) + .frame(egui::Frame::NONE.fill(tk.chrome).inner_margin(egui::Margin::symmetric(10, 0))) + .show(ui, |ui| { + ui.horizontal_centered(|ui| { + if let Some(p) = app.bake_progress() { + ui.add(egui::ProgressBar::new(p).desired_width(160.0).desired_height(10.0).text(RichText::new(tr("Baking")).size(10.0))); + if ui.small_button(tr("Cancel")).clicked() { + app.cancel_bake(); + } + } else if let Some(job) = &app.resize { + let bar = egui::ProgressBar::new(job.progress.fraction()).desired_width(160.0).desired_height(10.0); + ui.add(bar.animate(true).text(RichText::new(tr("Resizing")).size(10.0))); + } else if let Some(p) = app.gpu.as_ref().and_then(|g| g.composite_progress(&app.session)) { + ui.add(egui::ProgressBar::new(p).desired_width(160.0).desired_height(10.0).text(RichText::new(tr("Compositing")).size(10.0))); + ui.ctx().request_repaint(); + } else if let Some(msg) = app.session.log.last() { + ui.label(RichText::new(msg).size(11.0).color(tk.text_dim)); } - } else if let Some(job) = &app.resize { - let bar = egui::ProgressBar::new(job.progress.fraction()).desired_width(160.0).desired_height(10.0); - ui.add(bar.animate(true).text(RichText::new(tr("Resizing")).size(10.0))); - } else if let Some(p) = app.gpu.as_ref().and_then(|g| g.composite_progress(&app.session)) { - ui.add(egui::ProgressBar::new(p).desired_width(160.0).desired_height(10.0).text(RichText::new(tr("Compositing")).size(10.0))); - ui.ctx().request_repaint(); - } else if let Some(msg) = app.session.log.last() { - ui.label(RichText::new(msg).size(11.0).color(tk.text_dim)); - } - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - let gpu = app.gpu.as_ref().map(|g| g.adapter.as_str()).unwrap_or(tr("no GPU")); - ui.label( - RichText::new(trf("Version: {version} ({gpu})", &[("version", &texturecraft_engine::VERSION), ("gpu", &gpu)])) - .size(11.0) - .color(tk.text_dim), - ); - ui.separator(); - let m = app.session.memory(); - let mb = |b: usize| b as f64 / (1024.0 * 1024.0); - let total = mb(m.total()); - let decimals = if total < 10.0 { 1 } else { 0 }; - let mb1 = |b: usize| format!("{:.1}", mb(b)); - ui.label(RichText::new(trf("Layer memory: {mb} MB", &[("mb", &format!("{total:.decimals$}"))])).size(11.0).color(tk.text_dim)).on_hover_ui( - |ui| { - ui.label(trf( - "Painted layer pixels {pixels} MB, composited channels {composites} MB, compositing cache {cache} MB", - &[("pixels", &mb1(m.pixels)), ("composites", &mb1(m.composites)), ("cache", &mb1(m.cache))], - )); - }, - ); - ui.separator(); - ui.label(RichText::new(trf("UI {ms} ms", &[("ms", &format!("{:.1}", app.ui_ms))])).size(11.0).color(tk.text_dim)); - ui.add_space(vec2(0.0, 0.0).x); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + let gpu = app.gpu.as_ref().map(|g| g.adapter.as_str()).unwrap_or(tr("no GPU")); + ui.label( + RichText::new(trf("Version: {version} ({gpu})", &[("version", &texturecraft_engine::VERSION), ("gpu", &gpu)])) + .size(11.0) + .color(tk.text_dim), + ); + ui.separator(); + let m = app.session.memory(); + let mb = |b: usize| b as f64 / (1024.0 * 1024.0); + let total = mb(m.total()); + let decimals = if total < 10.0 { 1 } else { 0 }; + let mb1 = |b: usize| format!("{:.1}", mb(b)); + ui.label(RichText::new(trf("Layer memory: {mb} MB", &[("mb", &format!("{total:.decimals$}"))])).size(11.0).color(tk.text_dim)).on_hover_ui( + |ui| { + ui.label(trf( + "Painted layer pixels {pixels} MB, composited channels {composites} MB, compositing cache {cache} MB", + &[("pixels", &mb1(m.pixels)), ("composites", &mb1(m.composites)), ("cache", &mb1(m.cache))], + )); + }, + ); + ui.separator(); + ui.label(RichText::new(trf("UI {ms} ms", &[("ms", &format!("{:.1}", app.ui_ms))])).size(11.0).color(tk.text_dim)); + ui.add_space(vec2(0.0, 0.0).x); + }); }); }); - }); } diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 27de96d2..e91fa553 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -32,7 +32,7 @@ pub fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { /// A titled tool window; `id` keeps its place across UI languages. pub(crate) fn window<'a>(id: &str, title: &str, open: &'a mut bool) -> egui::Window<'a> { - egui::Window::new(RichText::new(title).font(crate::theme::medium(13.0)).strong()) + egui::Window::new(RichText::new(title).font(crate::theme::semibold(13.0)).strong()) .id(egui::Id::unique(id)) .open(open) .resizable(true) @@ -513,8 +513,14 @@ pub(crate) fn log(app: &mut TextureCraftApp, ui: &mut Ui) { pub fn bake_left(app: &mut TextureCraftApp, ui: &mut Ui) { let tk = Tokens::get(ui.ctx()); - egui::Panel::left("bake_left").resizable(true).default_size(320.0).frame(egui::Frame::NONE).show(ui, |ui| { - crate::theme::card(ui, &tk, egui::Margin { left: 6, right: 0, top: 6, bottom: 6 }, egui::Margin::symmetric(8, 6), |ui| bake_body(app, ui)); + egui::Panel::left("bake_left").resizable(true).default_size(320.0).show_separator_line(false).frame(egui::Frame::NONE).show(ui, |ui| { + crate::theme::card( + ui, + &tk, + egui::Margin { left: crate::theme::GUTTER, right: 0, top: crate::theme::GUTTER, bottom: crate::theme::GUTTER }, + egui::Margin::symmetric(8, 6), + |ui| bake_body(app, ui), + ); }); } diff --git a/docs/releasing.md b/docs/releasing.md index f96bbe31..c387a5f3 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -108,7 +108,7 @@ All file names are `texturecraft---.`, written to | Web | `texturecraft-web-.zip` (trunk, `wasm-release` profile; hosting notes in `packaging/web/README.md`) | `packaging/web/package.sh` | Every desktop package ships both binaries, `texturecraft` and `texturecraft-cli` (on macOS the CLI -is its own zip next to the DMG). Release builds embed the craft-fonts CJK UI fonts +is its own zip next to the DMG). Release builds embed the craft-fonts interface font (Inter) and CJK UI fonts (`CRAFT_FONTS_REF` in `release.yml`) and ship their `OFL-.txt` licences with the other notices. The packaging scripts smoke-test `texturecraft-cli --version`, and the Linux job also runs the AppImage with diff --git a/packaging/env.sh b/packaging/env.sh index fad5ec6c..4fe93776 100644 --- a/packaging/env.sh +++ b/packaging/env.sh @@ -52,7 +52,7 @@ copy_docs() { done # Licences of the craft-fonts faces crates/ui-egui/build.rs embeds (release builds set CRAFT_FONTS_DIR). if [ -n "${CRAFT_FONTS_DIR:-}" ]; then - for f in ibm-plex-sans ibm-plex-mono biz-ud-pgothic noto-sans-cjk-sc; do + for f in inter biz-ud-pgothic noto-sans-cjk-sc; do if [ -f "$CRAFT_FONTS_DIR/fonts/$f/OFL.txt" ]; then cp "$CRAFT_FONTS_DIR/fonts/$f/OFL.txt" "$dest/OFL-$f.txt"; fi done fi diff --git a/packaging/windows/package.ps1 b/packaging/windows/package.ps1 index 249b22a3..a5241d21 100644 --- a/packaging/windows/package.ps1 +++ b/packaging/windows/package.ps1 @@ -115,7 +115,7 @@ foreach ($f in 'README.md', 'LICENSE-MIT', 'LICENSE-APACHE', 'NOTICE', 'ATTRIBUT } # Licences of the craft-fonts faces crates/ui-egui/build.rs embeds (release builds set CRAFT_FONTS_DIR). if ($env:CRAFT_FONTS_DIR) { - foreach ($f in 'ibm-plex-sans', 'ibm-plex-mono', 'biz-ud-pgothic', 'noto-sans-cjk-sc') { + foreach ($f in 'inter', 'biz-ud-pgothic', 'noto-sans-cjk-sc') { $p = Join-Path $env:CRAFT_FONTS_DIR "fonts\$f\OFL.txt" if (Test-Path $p) { Copy-Item $p (Join-Path $Portable "OFL-$f.txt") } }