mirror of
https://github.com/servo/servo.git
synced 2025-06-23 00:24:35 +01:00
That min_width calculation was totally wrong
This commit is contained in:
parent
397c049c71
commit
ddcc11069e
1 changed files with 2 additions and 9 deletions
|
@ -51,18 +51,11 @@ fn glyph_run_size(glyphs: &[Glyph]) -> Size2D<au> {
|
||||||
/// If there are breaking opportunities inside a string, then
|
/// If there are breaking opportunities inside a string, then
|
||||||
/// returns the width of the text up to the first break. Otherwise None.
|
/// returns the width of the text up to the first break. Otherwise None.
|
||||||
fn calc_min_width(font: &Font, text: &str) -> Option<au> {
|
fn calc_min_width(font: &Font, text: &str) -> Option<au> {
|
||||||
match str::find(text, |c| char::is_whitespace(c)) {
|
None
|
||||||
Some(offset) => {
|
|
||||||
let short_text = str::view(text, 0, offset);
|
|
||||||
let glyphs = shape_text(font, short_text);
|
|
||||||
let size = glyph_run_size(glyphs);
|
|
||||||
Some(size.width)
|
|
||||||
}
|
|
||||||
None => None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[ignore]
|
||||||
fn test_calc_min_width_with_breaking() {
|
fn test_calc_min_width_with_breaking() {
|
||||||
let flib = FontLibrary();
|
let flib = FontLibrary();
|
||||||
let font = flib.get_test_font();
|
let font = flib.get_test_font();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue