Store font ID with CacheKey
This commit is contained in:
parent
1bce05d995
commit
81cc65ca01
2 changed files with 4 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||||
pub struct CacheKey {
|
pub struct CacheKey {
|
||||||
|
pub font_id: fontdb::ID,
|
||||||
pub glyph_id: u16,
|
pub glyph_id: u16,
|
||||||
pub font_size: i32,
|
pub font_size: i32,
|
||||||
pub x_bin: SubpixelBin,
|
pub x_bin: SubpixelBin,
|
||||||
|
|
@ -7,11 +8,12 @@ pub struct CacheKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CacheKey {
|
impl CacheKey {
|
||||||
pub fn new(glyph_id: u16, font_size: i32, pos: (f32, f32)) -> (Self, i32, i32) {
|
pub fn new(font_id: fontdb::ID, glyph_id: u16, font_size: i32, pos: (f32, f32)) -> (Self, i32, i32) {
|
||||||
let (x, x_bin) = SubpixelBin::new(pos.0);
|
let (x, x_bin) = SubpixelBin::new(pos.0);
|
||||||
let (y, y_bin) = SubpixelBin::new(pos.1);
|
let (y, y_bin) = SubpixelBin::new(pos.1);
|
||||||
(
|
(
|
||||||
Self {
|
Self {
|
||||||
|
font_id,
|
||||||
glyph_id,
|
glyph_id,
|
||||||
font_size,
|
font_size,
|
||||||
x_bin,
|
x_bin,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ impl<'a> FontShapeGlyph<'a> {
|
||||||
let y_offset = font_size as f32 * self.y_offset;
|
let y_offset = font_size as f32 * self.y_offset;
|
||||||
let x_advance = font_size as f32 * self.x_advance;
|
let x_advance = font_size as f32 * self.x_advance;
|
||||||
|
|
||||||
let inner = CacheKey::new(self.inner, font_size, (x + x_offset, y - y_offset));
|
let inner = CacheKey::new(self.font.info.id, self.inner, font_size, (x + x_offset, y - y_offset));
|
||||||
FontLayoutGlyph {
|
FontLayoutGlyph {
|
||||||
start: self.start,
|
start: self.start,
|
||||||
end: self.end,
|
end: self.end,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue