From 7b289c945bea30efccd6c28fe334e169e3ebac9d Mon Sep 17 00:00:00 2001 From: John Nunley Date: Mon, 24 Jul 2023 17:57:46 -0700 Subject: [PATCH] Fix no_std build --- src/font/system.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/font/system.rs b/src/font/system.rs index c156b9b..605617b 100644 --- a/src/font/system.rs +++ b/src/font/system.rs @@ -1,6 +1,7 @@ use crate::{Attrs, AttrsOwned, Font}; use alloc::string::String; use alloc::sync::Arc; +use alloc::vec::Vec; use core::fmt; use core::hash::BuildHasherDefault; use core::ops::{Deref, DerefMut}; @@ -44,7 +45,7 @@ impl FontSystem { /// while debug builds can take up to ten times longer. For this reason, it should only be /// called once, and the resulting [`FontSystem`] should be shared. pub fn new() -> Self { - Self::new_with_fonts(std::iter::empty()) + Self::new_with_fonts(core::iter::empty()) } /// Create a new [`FontSystem`] with a pre-specified set of fonts. @@ -100,6 +101,7 @@ impl FontSystem { .entry(id) .or_insert_with(|| { unsafe { + #[cfg(feature = "std")] self.db.make_shared_face_data(id); } let face = self.db.face(id)?; @@ -119,7 +121,7 @@ impl FontSystem { //TODO: do not create AttrsOwned unless entry does not already exist .entry(AttrsOwned::new(attrs)) .or_insert_with(|| { - #[cfg(not(target_arch = "wasm32"))] + #[cfg(all(feature = "std", not(target_arch = "wasm32")))] let now = std::time::Instant::now(); let ids = self @@ -129,7 +131,7 @@ impl FontSystem { .map(|face| face.id) .collect::>(); - #[cfg(not(target_arch = "wasm32"))] + #[cfg(all(feature = "std", not(target_arch = "wasm32")))] { let elapsed = now.elapsed(); log::debug!("font matches for {:?} in {:?}", attrs, elapsed);