aboutsummaryrefslogtreecommitdiff
path: root/font
diff options
context:
space:
mode:
Diffstat (limited to 'font')
-rw-r--r--font/src/darwin/mod.rs4
-rw-r--r--font/src/ft/mod.rs9
-rw-r--r--font/src/lib.rs2
3 files changed, 15 insertions, 0 deletions
diff --git a/font/src/darwin/mod.rs b/font/src/darwin/mod.rs
index 14381113..89858f77 100644
--- a/font/src/darwin/mod.rs
+++ b/font/src/darwin/mod.rs
@@ -422,11 +422,15 @@ impl Font {
let descent = self.ct_font.descent() as f64;
let leading = self.ct_font.leading() as f64;
let line_height = (ascent + descent + leading + 0.5).floor();
+ let underline_position = self.ct_font.underline_position() as f32;
+ let underline_thickness = self.ct_font.underline_thickness() as f32;
Metrics {
average_advance: average_advance,
line_height: line_height,
descent: -(self.ct_font.descent() as f32),
+ underline_position,
+ underline_thickness,
}
}
diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs
index 68d2faf3..6d77a61c 100644
--- a/font/src/ft/mod.rs
+++ b/font/src/ft/mod.rs
@@ -86,15 +86,24 @@ impl ::Rasterize for FreeTypeRasterizer {
}
fn metrics(&self, key: FontKey) -> Result<Metrics, Error> {
+ let face = self.faces
+ .get(&key)
+ .ok_or(Error::FontNotLoaded)?;
let full = self.full_metrics(key)?;
let height = (full.size_metrics.height / 64) as f64;
let descent = (full.size_metrics.descender / 64) as f32;
+ let underline_position =
+ (f32::from(face.ft_face.underline_position()) / 64.).round();
+ let underline_thickness =
+ (f32::from(face.ft_face.underline_thickness()) / 64.).round();
Ok(Metrics {
average_advance: full.cell_width,
line_height: height,
descent: descent,
+ underline_position,
+ underline_thickness,
})
}
diff --git a/font/src/lib.rs b/font/src/lib.rs
index 330ed362..7a8ac7a7 100644
--- a/font/src/lib.rs
+++ b/font/src/lib.rs
@@ -314,6 +314,8 @@ pub struct Metrics {
pub average_advance: f64,
pub line_height: f64,
pub descent: f32,
+ pub underline_position: f32,
+ pub underline_thickness: f32,
}
pub trait Rasterize {