Merge pull request #6652 from penpot/elenatorro-fix-load-fonts

🐛 Fix fonts initialization
This commit is contained in:
Alejandro Alonso 2025-06-09 09:31:00 +02:00 committed by GitHub
commit d008ea9edd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 67 additions and 54 deletions

View file

@ -66,7 +66,7 @@ impl FontStore {
is_emoji: bool,
is_fallback: bool,
) -> Result<(), String> {
if self.has_family(&family) {
if self.has_family(&family, is_emoji) {
return Ok(());
}
@ -92,9 +92,14 @@ impl FontStore {
Ok(())
}
pub fn has_family(&self, family: &FontFamily) -> bool {
let serialized = format!("{}", family);
self.font_provider.family_names().any(|x| x == serialized)
pub fn has_family(&self, family: &FontFamily, is_emoji: bool) -> bool {
let alias = format!("{}", family);
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> {

View file

@ -31,11 +31,19 @@ pub extern "C" fn store_font(
}
#[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, {
let id = uuid_from_u32_quartet(a, b, c, d);
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
})