[][src]Struct kas_text::Environment

pub struct Environment {
    pub bounds: Vec2,
    pub dpp: f32,
    pub pt_size: f32,
    pub dir: Direction,
    pub bidi: bool,
    pub halign: Align,
    pub valign: Align,
    pub wrap: bool,
}

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]

impl Debug for Environment[src]

impl Default for Environment[src]

impl PartialEq<Environment> for Environment[src]

impl StructuralPartialEq for Environment[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.