Skip to content

Commit

Permalink
Fix emoji glyph advance
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisduerr committed May 4, 2022
1 parent dd9658d commit 367319c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- FreeType proportional font metrics using `RasterizedGlyph::advance` and `Rasterize::kerning`

### Changed

- Minimum Rust version has been bumped to 1.56.0
Expand Down
6 changes: 5 additions & 1 deletion src/ft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ impl Rasterize for FreeTypeRasterizer {
}
}

// Transform glyphs with the matrix from Fontconfig. Primarily used to generate italics.
let advance = unsafe {
// Transform glyphs with the matrix from Fontconfig. Primarily used to generate italics.
let raw_glyph = face.ft_face.raw().glyph;
if let Some(matrix) = face.matrix.as_ref() {
// Check that the glyph is a vectorial outline, not a bitmap.
Expand Down Expand Up @@ -250,6 +250,10 @@ impl Rasterize for FreeTypeRasterizer {
},
};

// Scale glyph advance.
rasterized_glyph.advance.0 = (advance.0 as f64 * fixup_factor) as i32;
rasterized_glyph.advance.1 = (advance.1 as f64 * fixup_factor) as i32;

rasterized_glyph = downsample_bitmap(rasterized_glyph, fixup_factor);
}

Expand Down

0 comments on commit 367319c

Please sign in to comment.