diff options
author | 2020-05-30 19:23:16 +1200 | |
---|---|---|
committer | 2020-05-31 11:00:17 +1200 | |
commit | ae9521e500d97c9495003a727b6fd931671dda8b (patch) | |
tree | 1141f65a3d41662b834fe8e26629b0402bcd4c57 /glow | |
parent | 05750bf1863f8a6d2b797c4c482cd38dc45d7aeb (diff) | |
download | iced-ae9521e500d97c9495003a727b6fd931671dda8b.tar.gz iced-ae9521e500d97c9495003a727b6fd931671dda8b.tar.bz2 iced-ae9521e500d97c9495003a727b6fd931671dda8b.zip |
Feature gate `font-kit` behind `"default_system_font"` feature.
Diffstat (limited to 'glow')
-rw-r--r-- | glow/Cargo.toml | 3 | ||||
-rw-r--r-- | glow/src/text.rs | 17 |
2 files changed, 13 insertions, 7 deletions
diff --git a/glow/Cargo.toml b/glow/Cargo.toml index 262f0264..baf2eb2f 100644 --- a/glow/Cargo.toml +++ b/glow/Cargo.toml @@ -9,6 +9,7 @@ repository = "https://github.com/hecrj/iced" [features] canvas = ["iced_graphics/canvas"] +default_system_font = ["iced_graphics/font-source"] # Not supported yet! image = [] svg = [] @@ -29,7 +30,7 @@ path = "../native" [dependencies.iced_graphics] version = "0.1" path = "../graphics" -features = ["font-source", "font-fallback", "font-icons", "opengl"] +features = ["font-fallback", "font-icons", "opengl"] [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] diff --git a/glow/src/text.rs b/glow/src/text.rs index 6dc7882c..925c7287 100644 --- a/glow/src/text.rs +++ b/glow/src/text.rs @@ -12,15 +12,20 @@ pub struct Pipeline { impl Pipeline { pub fn new(gl: &glow::Context, default_font: Option<&[u8]>) -> Self { + let default_font = default_font.map(|slice| slice.to_vec()); + // TODO: Font customization - let font_source = font::Source::new(); + #[cfg(feature = "default_system_font")] + let default_font = { + default_font.or_else(|| { + font::Source::new() + .load(&[font::Family::SansSerif, font::Family::Serif]) + .ok() + }) + }; let default_font = - default_font.map(|slice| slice.to_vec()).unwrap_or_else(|| { - font_source - .load(&[font::Family::SansSerif, font::Family::Serif]) - .unwrap_or_else(|_| font::FALLBACK.to_vec()) - }); + default_font.unwrap_or_else(|| font::FALLBACK.to_vec()); let font = ab_glyph::FontArc::try_from_vec(default_font) .unwrap_or_else(|_| { |