Struct rusttype::gpu_cache::CacheBuilder [] [src]

pub struct CacheBuilder {
    pub width: u32,
    pub height: u32,
    pub scale_tolerance: f32,
    pub position_tolerance: f32,
    pub pad_glyphs: bool,
}

Builder for a Cache.

Example

use rusttype::gpu_cache::CacheBuilder;

let default_cache = CacheBuilder {
    width: 256,
    height: 256,
    scale_tolerance: 0.1,
    position_tolerance: 0.1,
    pad_glyphs: true,
}.build();

let bigger_cache = CacheBuilder {
    width: 1024,
    height: 1024,
    ..CacheBuilder::default()
}.build();

Fields

Along with height specifies the dimensions of the 2D texture that will hold the cache contents on the GPU.

This must match the dimensions of the actual texture used, otherwise cache_queued will try to cache into coordinates outside the bounds of the texture.

Along with width specifies the dimensions of the 2D texture that will hold the cache contents on the GPU.

This must match the dimensions of the actual texture used, otherwise cache_queued will try to cache into coordinates outside the bounds of the texture.

Specifies the tolerances (maximum allowed difference) for judging whether an existing glyph in the cache is close enough to the requested glyph in scale to be used in its place. Due to floating point inaccuracies that can affect user code it is not recommended to set these parameters too close to zero as effectively identical glyphs could end up duplicated in the cache.

Both scale_tolerance and position_tolerance are measured in pixels.

A typical application will produce results with no perceptible inaccuracies with scale_tolerance and position_tolerance set to 0.1. Depending on the target DPI higher tolerance may be acceptable.

Specifies the tolerances (maximum allowed difference) for judging whether an existing glyph in the cache is close enough to the requested glyph in subpixel offset to be used in its place. Due to floating point inaccuracies that can affect user code it is not recommended to set these parameters too close to zero as effectively identical glyphs could end up duplicated in the cache.

Both scale_tolerance and position_tolerance are measured in pixels.

Note that since position_tolerance is a tolerance of subpixel offsets, setting it to 1.0 or higher is effectively a "don't care" option.

A typical application will produce results with no perceptible inaccuracies with scale_tolerance and position_tolerance set to 0.1. Depending on the target DPI higher tolerance may be acceptable.

Pack glyphs in texture with a padding of a single zero alpha pixel to avoid bleeding from interpolated shader texture lookups near edges.

If glyphs are never transformed this may be set to false to slightly improve the glyph packing.

Methods

impl CacheBuilder
[src]

[src]

Constructs a new cache. Note that this is just the CPU side of the cache. The GPU texture is managed by the user.

Panics

scale_tolerance or position_tolerance are less than or equal to zero.

Trait Implementations

impl Debug for CacheBuilder
[src]

[src]

Formats the value using the given formatter. Read more

impl Clone for CacheBuilder
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for CacheBuilder
[src]

[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl Send for CacheBuilder

impl Sync for CacheBuilder