mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-31 08:22:33 +00:00
Add Fonts in Text Style (#344)
This commit is contained in:
@@ -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
|
||||
@@ -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<u8> {
|
||||
// TODO: Somehow fix this ugly mess
|
||||
#[derive(serde::Serialize)]
|
||||
|
||||
@@ -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<HoverEvent<'a>>,
|
||||
/// Allows you to change the font of the text.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub font: Option<String>,
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user