From f42d759131a10a34c20c0914600bca904fda3b9b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 13 Apr 2021 11:26:13 +0200 Subject: [PATCH] Remove dead code The height method on FontMetrics is not needed anymore. We call `text_size` nowadays. --- sixtyfps_runtime/corelib/graphics.rs | 4 ---- sixtyfps_runtime/rendering_backends/gl/lib.rs | 12 ------------ sixtyfps_runtime/rendering_backends/qt/qt_window.rs | 6 ------ 3 files changed, 22 deletions(-) diff --git a/sixtyfps_runtime/corelib/graphics.rs b/sixtyfps_runtime/corelib/graphics.rs index 2632dc436..7d594066e 100644 --- a/sixtyfps_runtime/corelib/graphics.rs +++ b/sixtyfps_runtime/corelib/graphics.rs @@ -135,10 +135,6 @@ pub trait FontMetrics { /// for example when receiving a mouse click into a text field. Then this function returns the "cursor" /// position. fn text_offset_for_x_position<'a>(&self, text: &'a str, x: f32) -> usize; - /// Returns the height of the font. This is typically the sum of the ascent and the descent, resulting - /// in the height that can fit the talltest glyphs of the font. Note that it is possible though that - /// the font may include glyphs that exceed this. - fn height(&self) -> f32; } #[cfg(feature = "ffi")] diff --git a/sixtyfps_runtime/rendering_backends/gl/lib.rs b/sixtyfps_runtime/rendering_backends/gl/lib.rs index d0c2b2f50..a31ab1124 100644 --- a/sixtyfps_runtime/rendering_backends/gl/lib.rs +++ b/sixtyfps_runtime/rendering_backends/gl/lib.rs @@ -1420,18 +1420,6 @@ impl FontMetrics for GLFontMetrics { } return text.len(); } - - fn height(&self) -> f32 { - self.shared_data - .canvas - .borrow_mut() - .measure_font(self.font().init_paint( - self.request.letter_spacing.unwrap_or_default(), - femtovg::Paint::default(), - )) - .unwrap() - .height() - } } impl GLFontMetrics { diff --git a/sixtyfps_runtime/rendering_backends/qt/qt_window.rs b/sixtyfps_runtime/rendering_backends/qt/qt_window.rs index 1afc83a57..b1fdf885a 100644 --- a/sixtyfps_runtime/rendering_backends/qt/qt_window.rs +++ b/sixtyfps_runtime/rendering_backends/qt/qt_window.rs @@ -1075,12 +1075,6 @@ impl sixtyfps_corelib::graphics::FontMetrics for QFont { return QStringView(string).left(cur).toUtf8().size(); }} } - - fn height(&self) -> f32 { - cpp! { unsafe [self as "const QFont*"] -> f32 as "float"{ - return QFontMetricsF(*self).height(); - }} - } } thread_local! {