Do not require lifetime for swash fontref
This commit is contained in:
parent
525c4efaa5
commit
3e8e28f0b3
2 changed files with 15 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ pub struct Font<'a> {
|
|||
pub index: u32,
|
||||
pub rustybuzz: rustybuzz::Face<'a>,
|
||||
#[cfg(feature = "swash")]
|
||||
pub swash: swash::FontRef<'a>,
|
||||
pub swash: (u32, swash::CacheKey),
|
||||
}
|
||||
|
||||
impl<'a> Font<'a> {
|
||||
|
|
@ -28,7 +28,19 @@ impl<'a> Font<'a> {
|
|||
index: info.index,
|
||||
rustybuzz: rustybuzz::Face::from_slice(data, info.index)?,
|
||||
#[cfg(feature = "swash")]
|
||||
swash: swash::FontRef::from_index(data, info.index as usize)?,
|
||||
swash: {
|
||||
let swash = swash::FontRef::from_index(data, info.index as usize)?;
|
||||
(swash.offset, swash.key)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "swash")]
|
||||
pub fn as_swash(&self) -> swash::FontRef {
|
||||
swash::FontRef {
|
||||
data: self.data,
|
||||
offset: self.swash.0,
|
||||
key: self.swash.1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ impl SwashCache {
|
|||
|
||||
// Build the scaler
|
||||
let mut scaler = self.context
|
||||
.builder(font.swash)
|
||||
.builder(font.as_swash())
|
||||
.size(cache_key.font_size as f32)
|
||||
.hint(true)
|
||||
.build();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue