From f28c3e276465fbeec2315b3cc2297c1a55fde625 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Tue, 5 Dec 2023 18:22:30 -0800 Subject: [PATCH] Add `Font::SmallerBodyText`. This is a temporary measure to unblock UI use cases, which should be replaced with loadable (`Universe` member) font definitions. --- all-is-cubes/src/block/text.rs | 12 +++++++++--- all-is-cubes/src/save/conversion.rs | 2 ++ all-is-cubes/src/save/schema.rs | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/all-is-cubes/src/block/text.rs b/all-is-cubes/src/block/text.rs index 998764330..53204b47f 100644 --- a/all-is-cubes/src/block/text.rs +++ b/all-is-cubes/src/block/text.rs @@ -294,12 +294,18 @@ pub enum Font { /// /// This is a placeholder for further improvement in the font system. System16, + + #[doc(hidden)] + // experimental while we figure things out. Probably to be replaced with fonts stored in Universe + SmallerBodyText, } impl Font { fn eg_font(&self) -> &eg::mono_font::MonoFont<'static> { + use eg::mono_font::iso_8859_1 as f; match self { - //Self::System16 => &eg::mono_font::iso_8859_1::FONT_9X15, - Self::System16 => &eg::mono_font::iso_8859_1::FONT_8X13_BOLD, + //Self::System16 => &f::FONT_9X15, + Self::System16 => &f::FONT_8X13_BOLD, + Self::SmallerBodyText => &f::FONT_6X10, } } } @@ -307,7 +313,7 @@ impl Font { impl universe::VisitRefs for Font { fn visit_refs(&self, _: &mut dyn universe::RefVisitor) { match self { - Self::System16 => {} + Self::System16 | Self::SmallerBodyText => {} } } } diff --git a/all-is-cubes/src/save/conversion.rs b/all-is-cubes/src/save/conversion.rs index b23293d11..b8094994d 100644 --- a/all-is-cubes/src/save/conversion.rs +++ b/all-is-cubes/src/save/conversion.rs @@ -415,6 +415,7 @@ mod block { fn from(value: &text::Font) -> Self { match value { text::Font::System16 => schema::FontSer::System16V1, + text::Font::SmallerBodyText => schema::FontSer::UnstableSmallerBodyTextV1, } } } @@ -423,6 +424,7 @@ mod block { fn from(value: schema::FontSer) -> Self { match value { schema::FontSer::System16V1 => text::Font::System16, + schema::FontSer::UnstableSmallerBodyTextV1 => text::Font::SmallerBodyText, } } } diff --git a/all-is-cubes/src/save/schema.rs b/all-is-cubes/src/save/schema.rs index 4bdae8fb1..5041fdd03 100644 --- a/all-is-cubes/src/save/schema.rs +++ b/all-is-cubes/src/save/schema.rs @@ -209,6 +209,8 @@ pub(crate) enum TextSer { #[derive(Debug, Deserialize, Serialize)] pub(crate) enum FontSer { System16V1, + #[doc(hidden)] // experimental, and not intended to be actually serialized + UnstableSmallerBodyTextV1, } #[derive(Debug, Deserialize, Serialize)]