Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(text): embed the offered fonts so the render matches the picker
EtienneLescot5cd57f936e05
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.mdindex d53cfc019..dcbc432cf 100644--- a/THIRD-PARTY-NOTICES.md+++ b/THIRD-PARTY-NOTICES.md@@ -123,6 +123,30 @@ distributed by their own registries, not redistributed inside our binaries.so nothing of PipeWire's ships inside our installers beyond the compiledresult of its headers (inline functions and struct layouts).+## Fonts — Inter, Lora, Oswald, Caveat, IBM Plex Mono++- **Components**: the Regular and Bold `.ttf` of each family, under+ `resources/fonts/`.+- **Used by**: the native compositor, which draws captions and annotations with+ these files and nothing else (it registers them privately at start and never+ reads the fonts installed on the machine), and the editor's font picker.+- **License**: **SIL Open Font License 1.1** — <https://openfontlicense.org>.+ Each family's copyright notice and licence text ship beside its files as+ `<Family>-OFL.txt`, as the licence requires.+- **Unmodified**: every file is redistributed exactly as upstream publishes it,+ which is also why the Reserved Font Names "Lora" and "Plex" are kept.+- **Upstream**:+ - Inter — Copyright 2016 The Inter Project Authors. `extras/ttf/` of the v4.1+ release, <https://github.com/rsms/inter/releases/tag/v4.1>.+ - Lora 3.021 — Copyright 2011 The Lora Project Authors. `fonts/ttf/` of+ <https://github.com/cyrealtype/Lora-Cyrillic> at `2d53b449b6`.+ - Oswald 4.103 — Copyright 2016 The Oswald Project Authors. `fonts/ttf/` of+ <https://github.com/googlefonts/OswaldFont> at `89795261ac`.+ - Caveat 2.000 — Copyright 2014 The Caveat Project Authors. `fonts/ttf/` of+ <https://github.com/googlefonts/caveat> at `59745e818e`.+ - IBM Plex Mono 2.3 — Copyright © 2017 IBM Corp. `ofl/ibmplexmono/` of+ <https://github.com/google/fonts> at `23e54b51dd`.+## OpenScreen native helpers`wgc-capture` (Windows Graphics Capture), the ScreenCaptureKit helper (macOS),diff --git a/crates/compositor/src/lib.rs b/crates/compositor/src/lib.rsindex ed0222a43..e8c97bf13 100644--- a/crates/compositor/src/lib.rs+++ b/crates/compositor/src/lib.rs@@ -50,6 +50,7 @@ pub mod scene;// indépendant du choix de packaging d'ONNX Runtime.pub mod segmentation;pub mod text_anim;+pub mod text_fonts;pub mod text_plate;pub(crate) mod timeline_walk;diff --git a/crates/compositor/src/text_fonts.rs b/crates/compositor/src/text_fonts.rsnew file mode 100644index 000000000..3241b6fcd--- /dev/null+++ b/crates/compositor/src/text_fonts.rs@@ -0,0 +1,100 @@+//! Les polices du texte (sous-titres et annotations) : celles que l'app embarque, et elles seules.+//!+//! Les trois backends cherchaient la famille demandée parmi les polices INSTALLÉES sur la+//! machine, alors que l'app proposait des familles qu'elle n'installait nulle part. Sur une+//! machine qui ne les avait pas, chaque choix retombait sur la même police de repli, et changer+//! de police ne changeait rien à l'écran.+//!+//! Les fichiers vivent dans `public/fonts`. L'app pose `OPENSCREEN_FONTS_DIR` sur leur dossier+//! avant de charger l'addon (`compositorViewService.ts`, même contrat que `ORT_DYLIB_PATH`), et+//! chaque backend les enregistre pour ce processus seulement, sans rien installer : collection+//! privée pour DirectWrite, portée processus pour CoreText, base `fontdb` pour cosmic-text.+//! Sur macOS et Linux, une police installée qui porte le même nom peut passer devant la nôtre :+//! c'est alors la même famille dans une autre version, jamais un repli.+//!+//! Sans la variable (POC, addon chargé hors de l'app), la liste est vide et le texte se dessine+//! avec les polices du système, comme avant.++use std::path::{Path, PathBuf};++/// Posée par l'app : le dossier des polices embarquées.+pub const FONTS_DIR_ENV: &str = "OPENSCREEN_FONTS_DIR";++/// Les fichiers de police embarqués, ou aucun si l'app n'a pas indiqué leur dossier.+pub fn embedded_font_files() -> Vec<PathBuf> {+ std::env::var_os(FONTS_DIR_ENV)+ .map(|dir| font_files_in(Path::new(&dir)))+ .unwrap_or_default()+}++/// Les `.ttf` et `.otf` de `dir`, triés. Le dossier porte aussi les licences OFL, qui ne sont+/// pas des polices. Un dossier illisible donne une liste vide : mieux vaut les polices du+/// système que pas de texte du tout.+pub fn font_files_in(dir: &Path) -> Vec<PathBuf> {+ let mut files: Vec<PathBuf> = std::fs::read_dir(dir)+ .into_iter()+ .flatten()+ .flatten()+ .map(|entry| entry.path())+ .filter(|path| {+ let ext = path.extension().and_then(|ext| ext.to_str()).unwrap_or_default();+ ext.eq_ignore_ascii_case("ttf") || ext.eq_ignore_ascii_case("otf")+ })+ .collect();+ files.sort();+ files+}++/// `public/fonts` du dépôt, pour les tests des trois backends.+#[cfg(test)]+pub(crate) fn repo_fonts_dir() -> PathBuf {+ Path::new(env!("CARGO_MANIFEST_DIR")).join("../../public/fonts")+}++/// Les familles embarquées, telles que l'app les stocke. Miroir de `TEXT_FONT_FAMILIES`+/// (`src/lib/textFonts.ts`), dont le test vérifie que chaque fichier porte bien ce nom.+#[cfg(test)]+pub(crate) const SHIPPED_FAMILIES: [&str; 5] =+ ["Inter", "Lora", "Oswald", "Caveat", "IBM Plex Mono"];++/// Chaque famille se voit : deux familles se confondent quand elles dessinent le même bloc,+/// même largeur ET même hauteur à 2 % près, et un repli commun les confondrait toutes. La+/// largeur seule ne suffit pas : Inter et Lora ne diffèrent que d'1 % sur « Hamburgefonstiv ».+#[cfg(test)]+pub(crate) fn assert_distinct_blocks(blocks: &[(&str, f32, f32)]) {+ let close = |a: f32, b: f32| (a - b).abs() <= a.min(b) * 0.02;+ for (i, (a, wa, ha)) in blocks.iter().enumerate() {+ for (b, wb, hb) in &blocks[i + 1..] {+ assert!(+ !(close(*wa, *wb) && close(*ha, *hb)),+ "{a} et {b} dessinent le même bloc : {blocks:?}"+ );+ }+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn only_the_font_files_of_the_directory_are_registered() {+ let dir = repo_fonts_dir();+ let files = font_files_in(&dir);+ // Régulier et gras de chaque famille : les deux graisses qu'un contrôle peut produire.+ assert_eq!(files.len(), SHIPPED_FAMILIES.len() * 2, "{files:?}");+ assert!(files.iter().all(|f| f.extension().is_some_and(|e| e == "ttf")));+ // Les licences sont bien là, et bien écartées.+ let licences = std::fs::read_dir(&dir)+ .unwrap()+ .flatten()+ .filter(|e| e.path().extension().is_some_and(|x| x == "txt"))+ .count();+ assert_eq!(licences, SHIPPED_FAMILIES.len());+ }++ #[test]+ fn a_missing_directory_means_system_fonts_not_a_failure() {+ assert!(font_files_in(Path::new("/definitely/not/a/fonts/dir")).is_empty());+ }+}diff --git a/crates/compositor/src/text_linux.rs b/crates/compositor/src/text_linux.rsindex 34bac45e1..ad96934f7 100644--- a/crates/compositor/src/text_linux.rs+++ b/crates/compositor/src/text_linux.rs@@ -111,10 +111,23 @@ pub struct TextRasterizer {swash_cache: RefCell<SwashCache>,}+/// Ajoute `files` (`crate::text_fonts`) a la base `fontdb` de ce rasteriseur, sans rien+/// installer sur la machine. Un fichier illisible ne coute que sa police : le texte retombe+/// sur celles du systeme.+fn load_fonts(font_system: &mut FontSystem, files: &[std::path::PathBuf]) {+ for path in files {+ if let Err(e) = font_system.db_mut().load_font_file(path) {+ eprintln!("[text] police non chargee ({e}) : {}", path.display());+ }+ }+}+impl TextRasterizer {pub fn new() -> Result<TextRasterizer> {+ let mut font_system = FontSystem::new();+ load_fonts(&mut font_system, &crate::text_fonts::embedded_font_files());Ok(TextRasterizer {- font_system: RefCell::new(FontSystem::new()),+ font_system: RefCell::new(font_system),swash_cache: RefCell::new(SwashCache::new()),})}@@ -436,6 +449,49 @@ mod tests {.collect()}+ /// Chaque famille embarquee est celle que cosmic-text dessine, dans les deux graisses+ /// qu'un controle peut produire, et deux familles ne se confondent jamais a l'ecran.+ #[test]+ fn every_shipped_family_draws_from_its_own_files() {+ use cosmic_text::fontdb::{Family, Query, Stretch, Style, Weight};+ let mut font_system = FontSystem::new();+ let files = crate::text_fonts::font_files_in(&crate::text_fonts::repo_fonts_dir());+ load_fonts(&mut font_system, &files);+ for family in crate::text_fonts::SHIPPED_FAMILIES {+ for weight in [Weight::NORMAL, Weight::BOLD] {+ let query = Query {+ families: &[Family::Name(family)],+ weight,+ stretch: Stretch::Normal,+ style: Style::Normal,+ };+ let id = font_system+ .db()+ .query(&query)+ .unwrap_or_else(|| panic!("{family} introuvable"));+ // Un vrai fichier de cette graisse, pas le regulier epaissi ou non.+ assert_eq!(font_system.db().face(id).unwrap().weight, weight, "{family}");+ }+ }++ let raster = TextRasterizer {+ font_system: RefCell::new(font_system),+ swash_cache: RefCell::new(SwashCache::new()),+ };+ let mut blocks = Vec::new();+ for family in crate::text_fonts::SHIPPED_FAMILIES {+ let mut s = spec("Hamburgefonstiv", "left");+ s.font_family = family.to_owned();+ s.font_size_px = 100.0;+ s.box_px = [1600, 200];+ let atlas = raster.build_atlas(&s).expect("atlas").pixels;+ let (cols, rows) = (ink_cols(&atlas, 1600), ink_rows(&atlas, 1600, 0, 1600));+ let (w, h) = (cols[cols.len() - 1] - cols[0] + 1, rows[rows.len() - 1] - rows[0] + 1);+ blocks.push((family, w as f32, h as f32));+ }+ crate::text_fonts::assert_distinct_blocks(&blocks);+ }+#[test]fn the_plate_hugs_the_text_instead_of_filling_the_box() {// LE bug des sous-titres sous Linux. La plaque etait le quad de la boitediff --git a/crates/compositor/src/text_macos.rs b/crates/compositor/src/text_macos.rsindex 5979ab14c..647c66a5e 100644--- a/crates/compositor/src/text_macos.rs+++ b/crates/compositor/src/text_macos.rs@@ -34,6 +34,7 @@use crate::d3d::Gpu;use anyhow::{anyhow, bail, Result};use std::ffi::c_void;+use std::path::PathBuf;/// Spécification d'un texte à rastériser. Mêmes champs que `text_windows::TextSpec`/// — le moteur macOS les consomme via `cache_key` pour déterminer si une re-rastérisation@@ -141,6 +142,8 @@ const K_CT_PARAGRAPH_STYLE_SPECIFIER_ALIGNMENT: u32 = 0;/// `CTFontSymbolicTraits` : italique / gras.const K_CT_FONT_TRAIT_ITALIC: u32 = 1 << 0;const K_CT_FONT_TRAIT_BOLD: u32 = 1 << 1;+/// `kCTFontManagerScopeProcess` : la police n'existe que pour ce processus, rien n'est installé.+const K_CT_FONT_MANAGER_SCOPE_PROCESS: u32 = 1;#[repr(C)]#[derive(Clone, Copy)]@@ -174,6 +177,12 @@ extern "C" {str_: CFTypeRef,attributes: CFTypeRef,) -> CFTypeRef;+ fn CFURLCreateFromFileSystemRepresentation(+ alloc: CFTypeRef,+ buffer: *const u8,+ buf_len: CFIndex,+ is_directory: u8,+ ) -> CFTypeRef;static kCFTypeDictionaryKeyCallBacks: c_void;static kCFTypeDictionaryValueCallBacks: c_void;}@@ -231,6 +240,11 @@ extern "C" {frame_attributes: CFTypeRef,) -> CFTypeRef;fn CTFrameDraw(frame: CFTypeRef, context: CFTypeRef);+ fn CTFontManagerRegisterFontsForURL(+ font_url: CFTypeRef,+ scope: u32,+ error: *mut CFTypeRef,+ ) -> bool;static kCTFontAttributeName: CFTypeRef;static kCTForegroundColorAttributeName: CFTypeRef;@@ -406,6 +420,35 @@ unsafe fn cf_string(s: &str) -> Option<CFOwned> {))}+/// Rend `files` (`crate::text_fonts`) visibles de CoreText pour CE processus seulement :+/// `CTFontCreateWithName` les trouve ensuite par leur nom de famille, sans que rien ne soit+/// installé sur la machine.+///+/// Un fichier refusé ne coûte que sa police : le texte retombe sur celles du système. Un+/// fichier déjà enregistré est refusé aussi, et reste utilisable.+unsafe fn register_fonts(files: &[PathBuf]) {+ use std::os::unix::ffi::OsStrExt;+ for path in files {+ let bytes = path.as_os_str().as_bytes();+ let Some(url) = CFOwned::new(CFURLCreateFromFileSystemRepresentation(+ std::ptr::null(),+ bytes.as_ptr(),+ bytes.len() as CFIndex,+ 0,+ )) else {+ continue;+ };+ let registered = CTFontManagerRegisterFontsForURL(+ url.get(),+ K_CT_FONT_MANAGER_SCOPE_PROCESS,+ std::ptr::null_mut(),+ );+ if !registered {+ eprintln!("[text] police non enregistrée (ou déjà) : {}", path.display());+ }+ }+}+/// Rastériseur de texte macOS. Pas d'état persistant : CoreText et CoreGraphics sont/// prêts dès le link des frameworks (côté Windows, `TextRasterizer::new` alloue les/// factories DirectWrite/Direct2D — d'où le `Result` conservé pour la symétrie).@@ -413,6 +456,10 @@ pub struct TextRasterizer;impl TextRasterizer {pub fn new() -> Result<TextRasterizer> {+ // Une fois par processus : l'enregistrement vaut pour tout CoreText, alors que chaque+ // compositeur (preview, export) crée son rastériseur.+ static REGISTER: std::sync::Once = std::sync::Once::new();+ REGISTER.call_once(|| unsafe { register_fonts(&crate::text_fonts::embedded_font_files()) });Ok(TextRasterizer)}@@ -739,6 +786,80 @@ mod tests {(x0, y0, x1, y1)}+ #[link(name = "CoreText", kind = "framework")]+ extern "C" {+ fn CTFontCopyFamilyName(font: CFTypeRef) -> CFTypeRef;+ fn CTFontGetSymbolicTraits(font: CFTypeRef) -> u32;+ }++ #[link(name = "CoreFoundation", kind = "framework")]+ extern "C" {+ fn CFStringGetCString(+ string: CFTypeRef,+ buffer: *mut std::ffi::c_char,+ buffer_size: CFIndex,+ encoding: u32,+ ) -> u8;+ }++ /// Le nom de famille que CoreText a réellement résolu pour `font`.+ unsafe fn family_of(font: CFTypeRef) -> String {+ let name = CFOwned::new(CTFontCopyFamilyName(font)).expect("CTFontCopyFamilyName");+ let mut buf = [0 as std::ffi::c_char; 256];+ let ok = CFStringGetCString(+ name.get(),+ buf.as_mut_ptr(),+ buf.len() as CFIndex,+ K_CF_STRING_ENCODING_UTF8,+ );+ assert_ne!(ok, 0, "CFStringGetCString");+ std::ffi::CStr::from_ptr(buf.as_ptr()).to_string_lossy().into_owned()+ }++ /// Chaque famille embarquée est celle que CoreText dessine. `CTFontCreateWithName` ne+ /// renvoie jamais NULL pour un nom inconnu : il retombe en silence sur une autre police,+ /// donc seul le nom de famille RÉSOLU dit si la bonne a été prise.+ #[test]+ fn every_shipped_family_draws_from_its_own_files() {+ unsafe {+ register_fonts(&crate::text_fonts::font_files_in(&crate::text_fonts::repo_fonts_dir()));+ for family in crate::text_fonts::SHIPPED_FAMILIES {+ let name = cf_string(family).unwrap();+ let font = CFOwned::new(CTFontCreateWithName(name.get(), 40.0, std::ptr::null()))+ .unwrap();+ assert_eq!(family_of(font.get()), family);+ let traits = CTFontGetSymbolicTraits(font.get());+ assert_eq!(traits & K_CT_FONT_TRAIT_BOLD, 0, "{family} : le régulier sort gras");+ // Le réglage Gras prend un vrai fichier gras de la MÊME famille.+ let bold = CFOwned::new(CTFontCreateCopyWithSymbolicTraits(+ font.get(),+ 0.0,+ std::ptr::null(),+ K_CT_FONT_TRAIT_BOLD,+ K_CT_FONT_TRAIT_BOLD | K_CT_FONT_TRAIT_ITALIC,+ ))+ .unwrap_or_else(|| panic!("{family} : pas de gras"));+ assert_eq!(family_of(bold.get()), family);+ assert_ne!(CTFontGetSymbolicTraits(bold.get()) & K_CT_FONT_TRAIT_BOLD, 0);+ }+ }++ // Et chaque famille se voit, à l'encre dessinée.+ let mut blocks = Vec::new();+ for family in crate::text_fonts::SHIPPED_FAMILIES {+ let mut s = spec("Hamburgefonstiv");+ s.font_family = family.into();+ s.font_size_px = 100.0;+ s.box_px = [1600, 200];+ let Some((px, w, h)) = raster_bgra(&s) else {+ return;+ };+ let (x0, y0, x1, y1) = ink_bounds(&px, w, h);+ blocks.push((family, (x1 - x0 + 1) as f32, (y1 - y0 + 1) as f32));+ }+ crate::text_fonts::assert_distinct_blocks(&blocks);+ }+/// Le texte n'est pas retourné. Le test regarde où est l'encre plutôt que de faire/// confiance au sens du CTM : c'est la seule façon de distinguer « bien orienté » de/// « retourné », et le retournement était un vrai bug de ce fichier.diff --git a/crates/compositor/src/text_windows.rs b/crates/compositor/src/text_windows.rsindex e09f4cdc7..67f3d0923 100644--- a/crates/compositor/src/text_windows.rs+++ b/crates/compositor/src/text_windows.rs@@ -16,6 +16,8 @@//! re-rastériser (c'est l'affaire du vertex shader).use anyhow::{bail, Result};+use std::os::windows::ffi::OsStrExt;+use std::path::PathBuf;use windows::core::Interface;use windows::Win32::Graphics::Direct2D::Common::{D2D1_ALPHA_MODE_PREMULTIPLIED, D2D1_COLOR_F, D2D1_PIXEL_FORMAT, D2D_POINT_2F, D2D_RECT_F,@@ -30,8 +32,9 @@ use windows::Win32::Graphics::Direct3D11::{D3D11_BIND_SHADER_RESOURCE, D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT,};use windows::Win32::Graphics::DirectWrite::{- DWriteCreateFactory, IDWriteFactory, DWRITE_FACTORY_TYPE_SHARED,- DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_ITALIC, DWRITE_FONT_STYLE_NORMAL,+ DWriteCreateFactory, IDWriteFactory, IDWriteFactory5, IDWriteFontCollection1,+ DWRITE_FACTORY_TYPE_SHARED, DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_ITALIC,+ DWRITE_FONT_STYLE_NORMAL,DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_PARAGRAPH_ALIGNMENT_CENTER,DWRITE_PARAGRAPH_ALIGNMENT_FAR, DWRITE_PARAGRAPH_ALIGNMENT_NEAR, DWRITE_TEXT_ALIGNMENT_CENTER,DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_TEXT_ALIGNMENT_TRAILING, DWRITE_TEXT_METRICS,@@ -133,9 +136,38 @@ fn plate_rect(metrics: [f32; 4], box_px: [f32; 2], pad_x: f32, pad_y: f32) -> [f]}+/// Une collection DirectWrite faite des seuls `files` (`crate::text_fonts`), sans rien installer+/// sur la machine. `None` quand il n'y a rien à charger.+///+/// PRIVÉE, et c'est voulu : une famille absente n'y tombe pas sur une police installée du même+/// nom, donc le rendu ne dépend plus de la machine. Les caractères qu'aucune police embarquée+/// ne couvre (CJK, arabe…) passent toujours par le repli du système, que la mise en page+/// applique quelle que soit la collection de base.+unsafe fn private_font_collection(+ dwrite: &IDWriteFactory,+ files: &[PathBuf],+) -> windows::core::Result<Option<IDWriteFontCollection1>> {+ if files.is_empty() {+ return Ok(None);+ }+ // `IDWriteFactory5` : Windows 10 1703 et après. Plus ancien, le `cast` échoue et+ // l'appelant retombe sur les polices du système.+ let factory: IDWriteFactory5 = dwrite.cast()?;+ let builder = factory.CreateFontSetBuilder()?;+ for path in files {+ let wide_path: Vec<u16> = path.as_os_str().encode_wide().chain(Some(0)).collect();+ let file =+ factory.CreateFontFileReference(windows::core::PCWSTR(wide_path.as_ptr()), None)?;+ builder.AddFontFile(&file)?;+ }+ Ok(Some(factory.CreateFontCollectionFromFontSet(&builder.CreateFontSet()?)?))+}+pub struct TextRasterizer {d2d: ID2D1Factory,dwrite: IDWriteFactory,+ /// Les polices embarquées, cf. `private_font_collection`. `None` : collection du système.+ fonts: Option<IDWriteFontCollection1>,}impl TextRasterizer {@@ -146,7 +178,14 @@ impl TextRasterizer {let d2d: ID2D1Factory =D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, None)?;let dwrite: IDWriteFactory = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED)?;- Ok(TextRasterizer { d2d, dwrite })+ // Un échec ne coûte que les polices embarquées, pas le texte : on le dit et on+ // continue sur celles du système.+ let fonts = private_font_collection(&dwrite, &crate::text_fonts::embedded_font_files())+ .unwrap_or_else(|e| {+ eprintln!("[text] polices embarquées non chargées ({e}) : polices du système");+ None+ });+ Ok(TextRasterizer { d2d, dwrite, fonts })}}@@ -204,7 +243,7 @@ impl TextRasterizer {let locale = wide("");let format = self.dwrite.CreateTextFormat(windows::core::PCWSTR(family.as_ptr()),- None,+ self.fonts.as_deref(),if spec.bold { DWRITE_FONT_WEIGHT_BOLD } else { DWRITE_FONT_WEIGHT_NORMAL },if spec.italic { DWRITE_FONT_STYLE_ITALIC } else { DWRITE_FONT_STYLE_NORMAL },DWRITE_FONT_STRETCH_NORMAL,@@ -399,6 +438,77 @@ mod tests {}}+ /// Bloc mis en page de « Hamburgefonstiv » à 100 px, `(largeur, hauteur de ligne)`. Pas de+ /// device D3D : la mise en page DirectWrite suffit pour savoir quelle police a été prise.+ unsafe fn laid_out_block(+ dwrite: &IDWriteFactory,+ fonts: &IDWriteFontCollection1,+ family: &str,+ ) -> (f32, f32) {+ let (family, locale) = (wide(family), wide("en-us"));+ let format = dwrite+ .CreateTextFormat(+ windows::core::PCWSTR(family.as_ptr()),+ Some(&**fonts),+ DWRITE_FONT_WEIGHT_NORMAL,+ DWRITE_FONT_STYLE_NORMAL,+ DWRITE_FONT_STRETCH_NORMAL,+ 100.0,+ windows::core::PCWSTR(locale.as_ptr()),+ )+ .unwrap();+ let text: Vec<u16> = "Hamburgefonstiv".encode_utf16().collect();+ let layout = dwrite.CreateTextLayout(&text, &format, 10_000.0, 1_000.0).unwrap();+ let mut m = DWRITE_TEXT_METRICS::default();+ layout.GetMetrics(&mut m).unwrap();+ (m.width, m.height)+ }++ /// L'index de `family` dans `fonts`, ou `None` si elle n'y est pas.+ unsafe fn family_index(fonts: &IDWriteFontCollection1, family: &str) -> Option<u32> {+ let name = wide(family);+ let (mut index, mut exists) = (0u32, windows::Win32::Foundation::BOOL(0));+ fonts+ .FindFamilyName(windows::core::PCWSTR(name.as_ptr()), &mut index, &mut exists)+ .unwrap();+ exists.as_bool().then_some(index)+ }++ #[test]+ fn every_shipped_family_draws_from_its_own_files_never_from_the_system() {+ use windows::Win32::Graphics::DirectWrite::DWRITE_FONT_SIMULATIONS_NONE;+ unsafe {+ let dwrite: IDWriteFactory = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED).unwrap();+ let files = crate::text_fonts::font_files_in(&crate::text_fonts::repo_fonts_dir());+ let fonts = private_font_collection(&dwrite, &files).unwrap().expect("collection");+ // Privée : une police installée n'y est pas, donc aucun nom ne s'y résout en douce+ // vers ce que la machine se trouve avoir.+ assert!(family_index(&fonts, "Arial").is_none(), "la collection voit le système");++ let mut blocks = Vec::new();+ for family in crate::text_fonts::SHIPPED_FAMILIES {+ let index = family_index(&fonts, family)+ .unwrap_or_else(|| panic!("{family} absente de la collection embarquée"));+ // Le réglage Gras prend un VRAI fichier gras, pas une simulation : DirectWrite+ // épaissit, CoreText et cosmic-text non, et le rendu divergerait.+ let bold = fonts+ .GetFontFamily(index)+ .unwrap()+ .GetFirstMatchingFont(+ DWRITE_FONT_WEIGHT_BOLD,+ DWRITE_FONT_STRETCH_NORMAL,+ DWRITE_FONT_STYLE_NORMAL,+ )+ .unwrap();+ assert_eq!(bold.GetWeight(), DWRITE_FONT_WEIGHT_BOLD, "{family} : pas de gras");+ assert_eq!(bold.GetSimulations(), DWRITE_FONT_SIMULATIONS_NONE, "{family}");+ let (w, h) = laid_out_block(&dwrite, &fonts, family);+ blocks.push((family, w, h));+ }+ crate::text_fonts::assert_distinct_blocks(&blocks);+ }+ }+#[test]fn identical_specs_share_a_cache_key() {assert_eq!(spec("Bonjour").cache_key(), spec("Bonjour").cache_key());diff --git a/electron-builder.json5 b/electron-builder.json5index 930368613..8da5be310 100644--- a/electron-builder.json5+++ b/electron-builder.json5@@ -98,6 +98,7 @@"!dist/wallpapers/**","!dist/cursors/**","!dist/mediapipe/**",+ "!dist/fonts/**",// Exclude dead-weight node_modules: all frontend and electron code is pre-bundled by Vite (saves ~238 MB)"!node_modules/**","!*.png",@@ -145,6 +146,15 @@{"from": "public/mediapipe","to": "mediapipe"+ },+ // The only fonts captions and annotations are drawn in: the compositor registers them+ // privately (OPENSCREEN_FONTS_DIR, compositorViewService.ts) and never reads the machine's+ // installed fonts. Out of the asar for the same raw-path reason as the model above; the+ // renderer's picker specimens load the same copy through the asset base URL. 2.3 MB, with+ // each family's OFL text beside it as the licence requires.+ {+ "from": "public/fonts",+ "to": "fonts"}],diff --git a/electron/native-bridge/services/compositorViewService.test.ts b/electron/native-bridge/services/compositorViewService.test.tsindex 55a5c05e1..938fb42a7 100644--- a/electron/native-bridge/services/compositorViewService.test.ts+++ b/electron/native-bridge/services/compositorViewService.test.ts@@ -294,6 +294,69 @@ describe("CompositorViewService ffmpeg PATH prepend", () => {});});+describe("CompositorViewService text fonts", () => {+ // The compositor reads the font directory off OPENSCREEN_FONTS_DIR when it builds its text+ // rasterizer. Unset, it draws every family in a system fallback, which is the bug this pins.+ let tmpRoot: string;+ let resources: string;+ let originalResourcesPath: PropertyDescriptor | undefined;+ let originalVitePublic: string | undefined;+ let originalFontsDir: string | undefined;++ beforeEach(() => {+ tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "openscreen-fonts-root-"));+ resources = fs.mkdtempSync(path.join(os.tmpdir(), "openscreen-fonts-res-"));+ originalResourcesPath = Object.getOwnPropertyDescriptor(process, "resourcesPath");+ Object.defineProperty(process, "resourcesPath", { value: resources, configurable: true });+ originalVitePublic = process.env.VITE_PUBLIC;+ // Packaged layout: VITE_PUBLIC points into the asar, which the addon cannot read.+ process.env.VITE_PUBLIC = path.join(resources, "app.asar", "dist");+ originalFontsDir = process.env.OPENSCREEN_FONTS_DIR;+ Reflect.deleteProperty(process.env, "OPENSCREEN_FONTS_DIR");+ });++ afterEach(() => {+ if (originalResourcesPath) {+ Object.defineProperty(process, "resourcesPath", originalResourcesPath);+ }+ if (originalVitePublic === undefined) {+ Reflect.deleteProperty(process.env, "VITE_PUBLIC");+ } else {+ process.env.VITE_PUBLIC = originalVitePublic;+ }+ if (originalFontsDir === undefined) {+ Reflect.deleteProperty(process.env, "OPENSCREEN_FONTS_DIR");+ } else {+ process.env.OPENSCREEN_FONTS_DIR = originalFontsDir;+ }+ fs.rmSync(tmpRoot, { recursive: true, force: true });+ fs.rmSync(resources, { recursive: true, force: true });+ });++ it("points the compositor at the extraResources copy before the addon loads", () => {+ fs.mkdirSync(path.join(resources, "fonts"));++ new CompositorViewService({ appRoot: tmpRoot, isPackaged: true }).hasAddon();++ expect(process.env.OPENSCREEN_FONTS_DIR).toBe(path.join(resources, "fonts"));+ });++ it("leaves the variable unset when no fonts ship, so text falls back instead of failing", () => {+ new CompositorViewService({ appRoot: tmpRoot, isPackaged: true }).hasAddon();++ expect(process.env.OPENSCREEN_FONTS_DIR).toBeUndefined();+ });++ it("keeps a directory set by the environment", () => {+ fs.mkdirSync(path.join(resources, "fonts"));+ process.env.OPENSCREEN_FONTS_DIR = "/explicit/fonts";++ new CompositorViewService({ appRoot: tmpRoot, isPackaged: true }).hasAddon();++ expect(process.env.OPENSCREEN_FONTS_DIR).toBe("/explicit/fonts");+ });+});+describe("resolveSceneAssetPaths", () => {// A packaged install: `wallpapers/` and `cursors/` exist as real files under// resourcesPath (extraResources), while VITE_PUBLIC points into the asar, wherediff --git a/electron/native-bridge/services/compositorViewService.ts b/electron/native-bridge/services/compositorViewService.tsindex b08a1a06d..918b6ea43 100644--- a/electron/native-bridge/services/compositorViewService.ts+++ b/electron/native-bridge/services/compositorViewService.ts@@ -422,6 +422,23 @@ function ensureOnnxRuntimeOnPath(appRoot: string): void {}}+/**+ * Points `OPENSCREEN_FONTS_DIR` at the font files the compositor draws captions and annotations+ * with (`public/fonts`, shipped through `extraResources` like the wallpapers). The compositor+ * registers them privately when it builds its text rasterizer and never reads the machine's+ * installed fonts, so without this every family falls back to a system face. Best-effort like+ * `ensureOnnxRuntimeOnPath`: unresolved, text still draws, in system fonts.+ */+function ensureTextFontsDir(): void {+ if (process.env.OPENSCREEN_FONTS_DIR) {+ return;+ }+ const dir = resolveSceneAssetPath("fonts");+ if (dir) {+ process.env.OPENSCREEN_FONTS_DIR = dir;+ }+}+function tryLoadAddon(candidates: string[]): CompositorViewAddon | null {for (const candidate of candidates) {try {@@ -471,6 +488,7 @@ export class CompositorViewService {ensureFfmpegSharedDllsOnPath(appRoot);ensureOnnxRuntimeOnPath(appRoot);+ ensureTextFontsDir();const candidates = buildCandidatePaths(appRoot, isPackaged, envOverride);const loaded = tryLoadAddon(candidates);if (!loaded) {diff --git a/nix/package.nix b/nix/package.nixindex f8f9b44b2..a8f4290e5 100644--- a/nix/package.nix+++ b/nix/package.nix@@ -90,6 +90,9 @@ buildNpmPackage {# packaged layout (electron-builder extraResources -> resources/wallpapers).mkdir -p "$out/lib/openscreen/public"cp -r public/wallpapers "$out/lib/openscreen/public/wallpapers"+ # Same for the caption/annotation fonts: the renderer's picker loads them from+ # there. The compositor itself finds the copy Vite put in dist/fonts.+ cp -r public/fonts "$out/lib/openscreen/public/fonts"# Wrap system electron with the app directory.#diff --git a/public/fonts/Caveat-Bold.ttf b/public/fonts/Caveat-Bold.ttfnew file mode 100644index 000000000..901230a1bBinary files /dev/null and b/public/fonts/Caveat-Bold.ttf differdiff --git a/public/fonts/Caveat-OFL.txt b/public/fonts/Caveat-OFL.txtnew file mode 100644index 000000000..6e5220c95--- /dev/null+++ b/public/fonts/Caveat-OFL.txt@@ -0,0 +1,93 @@+Copyright 2014 The Caveat Project Authors (https://github.com/googlefonts/caveat)++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+http://scripts.sil.org/OFL+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/public/fonts/Caveat-Regular.ttf b/public/fonts/Caveat-Regular.ttfnew file mode 100644index 000000000..6a6526a4eBinary files /dev/null and b/public/fonts/Caveat-Regular.ttf differdiff --git a/public/fonts/IBMPlexMono-Bold.ttf b/public/fonts/IBMPlexMono-Bold.ttfnew file mode 100644index 000000000..17b406d22Binary files /dev/null and b/public/fonts/IBMPlexMono-Bold.ttf differdiff --git a/public/fonts/IBMPlexMono-OFL.txt b/public/fonts/IBMPlexMono-OFL.txtnew file mode 100644index 000000000..c35c4c618--- /dev/null+++ b/public/fonts/IBMPlexMono-OFL.txt@@ -0,0 +1,93 @@+Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"++This Font Software is licensed under the SIL Open Font License, Version 1.1.++This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/public/fonts/IBMPlexMono-Regular.ttf b/public/fonts/IBMPlexMono-Regular.ttfnew file mode 100644index 000000000..0c9770d51Binary files /dev/null and b/public/fonts/IBMPlexMono-Regular.ttf differdiff --git a/public/fonts/Inter-Bold.ttf b/public/fonts/Inter-Bold.ttfnew file mode 100644index 000000000..9fb9b751eBinary files /dev/null and b/public/fonts/Inter-Bold.ttf differdiff --git a/public/fonts/Inter-OFL.txt b/public/fonts/Inter-OFL.txtnew file mode 100644index 000000000..9b2ca37b3--- /dev/null+++ b/public/fonts/Inter-OFL.txt@@ -0,0 +1,92 @@+Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+http://scripts.sil.org/OFL++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION AND CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/public/fonts/Inter-Regular.ttf b/public/fonts/Inter-Regular.ttfnew file mode 100644index 000000000..b7aaca8deBinary files /dev/null and b/public/fonts/Inter-Regular.ttf differdiff --git a/public/fonts/Lora-Bold.ttf b/public/fonts/Lora-Bold.ttfnew file mode 100644index 000000000..daeba0126Binary files /dev/null and b/public/fonts/Lora-Bold.ttf differdiff --git a/public/fonts/Lora-OFL.txt b/public/fonts/Lora-OFL.txtnew file mode 100644index 000000000..d0ce7fe06--- /dev/null+++ b/public/fonts/Lora-OFL.txt@@ -0,0 +1,93 @@+Copyright 2011 The Lora Project Authors (https://github.com/cyrealtype/Lora-Cyrillic), with Reserved Font Name "Lora".++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+https://scripts.sil.org/OFL+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/public/fonts/Lora-Regular.ttf b/public/fonts/Lora-Regular.ttfnew file mode 100644index 000000000..c39a23838Binary files /dev/null and b/public/fonts/Lora-Regular.ttf differdiff --git a/public/fonts/Oswald-Bold.ttf b/public/fonts/Oswald-Bold.ttfnew file mode 100644index 000000000..4314b91e6Binary files /dev/null and b/public/fonts/Oswald-Bold.ttf differdiff --git a/public/fonts/Oswald-OFL.txt b/public/fonts/Oswald-OFL.txtnew file mode 100644index 000000000..4d4e319b6--- /dev/null+++ b/public/fonts/Oswald-OFL.txt@@ -0,0 +1,93 @@+Copyright 2016 The Oswald Project Authors (https://github.com/googlefonts/OswaldFont)++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+https://scripts.sil.org/OFL+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/public/fonts/Oswald-Regular.ttf b/public/fonts/Oswald-Regular.ttfnew file mode 100644index 000000000..dc593e1ebBinary files /dev/null and b/public/fonts/Oswald-Regular.ttf differdiff --git a/src/App.tsx b/src/App.tsxindex 01f0a6f73..56f801190 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -16,6 +16,7 @@ import { EditorDialogsProvider } from "./contexts/EditorDialogsContext";import { useScopedT } from "./contexts/I18nContext";import { ShortcutsProvider } from "./contexts/ShortcutsContext";import { loadAllCustomFonts } from "./lib/customFonts";+import { registerTextFontFaces } from "./lib/textFonts";const VideoEditorEntry = lazy(() =>import("./components/ai-edition/AiEditionShell").then((module) => ({@@ -77,6 +78,7 @@ export default function App() {loadAllCustomFonts().catch((error) => {console.error("Failed to load custom fonts:", error);});+ registerTextFontFaces();}, []);const content = (() => {diff --git a/src/components/ai-edition/CaptionsPane.tsx b/src/components/ai-edition/CaptionsPane.tsxindex 2111d696b..36fb9627f 100644--- a/src/components/ai-edition/CaptionsPane.tsx+++ b/src/components/ai-edition/CaptionsPane.tsx@@ -30,6 +30,7 @@ import {} from "@/lib/ai-edition/store/transcriptionStore";import { useCaptions } from "@/lib/ai-edition/store/useCaptions";import { firstTimelineBusyView } from "@/lib/ai-edition/transcription/status";+import { TEXT_FONT_FAMILIES } from "@/lib/textFonts";import { nativeBridgeClient } from "@/native";import { ColorField } from "./ColorField";import styles from "./NewEditorShell.module.css";@@ -37,28 +38,6 @@ import { SliderCell, Toggle } from "./RightPanes";import { useTranscriptionLabel } from "./TranscriptionStatus";import { transcriptionBusyLabel } from "./transcriptionBusyLabel";-/** The families `src/index.css` already loads for on-canvas text — anything else- * would render in the preview but fall back to a default in the export canvas. */-const CAPTION_FONTS = [- "Inter",- "Geist",- "DM Sans",- "Plus Jakarta Sans",- "Manrope",- "Space Grotesk",- "Sora",- "IBM Plex Sans",- "Oswald",- "Bebas Neue",- "Lora",- "Merriweather",- "Playfair Display",- "Caveat",- "Permanent Marker",- "Fira Code",- "IBM Plex Mono",-] as const;-/** Offered as translation targets. Codes double as the storage key. */const TRANSLATION_LANGUAGES: ReadonlyArray<{ code: string; label: string }> = [{ code: "en", label: "English" },@@ -438,7 +417,9 @@ export function CaptionsPane({ onClose }: { onClose?: () => void } = {}) {onChange={(e) => void set({ fontFamily: e.target.value })}style={selectStyle}>- {CAPTION_FONTS.map((font) => (+ {/* Only the families the compositor ships: it never reads the machine's+ installed fonts, so any other name would draw a fallback. */}+ {TEXT_FONT_FAMILIES.map((font) => (<option key={font} value={font} style={{ fontFamily: font }}>{font}</option>diff --git a/src/index.css b/src/index.cssindex cf0953a8d..47ed55d2e 100644--- a/src/index.css+++ b/src/index.css@@ -1,5 +1,3 @@-@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Caveat:wght@400;700&family=DM+Sans:ital,wght@0,400;0,700;1,400;1,700&family=Fira+Code:wght@400;700&family=IBM+Plex+Mono:ital,wght@0,400;0,700;1,400;1,700&family=IBM+Plex+Sans:ital,wght@0,400;0,700;1,400;1,700&family=Inter:ital,wght@0,400;0,700;1,400;1,700&family=Lora:ital,wght@0,400;0,700;1,400;1,700&family=Manrope:wght@400;700&family=Merriweather:ital,wght@0,400;0,700;1,400;1,700&family=Oswald:wght@400;700&family=Permanent+Marker&family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&family=Plus+Jakarta+Sans:ital,wght@0,400;0,700;1,400;1,700&family=Space+Grotesk:wght@400;700&family=Sora:wght@400;700&display=swap");-@tailwind base;@tailwind components;@tailwind utilities;diff --git a/src/lib/ai-edition/captions/captions.test.ts b/src/lib/ai-edition/captions/captions.test.tsindex a1321e491..d487078d5 100644--- a/src/lib/ai-edition/captions/captions.test.ts+++ b/src/lib/ai-edition/captions/captions.test.ts@@ -140,6 +140,17 @@ describe("caption settings", () => {expect(getCaptionSettings(next)).toMatchObject({ minWordsPerLine: 3, maxWordsPerLine: 9 });});+ it("reads a stored font that no longer ships as the default, and keeps one that does", () => {+ // Saved while the picker offered 17 Google families the compositor never had: the+ // project must still render, and the picker must still show a real entry.+ const stored = (fontFamily: string) =>+ getCaptionSettings(+ doc({ legacyEditor: { captions: { fontFamily } } } as Partial<AxcutDocument>),+ ).fontFamily;+ expect(stored("Bebas Neue")).toBe("Inter");+ expect(stored("Caveat")).toBe("Caveat");+ });+it("folds the opacity into the background colour, and reports 'transparent' when off", () => {expect(captionBackgroundCss({ ...ON, backgroundColor: "#10b981", backgroundOpacity: 0.5 }),diff --git a/src/lib/ai-edition/captions/settings.ts b/src/lib/ai-edition/captions/settings.tsindex 1f289ffe6..31119b25a 100644--- a/src/lib/ai-edition/captions/settings.ts+++ b/src/lib/ai-edition/captions/settings.ts@@ -9,6 +9,7 @@// `legacyEditor` passthrough blob), so caption settings round-trip through save// / load / undo with every other appearance setting and need no schema bump.+import { DEFAULT_TEXT_FONT_FAMILY, resolveTextFontFamily } from "@/lib/textFonts";import { clamp } from "@/utils/math";import type { AxcutDocument } from "../schema";import { type TranscriptLane, voiceoverPlacements } from "../timeline/aggregated-transcript";@@ -107,7 +108,7 @@ export const DEFAULT_CAPTION_SETTINGS: CaptionSettings = {language: null,captionLane: "recording",fontSize: 48,- fontFamily: "Inter",+ fontFamily: DEFAULT_TEXT_FONT_FAMILY,fontWeight: "bold",color: "#ffffff",backgroundEnabled: true,@@ -478,7 +479,9 @@ export function getCaptionSettings(// that `lanePlacements` would not recognise.captionLane: readEnum(raw.captionLane, CAPTION_LANES, d.captionLane),fontSize,- fontFamily: readString(raw.fontFamily, d.fontFamily),+ // A family that no longer ships reads as the default: the compositor could not draw it,+ // and the picker has no entry to show for it.+ fontFamily: resolveTextFontFamily(raw.fontFamily),fontWeight: readEnum(raw.fontWeight, ["normal", "bold"] as const, d.fontWeight),color: readString(raw.color, d.color),backgroundEnabled,diff --git a/src/lib/textFonts.test.ts b/src/lib/textFonts.test.tsnew file mode 100644index 000000000..0136341fe--- /dev/null+++ b/src/lib/textFonts.test.ts@@ -0,0 +1,83 @@+import fs from "node:fs";+import path from "node:path";+import { describe, expect, it } from "vitest";+import {+ DEFAULT_TEXT_FONT_FAMILY,+ resolveTextFontFamily,+ TEXT_FONT_FAMILIES,+ textFontFile,+} from "./textFonts";++// `import.meta.url` isn't a file: URL under the test environment's transform.+const PUBLIC_DIR = path.resolve(process.cwd(), "public");++/** English (Windows, Unicode BMP) records of a TrueType file's `name` table, by nameID. */+function fontNames(file: string): Map<number, string> {+ const font = fs.readFileSync(file);+ let table = -1;+ for (let i = 0; i < font.readUInt16BE(4); i++) {+ const record = 12 + i * 16;+ if (font.toString("latin1", record, record + 4) === "name") {+ table = font.readUInt32BE(record + 8);+ }+ }+ const strings = table + font.readUInt16BE(table + 4);+ const names = new Map<number, string>();+ for (let i = 0; i < font.readUInt16BE(table + 2); i++) {+ const [platform, encoding, language, nameId, length, offset] = [0, 2, 4, 6, 8, 10].map((at) =>+ font.readUInt16BE(table + 6 + i * 12 + at),+ );+ if (platform === 3 && encoding === 1 && language === 0x409) {+ const utf16be = Buffer.from(font.subarray(strings + offset, strings + offset + length));+ names.set(nameId, utf16be.swap16().toString("utf16le"));+ }+ }+ return names;+}++describe("the text font files", () => {+ it("ship a regular and a bold file per family, each named inside as the picker names it", () => {+ // DirectWrite, CoreText and fontdb all find these files by the family name INSIDE them,+ // so a file whose name table disagrees with the list draws the fallback face again.+ for (const family of TEXT_FONT_FAMILIES) {+ for (const [weight, style] of [+ ["normal", "Regular"],+ ["bold", "Bold"],+ ] as const) {+ const names = fontNames(path.join(PUBLIC_DIR, textFontFile(family, weight)));+ expect(names.get(1)).toBe(family);+ expect(names.get(2)).toBe(style);+ }+ }+ });++ it("ship nothing the picker does not offer, and each family's licence beside it", () => {+ const dir = path.join(PUBLIC_DIR, "fonts");+ const shipped = fs.readdirSync(dir).filter((file) => /\.(ttf|otf)$/i.test(file));+ const offered = TEXT_FONT_FAMILIES.flatMap((family) =>+ (["normal", "bold"] as const).map((weight) => path.basename(textFontFile(family, weight))),+ );+ expect(shipped.sort()).toEqual(offered.sort());+ for (const family of TEXT_FONT_FAMILIES) {+ const licence = fs.readFileSync(+ path.join(dir, `${family.replace(/ /g, "")}-OFL.txt`),+ "utf8",+ );+ expect(licence).toContain("SIL Open Font License, Version 1.1");+ }+ });+});++describe("resolveTextFontFamily", () => {+ it("keeps every family that ships", () => {+ for (const family of TEXT_FONT_FAMILIES) {+ expect(resolveTextFontFamily(family)).toBe(family);+ }+ });++ it("reads a family that no longer ships, or garbage, as the default", () => {+ for (const stored of ["Bebas Neue", "Geist", "Playfair Display", "Arial", "", null, 42]) {+ expect(resolveTextFontFamily(stored)).toBe(DEFAULT_TEXT_FONT_FAMILY);+ }+ });+});diff --git a/src/lib/textFonts.ts b/src/lib/textFonts.tsnew file mode 100644index 000000000..c78bbf30c--- /dev/null+++ b/src/lib/textFonts.ts@@ -0,0 +1,54 @@+// The font families text can be drawn in: captions and annotations alike.+//+// Each family ships as two files in `public/fonts`, `<Family without spaces>-Regular.ttf` and+// `-Bold.ttf` (the only two weights a control can produce). The compositor registers them+// privately when it starts (`OPENSCREEN_FONTS_DIR`, set by compositorViewService.ts) and never+// looks at the fonts installed on the machine, so a family that is not listed here cannot be+// drawn. Offering one anyway is a control that changes nothing: the picker used to list 17+// families from Google Fonts, and on a machine without them every choice rendered in the same+// fallback face.++import { getAssetPath } from "./assetPath";++export const TEXT_FONT_FAMILIES = ["Inter", "Lora", "Oswald", "Caveat", "IBM Plex Mono"] as const;++export type TextFontFamily = (typeof TEXT_FONT_FAMILIES)[number];++export const DEFAULT_TEXT_FONT_FAMILY: TextFontFamily = "Inter";++/**+ * A stored family, read back: itself when it ships, the default otherwise. Projects saved while+ * the picker offered families that never shipped keep rendering, in the face every one of those+ * choices actually fell back to on a machine without the font.+ */+export function resolveTextFontFamily(value: unknown): TextFontFamily {+ return (TEXT_FONT_FAMILIES as readonly unknown[]).includes(value)+ ? (value as TextFontFamily)+ : DEFAULT_TEXT_FONT_FAMILY;+}++/** Where a family's weight ships, relative to the asset base (`public/` in dev). */+export function textFontFile(family: TextFontFamily, weight: "normal" | "bold"): string {+ return `fonts/${family.replace(/ /g, "")}-${weight === "bold" ? "Bold" : "Regular"}.ttf`;+}++/**+ * Makes the shipped files the renderer's faces too, so the picker shows each family exactly as+ * the compositor will draw it, offline included. Faces load lazily, on first use. Cosmetic, so+ * it never throws: a picker without specimens still picks.+ */+export function registerTextFontFaces(): void {+ if (typeof FontFace === "undefined" || typeof document === "undefined" || !document.fonts) {+ return;+ }+ try {+ for (const family of TEXT_FONT_FAMILIES) {+ for (const weight of ["normal", "bold"] as const) {+ const url = getAssetPath(textFontFile(family, weight));+ document.fonts.add(new FontFace(family, `url("${url}")`, { weight }));+ }+ }+ } catch (error) {+ console.warn("[fonts] text font specimens unavailable:", error);+ }+}diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.tsindex d1790e10a..14724f53d 100644--- a/src/native/sceneDescription.test.ts+++ b/src/native/sceneDescription.test.ts@@ -1896,6 +1896,28 @@ describe("buildSceneDescription.annotations", () => {});});+ it("draws a font that does not ship in the default, and keeps one that does", () => {+ // The compositor only has the embedded families: an annotation saved with any other+ // name would draw whatever the machine falls back to.+ const annotation = (id: string, fontFamily: string) => ({+ id,+ startMs: 0,+ endMs: 1000,+ type: "text" as const,+ content: "Hello",+ position: { x: 10, y: 10 },+ size: { width: 40, height: 10 },+ style: { ...style, fontFamily },+ zIndex: 0,+ });+ const scene = buildSceneDescription(+ docWithAnnotations([annotation("old", "Permanent Marker"), annotation("new", "Lora")]),+ );+ const family = (id: string) => scene.annotations.find((a) => a.id === id)?.text?.fontFamily;+ expect(family("old")).toBe("Inter");+ expect(family("new")).toBe("Lora");+ });+it("carries the text payload, reading the field the inspector actually writes", () => {const scene = buildSceneDescription(docWithAnnotations([diff --git a/src/native/sceneDescription.ts b/src/native/sceneDescription.tsindex 75bbd8139..2d3ff0df1 100644--- a/src/native/sceneDescription.ts+++ b/src/native/sceneDescription.ts@@ -61,6 +61,7 @@ import {} from "@/lib/compositeLayout";import { parseCssGradient, resolveLinearGradientAngle } from "@/lib/exporter/gradientParser";import type { FrameTheme, RecordingFrame } from "@/lib/projectDefaults";+import { resolveTextFontFamily } from "@/lib/textFonts";import type { CompositorClipInput } from "./contracts";import { ROUNDNESS_REFERENCE_PX } from "./paramUnits";@@ -1284,7 +1285,10 @@ export function buildSceneDescription(color: style.color,backgroundColor: style.backgroundColor,fontSizeRel: annotationFontSizeFraction(style.fontSize),- fontFamily: style.fontFamily,+ // The one place every drawn text passes: a family that does not ship+ // (a project saved with any other name) draws in the default rather+ // than in whatever the machine falls back to.+ fontFamily: resolveTextFontFamily(style.fontFamily),fontWeight: style.fontWeight,fontStyle: style.fontStyle,textDecoration: style.textDecoration,diff --git a/src/styles/fonts.css b/src/styles/fonts.cssindex cb17d34d2..4662dc789 100644--- a/src/styles/fonts.css+++ b/src/styles/fonts.css@@ -5,9 +5,8 @@** Self-hosted rather than pulled from Google Fonts on purpose: this is a* desktop app that has to start with no network, and the whole UI chrome- * hangs off these two families. (index.css does @import Google Fonts, but- * that set is the on-canvas caption picker — cosmetic, and already only- * meaningful for a user who went looking for those faces.)+ * hangs off these two families. (The on-canvas caption/annotation families+ * are separate: public/fonts, registered by lib/textFonts.ts.)** One variable file per family covers weights 100-900, so the pair costs* ~138 KB instead of the ~19 static cuts it replaces. Upstream: