Struct kas_text::Environment
source · [−]pub struct Environment {
pub flags: EnvFlags,
pub dir: Direction,
pub font_id: FontId,
pub dpp: f32,
pub pt_size: f32,
pub bounds: Vec2,
pub align: (Align, Align),
}
Expand description
Environment in which text is prepared for display
An Environment
can be default-constructed (without line-wrapping).
Fields
flags: EnvFlags
Flags enabling/disabling certain features
Bidirectional text
If enabled, right-to-left text embedded within left-to-right text and LTR within RTL will be re-ordered according to the Unicode Bidirectional Algorithm (Unicode Technical Report #9).
If disabled, the base paragraph direction may be LTR or RTL depending on
Environment::dir
, but embedded text is not re-ordered.
Default value: true
. This should normally be enabled unless there is
a specific reason to disable it.
Line wrapping
By default, this is true and long text lines are wrapped based on the
width bounds. If set to false, lines are not wrapped at the width
boundary, but explicit line-breaks such as \n
still result in new
lines.
dir: Direction
Default text direction
Usually this may be left to its default value of Direction::Auto
.
If bidi == true
, this parameter sets the “paragraph embedding level”
(whose main affect is on lines without strongly-directional characters).
If bidi == false
this directly sets the line direction, unless
dir == Auto
, in which case direction is auto-detected.
font_id: FontId
Default font
This font is used unless a formatting token (see crate::format
)
is used.
dpp: f32
Pixels-per-point
This is a scaling factor used to convert font sizes (in points) to a
size in pixels (dots). Units are pixels/point
. See crate::fonts
documentation.
Default value: 96.0 / 72.0
pt_size: f32
Default font size in points
We use “point sizes” (Points per Em), since this is a widely used
measure of font size. See crate::fonts
module documentation.
Default value: 11.0
bounds: Vec2
The available (horizontal and vertical) space
This defaults to infinity (implying no bounds). To enable line-wrapping set at least a horizontal bound. The vertical bound is required for alignment (when aligning to the center or bottom). Glyphs outside of these bounds may not be drawn.
align: (Align, Align)
Alignment (horiz
, vert
)
By default, horizontal alignment is left or right depending on the
text direction (see Environment::dir
), and vertical alignment is
to the top.
Implementations
sourceimpl Environment
impl Environment
sourceimpl Environment
impl Environment
Trait Implementations
sourceimpl Clone for Environment
impl Clone for Environment
sourcefn clone(&self) -> Environment
fn clone(&self) -> Environment
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Environment
impl Debug for Environment
sourceimpl Default for Environment
impl Default for Environment
sourceimpl PartialEq<Environment> for Environment
impl PartialEq<Environment> for Environment
sourcefn eq(&self, other: &Environment) -> bool
fn eq(&self, other: &Environment) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Environment) -> bool
fn ne(&self, other: &Environment) -> bool
This method tests for !=
.
impl StructuralPartialEq for Environment
Auto Trait Implementations
impl RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl UnwindSafe for Environment
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<S, T> CastFloat<T> for S where
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for S where
T: ConvFloat<S>,
sourcepub fn cast_trunc(self) -> T
pub fn cast_trunc(self) -> T
Cast to integer, truncating Read more
sourcepub fn cast_nearest(self) -> T
pub fn cast_nearest(self) -> T
Cast to the nearest integer Read more
sourcepub fn cast_floor(self) -> T
pub fn cast_floor(self) -> T
Cast the floor to an integer Read more
sourcepub fn try_cast_trunc(self) -> Result<T, Error>
pub fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
sourcepub fn try_cast_nearest(self) -> Result<T, Error>
pub fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
sourcepub fn try_cast_floor(self) -> Result<T, Error>
pub fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
sourcepub fn try_cast_ceil(self) -> Result<T, Error>
pub fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more