From 2ac974702394c2c8e7804bd634f644b36ad9be3f Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 29 Apr 2016 17:53:16 -0700 Subject: [PATCH] gfx: Map `sans-serif` to Helvetica on Mac, DejaVu Sans on Linux, and Roboto on Android. This matches what I believe the OS native defaults to be. Partially addresses #9487. --- components/gfx/font_cache_thread.rs | 3 ++- components/gfx/platform/freetype/font_list.rs | 10 ++++++++++ components/gfx/platform/macos/font_list.rs | 4 ++++ .../html/word-break-normal-bo-000.htm.ini | 3 +-- .../tests/css/input_selection_incremental_ref.html | 9 +++++---- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs index 19efd3073c6..72027689e2f 100644 --- a/components/gfx/font_cache_thread.rs +++ b/components/gfx/font_cache_thread.rs @@ -8,6 +8,7 @@ use ipc_channel::router::ROUTER; use mime::{TopLevel, SubLevel}; use net_traits::{AsyncResponseTarget, LoadContext, PendingAsyncLoad, ResourceThread, ResponseAction}; use platform::font_context::FontContextHandle; +use platform::font_list::SANS_SERIF_FONT_FAMILY; use platform::font_list::for_each_available_family; use platform::font_list::for_each_variation; use platform::font_list::last_resort_font_families; @@ -120,7 +121,7 @@ fn populate_generic_fonts() -> HashMap { let mut generic_fonts = HashMap::with_capacity(5); append_map(&mut generic_fonts, FontFamily::Serif, "Times New Roman"); - append_map(&mut generic_fonts, FontFamily::SansSerif, "Arial"); + append_map(&mut generic_fonts, FontFamily::SansSerif, SANS_SERIF_FONT_FAMILY); append_map(&mut generic_fonts, FontFamily::Cursive, "Apple Chancery"); append_map(&mut generic_fonts, FontFamily::Fantasy, "Papyrus"); append_map(&mut generic_fonts, FontFamily::Monospace, "Menlo"); diff --git a/components/gfx/platform/freetype/font_list.rs b/components/gfx/platform/freetype/font_list.rs index 3ec62008882..ef89adeffd1 100644 --- a/components/gfx/platform/freetype/font_list.rs +++ b/components/gfx/platform/freetype/font_list.rs @@ -157,3 +157,13 @@ pub fn last_resort_font_families() -> Vec { "Arial".to_owned() ) } + +#[cfg(target_os = "android")] +pub static SANS_SERIF_FONT_FAMILY: &'static str = "Roboto"; + +#[cfg(target_os = "linux")] +pub static SANS_SERIF_FONT_FAMILY: &'static str = "DejaVu Sans"; + +#[cfg(target_os = "windows")] +pub static SANS_SERIF_FONT_FAMILY: &'static str = "Arial"; + diff --git a/components/gfx/platform/macos/font_list.rs b/components/gfx/platform/macos/font_list.rs index f0b629944ed..c0800f94c23 100644 --- a/components/gfx/platform/macos/font_list.rs +++ b/components/gfx/platform/macos/font_list.rs @@ -41,3 +41,7 @@ pub fn system_default_family(_generic_name: &str) -> Option { pub fn last_resort_font_families() -> Vec { vec!("Arial Unicode MS".to_owned(), "Arial".to_owned()) } + +#[cfg(target_os = "macos")] +pub static SANS_SERIF_FONT_FAMILY: &'static str = "Helvetica"; + diff --git a/tests/wpt/metadata-css/css-text-3_dev/html/word-break-normal-bo-000.htm.ini b/tests/wpt/metadata-css/css-text-3_dev/html/word-break-normal-bo-000.htm.ini index 525c2c7505a..2b2af21d60d 100644 --- a/tests/wpt/metadata-css/css-text-3_dev/html/word-break-normal-bo-000.htm.ini +++ b/tests/wpt/metadata-css/css-text-3_dev/html/word-break-normal-bo-000.htm.ini @@ -1,4 +1,3 @@ [word-break-normal-bo-000.htm] type: reftest - expected: - if os == "linux": FAIL + expected: FAIL diff --git a/tests/wpt/mozilla/tests/css/input_selection_incremental_ref.html b/tests/wpt/mozilla/tests/css/input_selection_incremental_ref.html index 7b9986ce98e..9b9f20916c5 100644 --- a/tests/wpt/mozilla/tests/css/input_selection_incremental_ref.html +++ b/tests/wpt/mozilla/tests/css/input_selection_incremental_ref.html @@ -4,16 +4,17 @@ input selection incremental reference - Hello +
Hello