diff --git a/hui-glium/Cargo.toml b/hui-glium/Cargo.toml index aed5b86..a0c1f2c 100644 --- a/hui-glium/Cargo.toml +++ b/hui-glium/Cargo.toml @@ -15,8 +15,7 @@ include = [ ] [dependencies] -#hack: hui doesn't compile without the builtin_font feature due to a bug -hui = { version = "=0.1.0-alpha.4", path = "../hui", default-features = false, features = ["builtin_font"] } +hui = { version = "=0.1.0-alpha.4", path = "../hui", default-features = false } glium = { version = "0.34", default-features = false } glam = "0.25" log = "0.4" diff --git a/hui/src/element/builtin/text.rs b/hui/src/element/builtin/text.rs index 500252a..0f02f17 100644 --- a/hui/src/element/builtin/text.rs +++ b/hui/src/element/builtin/text.rs @@ -1,13 +1,10 @@ use std::borrow::Cow; use glam::{vec2, Vec4}; use crate::{ - draw::UiDrawCommand, - element::{MeasureContext, ProcessContext, UiElement}, - measure::Response, - text::{FontHandle, BUILTIN_FONT}, - layout::UiSize + draw::UiDrawCommand, element::{MeasureContext, ProcessContext, UiElement}, layout::UiSize, measure::Response, text::{FontHandle, DEFAULT_FONT} }; + //TODO: text fit // pub enum TextSize { // FitToWidthRatio(f32), @@ -29,7 +26,7 @@ impl Default for Text { text: "".into(), size: (UiSize::Auto, UiSize::Auto), color: Vec4::new(1., 1., 1., 1.), - font: BUILTIN_FONT, + font: DEFAULT_FONT, text_size: 16, } } diff --git a/hui/src/text.rs b/hui/src/text.rs index c2e987d..d69570b 100644 --- a/hui/src/text.rs +++ b/hui/src/text.rs @@ -4,7 +4,10 @@ mod font; mod ftm; use font::FontManager; -pub use font::{FontHandle, BUILTIN_FONT}; +pub use font::FontHandle; +#[cfg(feature="builtin_font")] +pub use font::BUILTIN_FONT; +pub(crate) use font::DEFAULT_FONT; use fontdue::{Font, FontSettings}; use ftm::FontTextureManager; pub use ftm::{FontTextureInfo, GlyphCacheEntry}; diff --git a/hui/src/text/font.rs b/hui/src/text/font.rs index e560c5c..402edd6 100644 --- a/hui/src/text/font.rs +++ b/hui/src/text/font.rs @@ -6,6 +6,12 @@ pub struct FontHandle(pub(crate) usize); #[cfg(feature = "builtin_font")] pub const BUILTIN_FONT: FontHandle = FontHandle(0); + +pub(crate) const DEFAULT_FONT: FontHandle = { + #[cfg(feature = "builtin_font")] { BUILTIN_FONT } + #[cfg(not(feature = "builtin_font"))] { FontHandle(0) } +}; + #[cfg(feature = "builtin_font")] const BUILTIN_FONT_DATA: &[u8] = include_bytes!("../../assets/font/ProggyTiny.ttf");