FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Theme: keep the interface in Inter; Source Sans 3 is an Adobe font (AGENTS.md §1.1)
Brandon Thomas736760752bdf
diff --git a/crates/text/build.rs b/crates/text/build.rsindex be3fb7866..715a8b7df 100644--- a/crates/text/build.rs+++ b/crates/text/build.rs@@ -7,9 +7,8 @@//! empty and nothing else changes. A `CRAFT_FONTS_DIR` that is not a checkout is a warning, or an//! error with `CRAFT_FONTS_REQUIRED=1` (release builds).//!-//! Native builds embed every font. The web (wasm32) build embeds only the UI fonts (BIZ UDPGothic-//! Regular, ~4.5 MB, and Source Sans 3, ~1.3 MB) to stay under the web size budget (Cloudflare serves-//! files up to 25 MiB).+//! Native builds embed every font. The web (wasm32) build embeds only the UI font (BIZ UDPGothic+//! Regular, ~4.5 MB) to stay under the web size budget (Cloudflare serves files up to 25 MiB).//! Only the local directory is read: no network.use std::fmt::Write as _;@@ -48,7 +47,7 @@ fn craft_fonts(dir: &std::path::Path) -> Result<String, String> {let [family, style, file, scripts, ..] = f.as_slice() else {return Err(format!("malformed manifest line: {line}"));};- if wasm && !(*family == "BIZ UDPGothic" && *style == "Regular") && *family != "Source Sans 3" {+ if wasm && !(*family == "BIZ UDPGothic" && *style == "Regular") {continue;}let path = dir.join(file).canonicalize().map_err(|e| format!("{file}: {e}"))?;diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rsindex 22199e313..4de498421 100644--- a/crates/ui-egui/src/theme.rs+++ b/crates/ui-egui/src/theme.rs@@ -1,9 +1,7 @@//! Design tokens. Every widget reads colours/sizes from [`Tokens`] so themes apply everywhere.//!//! The default theme follows the look of Premiere Pro's current dark UI (values measured from-//! black-box screenshots, see `plan/premiere/02-ui-ux.md`); fonts are Inter + JetBrains Mono (OFL), and-//! Source Sans 3 (OFL, the closest open face to Premiere's) for the interface when the app is built-//! with craft-fonts.+//! black-box screenshots, see `plan/premiere/02-ui-ux.md`); fonts are Inter + JetBrains Mono (OFL).use std::sync::Arc;@@ -253,25 +251,14 @@ pub fn menu_style(s: &mut egui::Style) {}}-/// The interface face in craft-fonts: Source Sans 3 (Adobe's open-source sans, SIL OFL; the closest open-/// face to Premiere's interface type, which is not licensable).-pub const UI_FAMILY: &str = "Source Sans 3";--/// The craft-fonts entry of the interface face in `style`; `None` when the app was built without-/// craft-fonts (the interface then stays in Inter).-fn craft_ui_face(style: &str) -> Option<&'static filmcraft_text::fonts::CraftFont> {- filmcraft_text::fonts::CRAFT_FONTS.iter().find(|f| f.family == UI_FAMILY && f.style == style)-}-/// Every font family the theme defines (fallback fonts such as the Japanese fonts are added to each/// of them).pub fn font_families() -> Vec<FontFamily> {vec![FontFamily::Proportional, FontFamily::Monospace, FontFamily::Name("semibold".into()), FontFamily::Name("medium".into())]}-/// Install fonts (Source Sans 3 from craft-fonts when built with `CRAFT_FONTS_DIR`, then Inter, Inter-/// SemiBold, JetBrains Mono, then the Japanese craft-fonts) and egui visuals. Inter stays behind-/// Source Sans 3 for the symbols it lacks.+/// Install fonts (Inter, Inter SemiBold, JetBrains Mono, then the Japanese craft-fonts when built with+/// `CRAFT_FONTS_DIR`) and egui visuals.pub fn install(ctx: &egui::Context, t: &Tokens) {let mut fonts = FontDefinitions::default();fonts.font_data.insert("inter".into(), Arc::new(FontData::from_static(filmcraft_text::fonts::INTER_REGULAR)));@@ -282,14 +269,6 @@ pub fn install(ctx: &egui::Context, t: &Tokens) {fonts.families.entry(FontFamily::Monospace).or_default().insert(0, "jbmono".into());fonts.families.insert(FontFamily::Name("semibold".into()), vec!["inter-semibold".into(), "inter".into()]);fonts.families.insert(FontFamily::Name("medium".into()), vec!["inter-medium".into(), "inter".into()]);- for (family, style) in [("", "Regular"), ("medium", "Medium"), ("semibold", "Semibold")] {- if let Some(f) = craft_ui_face(style) {- let name = format!("ui:{} {}", f.family, f.style);- fonts.font_data.insert(name.clone(), Arc::new(FontData::from_static(f.bytes)));- let family = if family.is_empty() { FontFamily::Proportional } else { FontFamily::Name(family.into()) };- fonts.families.entry(family).or_default().insert(0, name);- }- }add_craft_fonts(&mut fonts);ctx.set_fonts(fonts);apply_visuals(ctx, t);@@ -419,8 +398,7 @@ mod tests {ctx.fonts_mut(|fonts| {let defs = fonts.definitions().clone();assert_eq!(defs.font_data.keys().filter(|k| k.starts_with("craft:")).count(), n);- let ui = if craft_ui_face("Regular").is_some() { "ui:Source Sans 3 Regular" } else { "inter" };- assert_eq!(defs.families[&FontFamily::Proportional].first().map(String::as_str), Some(ui));+ assert_eq!(defs.families[&FontFamily::Proportional].first().map(String::as_str), Some("inter"));assert_eq!(defs.families[&FontFamily::Monospace].first().map(String::as_str), Some("jbmono"));assert!(fonts.has_glyph(&FontId::new(13.0, FontFamily::Proportional), 'A'));if n == 0 {@@ -428,27 +406,4 @@ mod tests {}});}-- /// Built with craft-fonts that carry Source Sans 3: the interface text is set in it, every weight,- /// with Inter right behind it for symbols it lacks.- #[test]- fn interface_face_from_craft_fonts() {- if craft_ui_face("Regular").is_none() {- eprintln!("SKIPPED: built without Source Sans 3 in craft-fonts (set CRAFT_FONTS_DIR to run)");- return;- }- let ctx = installed();- ctx.fonts_mut(|fonts| {- let defs = fonts.definitions().clone();- for (family, first, next) in [- (FontFamily::Proportional, "ui:Source Sans 3 Regular", "inter"),- (FontFamily::Name("medium".into()), "ui:Source Sans 3 Medium", "inter-medium"),- (FontFamily::Name("semibold".into()), "ui:Source Sans 3 Semibold", "inter-semibold"),- ] {- let stack = &defs.families[&family];- assert_eq!(&stack[..2], &[first.to_string(), next.to_string()], "{family:?}: {stack:?}");- }- assert!(fonts.has_glyph(&Tokens::timecode(), '0'));- });- }}