diff --git a/pumpkin-core/src/text/README.md b/pumpkin-core/src/text/README.md index 82c36df2e..85c1f0edb 100644 --- a/pumpkin-core/src/text/README.md +++ b/pumpkin-core/src/text/README.md @@ -39,8 +39,8 @@ Here we build Mojang's Textcomponent, Which is used across many places, Often wh - [x] ShowEntity - Fonts - [x] Default - - [ ] Uniform (Unicode) - - [ ] Alt - - [ ] Illageralt + - [x] Uniform (Unicode) + - [x] Alt + - [x] Illageralt Reference: https://wiki.vg/Text_formatting \ No newline at end of file diff --git a/pumpkin-core/src/text/mod.rs b/pumpkin-core/src/text/mod.rs index 9e47026f2..1d97c5b85 100644 --- a/pumpkin-core/src/text/mod.rs +++ b/pumpkin-core/src/text/mod.rs @@ -158,6 +158,13 @@ impl<'a> TextComponent<'a> { self } + /// Allows you to change the font of the text. + /// Default fonts: `minecraft:default`, `minecraft:uniform`, `minecraft:alt`, `minecraft:illageralt` + pub fn font(mut self, identifier: String) -> Self { + self.style.font = Some(identifier); + self + } + pub fn encode(&self) -> Vec { // TODO: Somehow fix this ugly mess #[derive(serde::Serialize)] diff --git a/pumpkin-core/src/text/style.rs b/pumpkin-core/src/text/style.rs index 6010dd5e8..3a0726f4c 100644 --- a/pumpkin-core/src/text/style.rs +++ b/pumpkin-core/src/text/style.rs @@ -35,6 +35,9 @@ pub struct Style<'a> { /// Allows for a tooltip to be displayed when the player hovers their mouse over text. #[serde(default, skip_serializing_if = "Option::is_none")] pub hover_event: Option>, + /// Allows you to change the font of the text. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub font: Option, } impl<'a> Style<'a> { @@ -95,4 +98,11 @@ impl<'a> Style<'a> { self.hover_event = Some(event); self } + + /// Allows you to change the font of the text. + /// Default fonts: `minecraft:default`, `minecraft:uniform`, `minecraft:alt`, `minecraft:illageralt` + pub fn font(mut self, identifier: String) -> Self { + self.font = Some(identifier); + self + } }