pub struct GlyphLoaderArg<'a> { /* private fields */ }Expand description
Arguments for GlyphLoader::load_glyph.
Having a struct instead of a collection of parameters makes it easier to write and use.
Implementations§
Source§impl GlyphLoaderArg<'_>
impl GlyphLoaderArg<'_>
Sourcepub fn dpi_density(&self) -> f32
pub fn dpi_density(&self) -> f32
Gets the rasterizer density (DPI) of the renderer that requests this glyph.
It is usually 1.0, but in hiDPI settings it may be 2.0 (or any other value, actually).
Sourcepub fn set_dpi_density(&mut self, scale: f32)
pub fn set_dpi_density(&mut self, scale: f32)
Sets the rasterizer density.
If you can’t (or don’t want to) support hiDPI environments you can disable it by either
setting the GlyphBuildFlags::IGNORE_DPI or by calling this function.
You can set it to values other than 1.0, but the usefulness is limited.
Sourcepub fn oversample(&self) -> Vector2
pub fn oversample(&self) -> Vector2
Gets the X/Y oversample factor.
This is usually (1.0, 1.0), but for small fonts, it may be (2.0, 1.0). If so, you should render your glyph scaled by these factors in X and Y.
Sourcepub fn set_oversample(&mut self, oversample: Vector2)
pub fn set_oversample(&mut self, oversample: Vector2)
Sets the X/Y oversample factor.
If you can’t (or don’t want to) support oversampling you can disable it by either
setting the GlyphBuildFlags::IGNORE_OVERSAMPLE or by calling this function.
Sourcepub fn only_advance_x(&self) -> bool
pub fn only_advance_x(&self) -> bool
Returns the “only advance X” flag.
If this is true, when you call build, the draw callback will not actually be called:
only the advance_x parameter will be used.
This is used by Dear ImGui when using very big fonts to compute the position of the glyphs before rendering them, to save space in the texture atlas.
You can safely ignore this, if you don’t need to micro-optimize the loading of very big custom fonts.
Sourcepub fn build(
self,
origin: Vector2,
size: Vector2,
advance_x: f32,
flags: GlyphBuildFlags,
draw: impl FnOnce(&mut SubImage<&'_ mut ImageBuffer<Rgba<u8>, &'_ mut [u8]>>),
)
pub fn build( self, origin: Vector2, size: Vector2, advance_x: f32, flags: GlyphBuildFlags, draw: impl FnOnce(&mut SubImage<&'_ mut ImageBuffer<Rgba<u8>, &'_ mut [u8]>>), )
Builds the requested glyph.
origin is the offset of the origin of the glyph, by default it will be just over the
baseline.
size is the size of the glyph, when drawn to the screen.
advance_x is how many pixels this glyph occupies when part of a string.
flags: how to interpret the size and scale the bitmap.
draw: callback that actually draws the glyph.
Note that draw() may not be actually called every time. You can use only_advance_x() to
detect this case, if you need it.
Auto Trait Implementations§
impl<'a> Freeze for GlyphLoaderArg<'a>
impl<'a> !RefUnwindSafe for GlyphLoaderArg<'a>
impl<'a> !Send for GlyphLoaderArg<'a>
impl<'a> !Sync for GlyphLoaderArg<'a>
impl<'a> Unpin for GlyphLoaderArg<'a>
impl<'a> !UnwindSafe for GlyphLoaderArg<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more