Skip to content

Commit

Permalink
avm2: Do not enumerate fonts without a layout
Browse files Browse the repository at this point in the history
Flash does not enumerate fonts which do not have a layout defined.
Fonts without a layout are used only to refer to existing fonts
and they do not provide glyphs.
  • Loading branch information
kjarosh committed Jan 14, 2025
1 parent 0f4ecc7 commit 428ed70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/avm2/globals/flash/text/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub fn enumerate_fonts<'gc>(
for font in library.embedded_fonts() {
// TODO: EmbeddedCFF isn't supposed to show until it's been used (some kind of internal initialization method?)
// Device is only supposed to show when arg0 is true - but that's supposed to be "all known" device fonts, not just loaded ones
if font.font_type() == FontType::Embedded {
if font.has_layout() && font.font_type() == FontType::Embedded {
storage.push(FontObject::for_font(activation.gc(), font_class, font).into());
}
}
Expand Down
13 changes: 13 additions & 0 deletions core/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ struct FontData {
descriptor: FontDescriptor,

font_type: FontType,

/// Whether this font has a layout defined.
///
/// Fonts without a layout are used only to describe a font,
/// not to provide glyphs.
has_layout: bool,
}

impl<'gc> Font<'gc> {
Expand All @@ -385,6 +391,7 @@ impl<'gc> Font<'gc> {
glyphs: GlyphSource::FontFace(face),
descriptor,
font_type,
has_layout: true,
},
)))
}
Expand Down Expand Up @@ -463,6 +470,7 @@ impl<'gc> Font<'gc> {
leading,
descriptor,
font_type,
has_layout: tag.layout.is_some(),
},
))
}
Expand Down Expand Up @@ -513,6 +521,7 @@ impl<'gc> Font<'gc> {
glyphs: GlyphSource::Empty,
descriptor,
font_type,
has_layout: true,
},
))
}
Expand Down Expand Up @@ -759,6 +768,10 @@ impl<'gc> Font<'gc> {
pub fn font_type(&self) -> FontType {
self.0.font_type
}

pub fn has_layout(&self) -> bool {
self.0.has_layout
}
}

#[derive(Debug, Clone)]
Expand Down

0 comments on commit 428ed70

Please sign in to comment.