From 069f53a25ea07467b8c61be03c3bb03766305dd5 Mon Sep 17 00:00:00 2001 From: dhneio Date: Mon, 23 Feb 2015 04:36:18 -0800 Subject: [PATCH] Fix is_simple_advance check. Fixes #4614. --- components/gfx/text/glyph.rs | 7 +++++-- tests/ref/basic.list | 1 + tests/ref/font_advance.html | 2 ++ tests/ref/font_advance_ref.html | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tests/ref/font_advance.html create mode 100644 tests/ref/font_advance_ref.html diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index 5ebd33916e8..c5f803ca673 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -156,8 +156,11 @@ fn is_simple_glyph_id(id: GlyphId) -> bool { } fn is_simple_advance(advance: Au) -> bool { - let unsigned_au = advance.to_u32().unwrap(); - (unsigned_au & (GLYPH_ADVANCE_MASK >> GLYPH_ADVANCE_SHIFT as uint)) == unsigned_au + match advance.to_u32() { + Some(unsigned_au) => + (unsigned_au & (GLYPH_ADVANCE_MASK >> GLYPH_ADVANCE_SHIFT as uint)) == unsigned_au, + None => false + } } type DetailedGlyphCount = u16; diff --git a/tests/ref/basic.list b/tests/ref/basic.list index c66e6750ad5..3bbfc9c52d3 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -102,6 +102,7 @@ flaky_cpu == append_style_a.html append_style_b.html == floated_generated_content_a.html floated_generated_content_b.html == floated_list_item_a.html floated_list_item_ref.html == floated_table_with_margin_a.html floated_table_with_margin_ref.html +== font_advance.html font_advance_ref.html == font_size.html font_size_ref.html == font_style.html font_style_ref.html == height_compute_reset.html height_compute.html diff --git a/tests/ref/font_advance.html b/tests/ref/font_advance.html new file mode 100644 index 00000000000..91d871a656e --- /dev/null +++ b/tests/ref/font_advance.html @@ -0,0 +1,2 @@ + +a
Hello world
diff --git a/tests/ref/font_advance_ref.html b/tests/ref/font_advance_ref.html new file mode 100644 index 00000000000..91d871a656e --- /dev/null +++ b/tests/ref/font_advance_ref.html @@ -0,0 +1,2 @@ + +a
Hello world