[−][src]Struct kas_text::Environment
Environment in which text is prepared for display
An Environment
can be default-constructed (without line-wrapping).
Fields
bounds: Vec2
The available (horizontal and vertical) space
This defaults to infinity (implying no bounds). If line-wrapping is enabled, it is controlled by this width. Glyphs outside of these bounds may not be drawn.
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
.
Since "72 pt = 1 in" and the "standard" DPI is 96, calculate as:
dpp = dpi / 72 = scale_factor * (96 / 72)
Note that most systems allow the user to adjust the "font DPI" or set a scaling factor, thus this value may not correspond to the real pixel density of the display.
pt_size: f32
Default font size in points
This is stored in units of pt/em partly because this is a standard unit and partly because it allows fonts to scale with DPI.
dir: Direction
Default text direction
Note: right-to-left text can still occur in a left-to-right environment and vice-versa, however the default alignment direction can affect the layout of complex texts.
bidi: bool
Bidirectional text
If enabled, right-to-left text embedded within left-to-right text and RTL within LTR will be re-ordered correctly (up to the maximum embedding level defined by 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.
Normally this should be enabled, but within text-editors it might be disabled (at user's preference).
halign: Align
Horizontal alignment
valign: Align
Vertical alignment
wrap: bool
Line wrapping
If true, text is wrapped at word boundaries to fit within the available
width (regardless of height). If false, only explicit line-breaks such
as \n
result in new lines.
Implementations
impl Environment
[src]
pub fn new() -> Self
[src]
Alternative default constructor
Has left-to-right direction, default alignment, no line-wrapping,
default font FontScale
and zero-sized bounds.
pub fn line_height(&self, font_id: FontId) -> f32
[src]
Returns the height of a standard line
This depends on the pt_size
and dpp
fields.
To use "the standard font", use Default::default()
.
Trait Implementations
impl Clone for Environment
[src]
fn clone(&self) -> Environment
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Environment
[src]
impl Default for Environment
[src]
impl PartialEq<Environment> for Environment
[src]
fn eq(&self, other: &Environment) -> bool
[src]
fn ne(&self, other: &Environment) -> bool
[src]
impl StructuralPartialEq for Environment
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,