diff --git a/src/components/gfx/font_context.rs b/src/components/gfx/font_context.rs index 5a4a57b2d7e..e954d3e07ed 100644 --- a/src/components/gfx/font_context.rs +++ b/src/components/gfx/font_context.rs @@ -112,14 +112,14 @@ pub impl<'self> FontContext { debug!("(create font group) --- starting ---"); + let list = self.get_font_list(); + // TODO(Issue #193): make iteration over 'font-family' more robust. for str::each_split_char(style.families, ',') |family| { let family_name = str::trim(family); let transformed_family_name = self.transform_family(family_name); debug!("(create font group) transformed family is `%s`", transformed_family_name); - let list = self.get_font_list(); - let result = list.find_font_in_family(transformed_family_name, style); let mut found = false; for result.each |font_entry| { @@ -134,6 +134,16 @@ pub impl<'self> FontContext { } } + let last_resort = FontList::get_last_resort_font_families(); + + for last_resort.each |family| { + let result = list.find_font_in_family(*family,style); + for result.each |font_entry| { + let instance = Font::new_from_existing_handle(self, &font_entry.handle, style, self.backend); + do result::iter(&instance) |font: &@mut Font| { fonts.push(*font); } + } + } + assert!(fonts.len() > 0); // TODO(Issue #179): Split FontStyle into specified and used styles let used_style = copy *style; diff --git a/src/components/gfx/font_list.rs b/src/components/gfx/font_list.rs index 876e6d14aa5..e9a5afdf77c 100644 --- a/src/components/gfx/font_list.rs +++ b/src/components/gfx/font_list.rs @@ -19,6 +19,7 @@ pub type FontFamilyMap = HashMap<~str, @mut FontFamily>; trait FontListHandleMethods { fn get_available_families(&self, fctx: &FontContextHandle) -> FontFamilyMap; fn load_variations_for_family(&self, family: @mut FontFamily); + fn get_last_resort_font_families() -> ~[~str]; } /// The platform-independent font list abstraction. @@ -86,6 +87,11 @@ pub impl FontList { // TODO(Issue #188): look up localized font family names if canonical name not found family.map(|f| **f) } + + pub fn get_last_resort_font_families() -> ~[~str] { + let last_resort = FontListHandle::get_last_resort_font_families(); + last_resort + } } // Holds a specific font family, and the various diff --git a/src/components/gfx/platform/linux/font_list.rs b/src/components/gfx/platform/linux/font_list.rs index a7b99c6679e..1d8f9ddd007 100644 --- a/src/components/gfx/platform/linux/font_list.rs +++ b/src/components/gfx/platform/linux/font_list.rs @@ -125,6 +125,10 @@ pub impl FontListHandle { FcObjectSetDestroy(object_set); } } + + fn get_last_resort_font_families() -> ~[~str] { + ~[~"Arial"] + } } struct AutoPattern { diff --git a/src/components/gfx/platform/macos/font_list.rs b/src/components/gfx/platform/macos/font_list.rs index f362b513092..39f24f68fb4 100644 --- a/src/components/gfx/platform/macos/font_list.rs +++ b/src/components/gfx/platform/macos/font_list.rs @@ -55,4 +55,8 @@ pub impl FontListHandle { family.entries.push(entry) } } + + fn get_last_resort_font_families() -> ~[~str] { + ~[~"Arial Unicode MS",~"Arial"] + } }