Skip to content

Commit

Permalink
use en_US to decide metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
medicalwei authored and Lyude committed Nov 1, 2021
1 parent 37d3681 commit 4703ab6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ struct FontMetrix {

impl FontMetrix {
pub fn new(pango_context: pango::Context, line_space: i32) -> Self {
let font_metrics = pango_context.metrics(None, None).unwrap();
let font_metrics = pango_context
.metrics(None, Some(&pango::Language::from_string("en_US")))
.unwrap();
let font_desc = pango_context.font_description().unwrap();

FontMetrix {
Expand Down Expand Up @@ -128,18 +130,16 @@ impl CellMetrics {

let strikethrough_position =
(f64::from(font_metrics.strikethrough_position()) / f64::from(pango::SCALE)).ceil();
let strikethrough_thickness = (f64::from(font_metrics.strikethrough_thickness())
/ f64::from(pango::SCALE))
.ceil();
let strikethrough_thickness =
(f64::from(font_metrics.strikethrough_thickness()) / f64::from(pango::SCALE)).ceil();

CellMetrics {
pango_ascent: font_metrics.ascent(),
pango_descent: font_metrics.descent(),
pango_char_width: font_metrics.approximate_char_width(),
ascent,
line_height: ascent + descent + f64::from(line_space),
char_width: f64::from(font_metrics.approximate_char_width())
/ f64::from(pango::SCALE),
char_width: f64::from(font_metrics.approximate_char_width()) / f64::from(pango::SCALE),
underline_position: ascent - underline_position + underline_thickness / 2.0,
underline_thickness,
strikethrough_position: ascent - strikethrough_position + strikethrough_thickness / 2.0,
Expand Down

0 comments on commit 4703ab6

Please sign in to comment.