Struct ark_api::world::FormattedText
source · pub struct FormattedText { /* private fields */ }Expand description
Represents formatted text that can be attached to a Render component.
Implementations§
source§impl FormattedText
impl FormattedText
sourcepub fn new(data: &str) -> Self
pub fn new(data: &str) -> Self
Creates the FormattedText from data.
data contains a formatted string, formatted using a custom markup language documented elsewhere. If the string is empty, nothing will be drawn. Only characters supported by Ark’s current hardcoded fonts will work, others may be replaced with little squares or similar. Multiline is OK, \n will be treated as a linebreak (\r is ignored). A native \n character will also be considered a line break.
TODO: Replace this constructor with one that takes a high level representation and encodes the string, similar to the one in ark-modules.
Panics
If there are mistakes in the formatting, it will panic. This is intentional currently since we only intend the markup to be generated from a higher level source, so panics will catch bugs in that conversion but should otherwise never happen.
sourcepub fn new_with_fonts(data: &str, fonts: Vec<Font>) -> Self
pub fn new_with_fonts(data: &str, fonts: Vec<Font>) -> Self
Creates the FormattedText from data.
data contains a formatted string, formatted using a custom markup language documented elsewhere. If the string is empty, nothing will be drawn. Only characters supported by Ark’s current hardcoded fonts will work, others may be replaced with little squares or similar. Multiline is OK, \n will be treated as a linebreak (\r is ignored). A native \n character will also be considered a line break.
Also takes a vector of fonts which can be indexed into with including \f
TODO: Replace this constructor with one that takes a high level representation and encodes the string, similar to the one in ark-modules.
Panics
If there are mistakes in the formatting, it will panic. This is intentional currently since we only intend the markup to be generated from a higher level source, so panics will catch bugs in that conversion but should otherwise never happen.
Trait Implementations§
source§impl Clone for FormattedText
impl Clone for FormattedText
source§fn clone(&self) -> FormattedText
fn clone(&self) -> FormattedText
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for FormattedText
impl Debug for FormattedText
source§impl Hash for FormattedText
impl Hash for FormattedText
source§impl PartialEq<FormattedText> for FormattedText
impl PartialEq<FormattedText> for FormattedText
source§fn eq(&self, other: &FormattedText) -> bool
fn eq(&self, other: &FormattedText) -> bool
self and other values to be equal, and is used
by ==.source§impl ValueConverterTrait<FormattedText> for ValueConverter
impl ValueConverterTrait<FormattedText> for ValueConverter
source§fn into_value(v: FormattedText) -> Value
fn into_value(v: FormattedText) -> Value
Value enum.source§fn from_value(v: &Value) -> FormattedText
fn from_value(v: &Value) -> FormattedText
Value enum.