Skip to content

Commit

Permalink
Don't set monospace_em_width on Emoji fonts
Browse files Browse the repository at this point in the history
 "Noto Color Emoji" reports itself as a Monospace font. But resizing
 glyphs from such a font to fit a certain width may make emojis look
 rather small. So avoid font resizing with such fonts by not setting
 `monospace_em_width`.

 Fixes pop-os/cosmic-term#69.

Signed-off-by: Mohammad AlSaleh <[email protected]>
  • Loading branch information
MoSal committed Jan 18, 2024
1 parent a4a0c94 commit cfcfdda
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/font/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ impl Font {
let (monospace_em_width, unicode_codepoints) = {
db.with_face_data(id, |font_data, face_index| {
let face = ttf_parser::Face::parse(font_data, face_index).ok()?;
let monospace_em_width = info
.monospaced
let is_monospace = info.monospaced && !info.post_script_name.contains("Emoji");
let monospace_em_width = is_monospace
.then(|| {
let hor_advance = face.glyph_hor_advance(face.glyph_index(' ')?)? as f32;
let upem = face.units_per_em() as f32;
Some(hor_advance / upem)
})
.flatten();

if info.monospaced && monospace_em_width.is_none() {
if is_monospace && monospace_em_width.is_none() {
None?;
}

Expand Down

0 comments on commit cfcfdda

Please sign in to comment.