mirror of
https://github.com/penpot/penpot.git
synced 2025-07-19 01:47:17 +02:00
🐛 Cache emoji font correctly
This commit is contained in:
parent
79e1c29306
commit
8c20159fb0
3 changed files with 21 additions and 7 deletions
|
@ -131,7 +131,8 @@
|
||||||
(aget id-buffer 2)
|
(aget id-buffer 2)
|
||||||
(aget id-buffer 3)
|
(aget id-buffer 3)
|
||||||
(:weight font-data)
|
(:weight font-data)
|
||||||
(:style font-data)))]
|
(:style font-data)
|
||||||
|
emoji?))]
|
||||||
(when-not font-stored?
|
(when-not font-stored?
|
||||||
(store-font-url font-data uri emoji? fallback?)))))
|
(store-font-url font-data uri emoji? fallback?)))))
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl FontStore {
|
||||||
is_emoji: bool,
|
is_emoji: bool,
|
||||||
is_fallback: bool,
|
is_fallback: bool,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
if self.has_family(&family) {
|
if self.has_family(&family, is_emoji) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,9 +92,14 @@ impl FontStore {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_family(&self, family: &FontFamily) -> bool {
|
pub fn has_family(&self, family: &FontFamily, is_emoji: bool) -> bool {
|
||||||
let serialized = format!("{}", family);
|
let alias = format!("{}", family);
|
||||||
self.font_provider.family_names().any(|x| x == serialized)
|
let font_name = if is_emoji {
|
||||||
|
DEFAULT_EMOJI_FONT
|
||||||
|
} else {
|
||||||
|
alias.as_str()
|
||||||
|
};
|
||||||
|
self.font_provider.family_names().any(|x| x == font_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_fallback(&self) -> &HashSet<String> {
|
pub fn get_fallback(&self) -> &HashSet<String> {
|
||||||
|
|
|
@ -31,11 +31,19 @@ pub extern "C" fn store_font(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn is_font_uploaded(a: u32, b: u32, c: u32, d: u32, weight: u32, style: u8) -> bool {
|
pub extern "C" fn is_font_uploaded(
|
||||||
|
a: u32,
|
||||||
|
b: u32,
|
||||||
|
c: u32,
|
||||||
|
d: u32,
|
||||||
|
weight: u32,
|
||||||
|
style: u8,
|
||||||
|
is_emoji: bool,
|
||||||
|
) -> bool {
|
||||||
with_state!(state, {
|
with_state!(state, {
|
||||||
let id = uuid_from_u32_quartet(a, b, c, d);
|
let id = uuid_from_u32_quartet(a, b, c, d);
|
||||||
let family = FontFamily::new(id, weight, style.into());
|
let family = FontFamily::new(id, weight, style.into());
|
||||||
let res = state.render_state().fonts().has_family(&family);
|
let res = state.render_state().fonts().has_family(&family, is_emoji);
|
||||||
|
|
||||||
res
|
res
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue