| ... | ... | @@ -113,10 +113,12 @@ pub(crate) const DEFAULT_FONT: &str = "Arial"; |
| 113 | 113 | pub(crate) const DEFAULT_FONT_SIZE: f32 = 11.0; |
| 114 | 114 | |
| 115 | 115 | /// 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"))] |
| 119 | | const 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")))] |
| 121 | const BUNDLED: &[(&str, &[&[u8]])] = &[ |
| 120 | 122 | ( |
| 121 | 123 | "Calibri", |
| 122 | 124 | &[ |
| ... | ... | @@ -126,6 +128,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [ |
| 126 | 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 | 133 | "Arial", |
| 131 | 134 | &[ |
| ... | ... | @@ -133,6 +136,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [ |
| 133 | 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 | 141 | "Times New Roman", |
| 138 | 142 | &[ |
| ... | ... | @@ -142,6 +146,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [ |
| 142 | 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 | 151 | "Courier New", |
| 147 | 152 | &[ |
| ... | ... | @@ -156,7 +161,7 @@ const BUNDLED: [(&str, &[&[u8]]); 4] = [ |
| 156 | 161 | impl Default for TextEngine { |
| 157 | 162 | /// An engine that lays out each bundled family in its substitute where it is missing. |
| 158 | 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 | 165 | let mut engine = Self { |
| 161 | 166 | // Clones share loaded font files, so glyphs one lays out draw from the same cache. |
| 162 | 167 | fonts: FontContext { |
| ... | ... | @@ -167,8 +172,8 @@ impl Default for TextEngine { |
| 167 | 172 | arial_substitutes: BTreeSet::new(), |
| 168 | 173 | substitutes: BTreeMap::new(), |
| 169 | 174 | }; |
| 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 { |
| 172 | 177 | if engine.fonts.collection.family_id(family).is_none() { |
| 173 | 178 | for face in faces { |
| 174 | 179 | engine |
| ... | ... | @@ -706,7 +711,9 @@ mod tests { |
| 706 | 711 | if engine.substitute("Calibri").is_none() { |
| 707 | 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 | 717 | assert_eq!(engine.register_substitute(explicit.clone()), Ok("Calibri")); |
| 711 | 718 | let substitute = engine.substitute("Calibri").unwrap(); |
| 712 | 719 | assert_eq!(substitute.faces.len(), 1); |