Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #479 - Implement basic last-resort font selection. #511

Merged
merged 1 commit into from Jun 11, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Implement basic last-resort font selection.

  • Loading branch information
Caitlin Potter
Caitlin Potter committed Jun 10, 2013
commit 24ef69dccb88a943ab8ef5b976eb053a8d1697e9
@@ -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"]
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.