Struct cosmic_text::CacheKey
source · pub struct CacheKey {
pub font_id: ID,
pub glyph_id: u16,
pub font_size: i32,
pub x_bin: SubpixelBin,
pub y_bin: SubpixelBin,
}Expand description
Key for building a glyph cache
Fields§
§font_id: IDFont ID
glyph_id: u16Glyph ID
font_size: i32Font size in pixels
x_bin: SubpixelBinBinning of fractional X offset
y_bin: SubpixelBinBinning of fractional Y offset
Implementations§
source§impl CacheKey
impl CacheKey
sourcepub fn new(
font_id: ID,
glyph_id: u16,
font_size: i32,
pos: (f32, f32)
) -> (Self, i32, i32)
pub fn new(
font_id: ID,
glyph_id: u16,
font_size: i32,
pos: (f32, f32)
) -> (Self, i32, i32)
Examples found in repository?
src/shape.rs (lines 254-259)
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
fn layout(&self, font_size: i32, x: f32, y: f32, level: unicode_bidi::Level) -> LayoutGlyph {
let x_offset = font_size as f32 * self.x_offset;
let y_offset = font_size as f32 * self.y_offset;
let x_advance = font_size as f32 * self.x_advance;
let (cache_key, x_int, y_int) = CacheKey::new(
self.font_id,
self.glyph_id,
font_size,
(x + x_offset, y - y_offset)
);
LayoutGlyph {
start: self.start,
end: self.end,
x,
w: x_advance,
level,
cache_key,
x_offset,
y_offset,
x_int,
y_int,
color_opt: self.color_opt,
metadata: self.metadata,
}
}Trait Implementations§
source§impl Ord for CacheKey
impl Ord for CacheKey
source§impl PartialEq<CacheKey> for CacheKey
impl PartialEq<CacheKey> for CacheKey
source§impl PartialOrd<CacheKey> for CacheKey
impl PartialOrd<CacheKey> for CacheKey
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read more