Movatterモバイル変換


[0]ホーム

URL:


Docs.rs

[][src]Crategfx_glyph

Fast GPU cached text rendering using gfx-rs & rusttype.

Makes use of three kinds of caching to optimise frame performance.

  • Caching of glyph positioning output to avoid repeated cost of identical textrendering on sequential frames.
  • Caches draw calculations to avoid repeated cost of identical text rendering onsequential frames.
  • GPU cache logic to dynamically maintain a GPU texture of rendered glyphs.

Example

usegfx_glyph::{GlyphBrushBuilder,Section};letdejavu:&[u8]=include_bytes!("../../fonts/DejaVuSans.ttf");letmutglyph_brush=GlyphBrushBuilder::using_font_bytes(dejavu).build(gfx_factory.clone());letsection=Section {text:"Hello gfx_glyph",    ..Section::default()};glyph_brush.queue(section);glyph_brush.queue(some_other_section);glyph_brush.use_queue().draw(&mutgfx_encoder,&gfx_color)?;

Modules

rusttype

Re-exported rusttype types.

Structs

DrawBuilder

Short-lived builder for drawing glyphs, constructed fromGlyphBrush::use_queue.

Font

A single font. This may or may not own the font data.

FontId

Id for a font

GlyphBrush

Object allowing glyph drawing, containing cache state. Manages glyph positioning cacheing,glyph draw caching & efficient GPU texture cache updating and re-sizing on demand.

GlyphBrushBuilder

Builder for aGlyphBrush.

OwnedSectionText
OwnedVariedSection
Point

A point in 2-dimensional space, with each dimension of typeN.

PositionedGlyph

A glyph augmented with positioning and scaling information. You can querysuch a glyph for information that depends on the scale and position of theglyph.

Rect

A rectangle, with top-left corner atmin, and bottom-right corner atmax.

Scale

Defines the size of a rendered face of a font, in pixels, horizontally andvertically. A vertical scale ofy pixels means that the distance betwenthe ascent and descent lines (seeVMetrics) of the face will beypixels. Ifx andy are equal the scaling is uniform. Non-uniform scalingby a factorf in the horizontal direction is achieved by settingx equaltof timesy.

Section

An object that contains all the info to render a section of text.

SectionGeometry
SectionText
VariedSection

An object that contains all the info to render a varied section of text. That is one includingmany parts with differing fonts/scales/colors bowing to a single layout.

Enums

BuiltInLineBreaker

Built-in linebreaking logic.

HorizontalAlign

Describes horizontal alignment preference for positioning & bounds.

Layout

Built-inGlyphPositioner implementations.

LineBreak

Indicator that a character is a line break, soft or hard. Includes the offset (byte-index)position.

SharedBytes

SharedBytes handles the lifetime of font data used in RustType. The datais either a shared reference to externally owned data, or managed byreference counting.SharedBytes can be conveniently used withFrom andInto, and dereferences to the contained bytes.

VerticalAlign

Describes vertical alignment preference for positioning & bounds. Currently a placeholderfor future functionality.

Traits

FontMap

Mapper ofFontId ->Font

GlyphCruncher

Common glyph layout logic.

GlyphPositioner

Logic to calculate glyph positioning usingFont,SectionGeometry andSectionText.

LineBreaker

Producer of aLineBreak iterator. Used to allow to theLayout to be line break aware in a generic way.

Functions

default_transform

Returns the default 4 dimensional matrix orthographic projection used for drawing.

Type Definitions

PositionedGlyphIter

PositionedGlyph iterator.

Help

Keyboard Shortcuts

?
Show this help dialog
S
Focus the search field
Move up in search results
Move down in search results
Switch tab
Go to active search result
+
Expand all sections
-
Collapse all sections

Search Tricks

Prefix searches with a type followed by a colon (e.g.,fn:) to restrict the search to a given type.

Accepted types are:fn,mod,struct,enum,trait,type,macro, andconst.

Search functions by type signature (e.g.,vec -> usize or* -> vec)

Search multiple things at once by splitting your query with comma (e.g.,str,u8 orString,struct:Vec,test)


[8]
ページ先頭

©2009-2025 Movatter.jp