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
width: u32
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.
height: u32
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.
scale_tolerance: f32
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.
position_tolerance: f32
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.
pad_glyphs: bool
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]
pub fn build<'a>(self) -> Cache<'a>
[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]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for CacheBuilder
[src]
fn clone(&self) -> CacheBuilder
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more