Skip to content

Commit fe960b8

Browse files
authored
Merge pull request #203 from kyasu1/fix-CJK-font-issue
CJK fonts rendering works as expected
2 parents e802807 + 836b764 commit fe960b8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/font.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,10 @@ impl ParsedFont {
422422
for gid in glyph_ids.keys() {
423423
let (width, _) = match self.get_glyph_size(*gid) {
424424
Some(s) => s,
425-
None => continue,
425+
None => match self.get_space_width() {
426+
Some(w) => (w as i32, 0),
427+
None => (0, 0),
428+
},
426429
};
427430

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

0 commit comments

Comments
 (0)