mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Implement basic last-resort font selection.
This commit is contained in:
parent
8ee1b5f57a
commit
24ef69dccb
4 changed files with 26 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -125,6 +125,10 @@ pub impl FontListHandle {
|
|||
FcObjectSetDestroy(object_set);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_last_resort_font_families() -> ~[~str] {
|
||||
~[~"Arial"]
|
||||
}
|
||||
}
|
||||
|
||||
struct AutoPattern {
|
||||
|
|
|
@ -55,4 +55,8 @@ pub impl FontListHandle {
|
|||
family.entries.push(entry)
|
||||
}
|
||||
}
|
||||
|
||||
fn get_last_resort_font_families() -> ~[~str] {
|
||||
~[~"Arial Unicode MS",~"Arial"]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue