Skip to content

Commit

Permalink
Add Font::SmallerBodyText.
Browse files Browse the repository at this point in the history
This is a temporary measure to unblock UI use cases, which should be
replaced with loadable (`Universe` member) font definitions.
  • Loading branch information
kpreid committed Dec 6, 2023
1 parent 2a99553 commit f28c3e2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 9 additions & 3 deletions all-is-cubes/src/block/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,20 +294,26 @@ 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,
}
}
}

impl universe::VisitRefs for Font {
fn visit_refs(&self, _: &mut dyn universe::RefVisitor) {
match self {
Self::System16 => {}
Self::System16 | Self::SmallerBodyText => {}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions all-is-cubes/src/save/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand All @@ -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,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions all-is-cubes/src/save/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit f28c3e2

Please sign in to comment.