Skip to content

Commit 5342270

Browse files
committed
core: Always enable kerning for device fonts
The kerning setting works only for embedded fonts, and it does not affect device fonts at all. Kerning is always enabled for device fonts. Flash documentation also mentions that the kerning setting only affects embedded fonts.
1 parent 426537a commit 5342270

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/src/font.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ pub enum FontType {
411411
}
412412

413413
impl FontType {
414+
pub fn is_device(self) -> bool {
415+
self == Self::Device
416+
}
417+
414418
pub fn is_embedded(self) -> bool {
415419
self != Self::Device
416420
}
@@ -744,15 +748,16 @@ pub trait FontLike<'gc> {
744748
// TODO [KJ] I'm not sure whether we should iterate over characters here or over code units.
745749
// I suspect Flash Player does not support full UTF-16 when displaying and laying out text.
746750
let mut char_indices = text.char_indices().peekable();
747-
let has_kerning_info = self.has_kerning_info();
751+
let kerning_enabled =
752+
self.has_kerning_info() && (self.font_type().is_device() || params.kerning);
748753
let mut x = Twips::ZERO;
749754
while let Some((pos, c)) = char_indices.next() {
750755
let c = c.unwrap_or(char::REPLACEMENT_CHARACTER);
751756
if let Some(render_data) = self.get_glyph_render_data(c) {
752757
let glyph = render_data.glyph;
753758
let scale = params.height.get() as f32 / render_data.font.scale();
754759
let mut advance = glyph.advance();
755-
if has_kerning_info && params.kerning {
760+
if kerning_enabled {
756761
let next_char = char_indices.peek().cloned().unwrap_or((0, Ok('\0'))).1;
757762
let next_char = next_char.unwrap_or(char::REPLACEMENT_CHARACTER);
758763
advance += self.get_kerning_offset(c, next_char);

0 commit comments

Comments
 (0)