authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-03 14:18:06-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-03 15:13:32-07:00
log36add75c8aac03116e2ce66440c25e5c8b9bc2de
tree64636cc11d4d5a151d7286e87be133c42df38b35
parentf729362858ad787f269bc50144f0c765a84b366f
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

chore: release builds leave out the font clones where the system ships the real families

Windows ships Arial, Times New Roman, Courier New and Calibri, and macOS and iOS all but Calibri, so only Linux keeps Arimo, Tinos and Cousine and only Windows drops Carlito. Layout already preferred an installed family to its clone. Release executables after the debug split: macOS aarch64 40.97 to 36.42 MB (-4.56), Windows x86_64 45.88 to 38.62 MB (-7.26), Linux x86_64 unchanged at 52.35 MB. Assisted-by: claude-opus-5.5

1 files changed, 15 insertions(+), 8 deletions(-)

crates/canvas/src/layout.rs+15-8
......@@ -113,10 +113,12 @@ pub(crate) const DEFAULT_FONT: &str = "Arial";
113113pub(crate) const DEFAULT_FONT_SIZE: f32 = 11.0;
114114
115115/// Metric-compatible faces for the fonts OneNote pages use most, under the SIL Open Font
116/// Licence files beside them, by the family each stands in for. The browser fetches them
117/// beside the module instead (`register_substitute`), keeping them out of it.
118#[cfg(not(target_arch = "wasm32"))]
119const BUNDLED: [(&str, &[&[u8]]); 4] = [
116/// Licence files beside them, by the family each stands in for. Each is left out where the
117/// system ships the family it stands in for: Windows ships all four, macOS and iOS all but
118/// Calibri. The browser fetches them beside the module instead (`register_substitute`),
119/// keeping them out of it.
120#[cfg(not(any(windows, target_arch = "wasm32")))]
121const BUNDLED: &[(&str, &[&[u8]])] = &[
120122 (
121123 "Calibri",
122124 &[
......@@ -126,6 +128,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [
126128 include_bytes!("../assets/fonts/Carlito-BoldItalic.ttf"),
127129 ],
128130 ),
131 #[cfg(not(any(target_os = "macos", target_os = "ios")))]
129132 (
130133 "Arial",
131134 &[
......@@ -133,6 +136,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [
133136 include_bytes!("../assets/fonts/Arimo-Italic.ttf"),
134137 ],
135138 ),
139 #[cfg(not(any(target_os = "macos", target_os = "ios")))]
136140 (
137141 "Times New Roman",
138142 &[
......@@ -142,6 +146,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [
142146 include_bytes!("../assets/fonts/Tinos-BoldItalic.ttf"),
143147 ],
144148 ),
149 #[cfg(not(any(target_os = "macos", target_os = "ios")))]
145150 (
146151 "Courier New",
147152 &[
......@@ -156,7 +161,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [
156161impl Default for TextEngine {
157162 /// An engine that lays out each bundled family in its substitute where it is missing.
158163 fn default() -> Self {
159 #[cfg_attr(target_arch = "wasm32", allow(unused_mut))]
164 #[cfg_attr(any(windows, target_arch = "wasm32"), allow(unused_mut))]
160165 let mut engine = Self {
161166 // Clones share loaded font files, so glyphs one lays out draw from the same cache.
162167 fonts: FontContext {
......@@ -167,8 +172,8 @@ impl Default for TextEngine {
167172 arial_substitutes: BTreeSet::new(),
168173 substitutes: BTreeMap::new(),
169174 };
170 #[cfg(not(target_arch = "wasm32"))]
171 for (family, faces) in BUNDLED {
175 #[cfg(not(any(windows, target_arch = "wasm32")))]
176 for &(family, faces) in BUNDLED {
172177 if engine.fonts.collection.family_id(family).is_none() {
173178 for face in faces {
174179 engine
......@@ -706,7 +711,9 @@ mod tests {
706711 if engine.substitute("Calibri").is_none() {
707712 return;
708713 }
709 let explicit = Blob::new(Arc::new(BUNDLED[0].1[0].to_vec()));
714 let explicit = Blob::new(Arc::new(
715 include_bytes!("../assets/fonts/Carlito-Regular.ttf").to_vec(),
716 ));
710717 assert_eq!(engine.register_substitute(explicit.clone()), Ok("Calibri"));
711718 let substitute = engine.substitute("Calibri").unwrap();
712719 assert_eq!(substitute.faces.len(), 1);