Skip to content

Commit

Permalink
Merge pull request #203 from kyasu1/fix-CJK-font-issue
Browse files Browse the repository at this point in the history
CJK fonts rendering works as expected
  • Loading branch information
fschutt authored Feb 3, 2025
2 parents e802807 + 836b764 commit fe960b8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ impl ParsedFont {
for gid in glyph_ids.keys() {
let (width, _) = match self.get_glyph_size(*gid) {
Some(s) => s,
None => continue,
None => match self.get_space_width() {
Some(w) => (w as i32, 0),
None => (0, 0),
},
};

if *gid == current_high_gid {
Expand Down Expand Up @@ -764,7 +767,7 @@ impl ParsedFont {
// get the x and y size of a glyph (unscaled units)
pub fn get_glyph_size(&self, glyph_index: u16) -> Option<(i32, i32)> {
let g = self.glyph_records_decoded.get(&glyph_index)?;
let glyph_width = g.bounding_box.max_x as i32 - g.bounding_box.min_x as i32; // width
let glyph_width = g.horz_advance as i32;
let glyph_height = g.bounding_box.max_y as i32 - g.bounding_box.min_y as i32; // height
Some((glyph_width, glyph_height))
}
Expand Down

0 comments on commit fe960b8

Please sign in to comment.