pub struct TextBuilder { /* private fields */ }Expand description
Builder for Text values.
Implementations§
Source§impl TextBuilder
impl TextBuilder
Sourcepub fn string(self, string: ArcStr) -> Self
pub fn string(self, string: ArcStr) -> Self
Sets the string to be displayed.
The string may contain newlines, but is not automatically wrapped beyond that.
The default is the empty string.
Sourcepub fn font(self, font: Font) -> Self
pub fn font(self, font: Font) -> Self
Sets the font to use.
The default is Font::System16.
Sourcepub fn foreground(self, foreground: Block) -> Self
pub fn foreground(self, foreground: Block) -> Self
Sets the “foreground color”, or rather voxel, for the text.
This block is interpreted as a voxel in the same way as a block in a Primitive::Recur
space would be. However, the result of evaluating this block not cached. Therefore, it is
highly recommended that the block be stored in a block::BlockDef (which does cache)
if it is not trivial, particularly if this text is going to span multiple blocks.
The default value is Block::from(all_is_cubes_content::palette::ALMOST_BLACK).
Sourcepub fn outline(self, outline: Option<Block>) -> Self
pub fn outline(self, outline: Option<Block>) -> Self
Sets the outline color for the text.
This appears 1 voxel behind and to the side of the main color; making the overall text 2 voxels thick.
See Self::foreground() for information about how the block is used.
The default value is None.
Sourcepub fn resolution(self, resolution: Resolution) -> Self
pub fn resolution(self, resolution: Resolution) -> Self
Sets the voxel resolution to use.
This affects the size of the text, including its thickness, and the units of
layout_bounds.
The default is 16.
Sourcepub fn positioning(self, positioning: Positioning) -> Self
pub fn positioning(self, positioning: Positioning) -> Self
Sets the position of the text within (or extending out of) the
layout_bounds.
The default is:
Positioning {
x: PositioningX::Center,
line_y: PositioningY::BodyMiddle,
z: PositioningZ::Back,
}Sourcepub fn layout_bounds(self, resolution: Resolution, bounds: GridAab) -> Self
pub fn layout_bounds(self, resolution: Resolution, bounds: GridAab) -> Self
Sets the voxel bounding box within which the text is positioned, as well as the resolution since that determines the coordinate system scale.
The text might overflow this box; it is currently used only to choose the positioning of the text and cannot constrain it.
Sourcepub fn debug(self, debug: bool) -> Self
pub fn debug(self, debug: bool) -> Self
Sets the debug-rendering flag.
If true, then the text rendering is modified in an unspecified way which is intended to assist in diagnosing issues with text layout configuration. In particular, this currently includes:
- The region which is in bounds but not filled by a character is filled with a semi-transparent marker color instead of being transparent.
- If a
Primitive::Textblock’s bounds fail to intersect itsText, then the block is filled with a marker color.
Trait Implementations§
Source§impl Clone for TextBuilder
impl Clone for TextBuilder
Source§fn clone(&self) -> TextBuilder
fn clone(&self) -> TextBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TextBuilder
impl Debug for TextBuilder
Auto Trait Implementations§
impl Freeze for TextBuilder
impl RefUnwindSafe for TextBuilder
impl Send for TextBuilder
impl Sync for TextBuilder
impl Unpin for TextBuilder
impl UnwindSafe for TextBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more