Skip to main content

DiagnosticTextRenderer

Struct DiagnosticTextRenderer 

Source
pub struct DiagnosticTextRenderer { /* private fields */ }
Expand description

A class used to render diagnostic strings (only!), with caching of ASCII glyph runs. Digits are laid out in equal-width cells so rapidly changing values do not make the text jump around.

Implementations§

Source§

impl DiagnosticTextRenderer

Source

pub fn get_max_height(&self) -> f64

Source

pub fn digit_cell_width(&self) -> f64

The width of the cell every digit is centered in.

Source

pub fn new(glyph_run_source: Rc<dyn IDiagnosticGlyphRunSource>) -> Self

Source

pub fn from_glyph_typeface( glyph_typeface: Rc<GlyphTypeface>, font_rendering_em_size: f64, ) -> Self

Creates a renderer whose glyph runs are built from glyph_typeface at font_rendering_em_size (the C# constructor).

Source

pub fn create_default() -> Self

Creates the renderer the compositor’s debug overlays use: the glyph typeface of the default typeface at an em size of 12.

Source

pub fn shape(&self, text: &str) -> ShapedText

Shapes text into a single glyph run that can be drawn with draw_shaped_text without any per-frame measuring or shaping. Every UTF-16 code unit outside the printable ASCII range is shaped as a space. Glyphs advance by their natural width, so digits are not placed in cells; use draw_digits for values that change.

Source

pub fn shape_label(&self, text: &'static str) -> Rc<ShapedText>

The label text shaped by shape, shaped the first time and shared after that. Not in the reference: the port shapes the fixed labels of the FPS counter on the UI thread with this, where the glyph runs can be created (ServerCompositor::diagnostic_text_renderer).

Source

pub fn draw_shaped_text( &self, context: &mut dyn IDrawingContextImpl, text: &ShapedText, foreground: &dyn IImmutableBrush, )

Draws text shaped by shape at the origin of the current transform of context.

Source

pub fn draw_digits( &self, context: &mut dyn IDrawingContextImpl, value: i32, digit_count: i32, foreground: &dyn IImmutableBrush, )

Draws a non-negative value zero padded to digit_count digits, each in its own digit_cell_width wide cell, without formatting a string. Values that do not fit are clamped to the largest representable value.

Source

pub fn measure_ascii_text(&self, text: &str) -> Size

Measures text. Every UTF-16 code unit outside the printable ASCII range is measured as a space.

Source

pub fn draw_ascii_text( &self, context: &mut dyn IDrawingContextImpl, text: &str, foreground: &dyn IImmutableBrush, )

Draws text at the origin of the current transform of context. Every UTF-16 code unit outside the printable ASCII range is drawn as a space.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.