From 7436c107c169a49953abf6d4ee195a446742fae1 Mon Sep 17 00:00:00 2001 From: Junyoung Cho Date: Mon, 16 Sep 2013 14:08:22 +0900 Subject: [PATCH] Fix android/font.rs. Add an issue in macos/font.rs --- src/components/gfx/platform/android/font.rs | 18 +++++++++++++++++- src/components/gfx/platform/macos/font.rs | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/gfx/platform/android/font.rs b/src/components/gfx/platform/android/font.rs index 2bc62b76a53..b8b08cc9599 100644 --- a/src/components/gfx/platform/android/font.rs +++ b/src/components/gfx/platform/android/font.rs @@ -219,6 +219,7 @@ impl FontHandleMethods for FontHandle { } } + #[fixed_stack_segment] fn get_metrics(&self) -> FontMetrics { /* TODO(Issue #76): complete me */ let face = self.get_face_rec(); @@ -230,11 +231,26 @@ impl FontHandleMethods for FontHandle { let descent = self.font_units_to_au(face.descender as float); let max_advance = self.font_units_to_au(face.max_advance_width as float); + let mut strikeout_size = geometry::from_pt(0.0); + let mut strikeout_offset = geometry::from_pt(0.0); + let mut x_height = geometry::from_pt(0.0); + unsafe { + let os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2) as *TT_OS2; + let valid = os2.is_not_null() && (*os2).version != 0xffff; + if valid { + strikeout_size = self.font_units_to_au((*os2).yStrikeoutSize as float); + strikeout_offset = self.font_units_to_au((*os2).yStrikeoutPosition as float); + x_height = self.font_units_to_au((*os2).sxHeight as float); + } + } + return FontMetrics { underline_size: underline_size, underline_offset: underline_offset, + strikeout_size: strikeout_size, + strikeout_offset: strikeout_offset, leading: geometry::from_pt(0.0), //FIXME - x_height: geometry::from_pt(0.0), //FIXME + x_height: x_height, em_size: em_size, ascent: ascent, descent: -descent, // linux font's seem to use the opposite sign from mac diff --git a/src/components/gfx/platform/macos/font.rs b/src/components/gfx/platform/macos/font.rs index 6ace03423dd..6e51c758823 100644 --- a/src/components/gfx/platform/macos/font.rs +++ b/src/components/gfx/platform/macos/font.rs @@ -171,8 +171,8 @@ impl FontHandleMethods for FontHandle { // see also: https://bugs.webkit.org/show_bug.cgi?id=16768 // see also: https://bugreports.qt-project.org/browse/QTBUG-13364 underline_offset: Au::from_pt(self.ctfont.underline_position() as float), - strikeout_size: geometry::from_pt(0.0), //FIXME - strikeout_offset: geometry::from_pt(0.0), //FIXME + strikeout_size: geometry::from_pt(0.0), // FIXME(Issue #942) + strikeout_offset: geometry::from_pt(0.0), // FIXME(Issue #942) leading: Au::from_pt(self.ctfont.leading() as float), x_height: Au::from_pt(self.ctfont.x_height() as float), em_size: em_size,