Move the text_input_byte_offset_for_position from the FontMetrics to the Window

In preparation of having mutiple-lines TextInput, we will need to give more
data to this function so it no longer belong in FontMetrics

Also remove the unused FontMetric::line_height()
This commit is contained in:
Olivier Goffart 2021-08-31 11:55:32 +02:00 committed by Olivier Goffart
parent e1be599bc0
commit c1fc242a9a
7 changed files with 77 additions and 64 deletions

View file

@ -156,13 +156,6 @@ pub trait FontMetrics {
/// Returns the size of the given string in logical pixels.
/// When set, `max_width` means that one need to wrap the text so it does not go further than that
fn text_size(&self, text: &str, max_width: Option<f32>) -> Size;
/// Returns the height of a line of text.
fn line_height(&self) -> f32;
/// Returns the (UTF-8) byte offset in the given text that refers to the character that contributed to
/// the glyph cluster that's visually nearest to the given x coordinate. This is used for hit-testing,
/// for example when receiving a mouse click into a text field. Then this function returns the "cursor"
/// position.
fn text_offset_for_x_position(&self, text: &str, x: f32) -> usize;
}
#[cfg(feature = "ffi")]