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";...@@ -113,10 +113,12 @@ pub(crate) const DEFAULT_FONT: &str = "Arial";
113pub(crate) const DEFAULT_FONT_SIZE: f32 = 11.0;113pub(crate) const DEFAULT_FONT_SIZE: f32 = 11.0;
114114
115/// Metric-compatible faces for the fonts OneNote pages use most, under the SIL Open Font115/// 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 them116/// Licence files beside them, by the family each stands in for. Each is left out where the
117/// beside the module instead (`register_substitute`), keeping them out of it.117/// system ships the family it stands in for: Windows ships all four, macOS and iOS all but
118#[cfg(not(target_arch = "wasm32"))]118/// Calibri. The browser fetches them beside the module instead (`register_substitute`),
119const BUNDLED: [(&str, &[&[u8]]); 4] = [119/// keeping them out of it.
120#[cfg(not(any(windows, target_arch = "wasm32")))]
121const BUNDLED: &[(&str, &[&[u8]])] = &[
120 (122 (
121 "Calibri",123 "Calibri",
122 &[124 &[
...@@ -126,6 +128,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [...@@ -126,6 +128,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [
126 include_bytes!("../assets/fonts/Carlito-BoldItalic.ttf"),128 include_bytes!("../assets/fonts/Carlito-BoldItalic.ttf"),
127 ],129 ],
128 ),130 ),
131 #[cfg(not(any(target_os = "macos", target_os = "ios")))]
129 (132 (
130 "Arial",133 "Arial",
131 &[134 &[
...@@ -133,6 +136,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [...@@ -133,6 +136,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [
133 include_bytes!("../assets/fonts/Arimo-Italic.ttf"),136 include_bytes!("../assets/fonts/Arimo-Italic.ttf"),
134 ],137 ],
135 ),138 ),
139 #[cfg(not(any(target_os = "macos", target_os = "ios")))]
136 (140 (
137 "Times New Roman",141 "Times New Roman",
138 &[142 &[
...@@ -142,6 +146,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [...@@ -142,6 +146,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [
142 include_bytes!("../assets/fonts/Tinos-BoldItalic.ttf"),146 include_bytes!("../assets/fonts/Tinos-BoldItalic.ttf"),
143 ],147 ],
144 ),148 ),
149 #[cfg(not(any(target_os = "macos", target_os = "ios")))]
145 (150 (
146 "Courier New",151 "Courier New",
147 &[152 &[
...@@ -156,7 +161,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [...@@ -156,7 +161,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [
156impl Default for TextEngine {161impl Default for TextEngine {
157 /// An engine that lays out each bundled family in its substitute where it is missing.162 /// An engine that lays out each bundled family in its substitute where it is missing.
158 fn default() -> Self {163 fn default() -> Self {
159 #[cfg_attr(target_arch = "wasm32", allow(unused_mut))]164 #[cfg_attr(any(windows, target_arch = "wasm32"), allow(unused_mut))]
160 let mut engine = Self {165 let mut engine = Self {
161 // Clones share loaded font files, so glyphs one lays out draw from the same cache.166 // Clones share loaded font files, so glyphs one lays out draw from the same cache.
162 fonts: FontContext {167 fonts: FontContext {
...@@ -167,8 +172,8 @@ impl Default for TextEngine {...@@ -167,8 +172,8 @@ impl Default for TextEngine {
167 arial_substitutes: BTreeSet::new(),172 arial_substitutes: BTreeSet::new(),
168 substitutes: BTreeMap::new(),173 substitutes: BTreeMap::new(),
169 };174 };
170 #[cfg(not(target_arch = "wasm32"))]175 #[cfg(not(any(windows, target_arch = "wasm32")))]
171 for (family, faces) in BUNDLED {176 for &(family, faces) in BUNDLED {
172 if engine.fonts.collection.family_id(family).is_none() {177 if engine.fonts.collection.family_id(family).is_none() {
173 for face in faces {178 for face in faces {
174 engine179 engine
...@@ -706,7 +711,9 @@ mod tests {...@@ -706,7 +711,9 @@ mod tests {
706 if engine.substitute("Calibri").is_none() {711 if engine.substitute("Calibri").is_none() {
707 return;712 return;
708 }713 }
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 ));
710 assert_eq!(engine.register_substitute(explicit.clone()), Ok("Calibri"));717 assert_eq!(engine.register_substitute(explicit.clone()), Ok("Calibri"));
711 let substitute = engine.substitute("Calibri").unwrap();718 let substitute = engine.substitute("Calibri").unwrap();
712 assert_eq!(substitute.faces.len(), 1);719 assert_eq!(substitute.faces.len(), 1);