From ddcde6d1aeb68444775a51212d8c80b0cdea7aec Mon Sep 17 00:00:00 2001 From: fschutt Date: Fri, 13 Apr 2018 11:50:52 +0200 Subject: [PATCH] Fix the API of glyph_dimensions to make webrender compile on Windows --- font-renderer/src/directwrite/mod.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/font-renderer/src/directwrite/mod.rs b/font-renderer/src/directwrite/mod.rs index 86ec3c57..9f495067 100644 --- a/font-renderer/src/directwrite/mod.rs +++ b/font-renderer/src/directwrite/mod.rs @@ -193,11 +193,14 @@ impl FontContext where FK: Clone + Hash + Eq + Ord { /// libraries (including Pathfinder) apply modifications to the outlines: for example, to /// dilate them for easier reading. To retrieve extents that account for these modifications, /// set `exact` to false. - pub fn glyph_dimensions(&self, font_instance: &FontInstance, glyph_key: &GlyphKey) - -> Option { + pub fn glyph_dimensions(&self, + font_instance: &FontInstance, + glyph_key: &GlyphKey, + _exact: bool) + -> Result { unsafe { let font_face = match self.dwrite_font_faces.get(&font_instance.font_key) { - None => return None, + None => return Err(()), Some(font_face) => (*font_face).clone(), }; @@ -206,10 +209,10 @@ impl FontContext where FK: Clone + Hash + Eq + Ord { let result = (**font_face).GetDesignGlyphMetrics(&glyph_index, 1, &mut metrics, FALSE); if !winerror::SUCCEEDED(result) { - return None + return Err(()); } - Some(GlyphDimensions { + Ok(GlyphDimensions { advance: metrics.advanceWidth as f32, origin: Point2D::new(metrics.leftSideBearing, metrics.bottomSideBearing), size: Size2D::new((metrics.rightSideBearing - metrics.leftSideBearing) as u32,