Skip to content

Commit

Permalink
Support oblique(font-style) for linux and android
Browse files Browse the repository at this point in the history
Add oblique style to pattern to find proper font.
  • Loading branch information
deokjinkim committed Jan 3, 2014
1 parent 528d362 commit ddcbb3f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/components/gfx/platform/android/font_list.rs
Expand Up @@ -7,7 +7,7 @@ extern mod fontconfig;

use fontconfig::fontconfig::{
FcChar8, FcResultMatch, FcSetSystem, FcPattern,
FcResultNoMatch, FcMatchPattern, FC_SLANT_ITALIC, FC_WEIGHT_BOLD
FcResultNoMatch, FcMatchPattern, FC_SLANT_ITALIC, FC_WEIGHT_BOLD, FC_SLANT_OBLIQUE
};
use fontconfig::fontconfig::{
FcConfigGetCurrent, FcConfigGetFonts, FcPatternGetString,
Expand Down Expand Up @@ -169,10 +169,21 @@ pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, (
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC)
};
if res != 1 {
debug!("adding slant to pattern failed");
debug!("adding slant(italic) to pattern failed");
return Err(());
}
}

if style.oblique {
let res = do "slant".to_c_str().with_ref |FC_SLANT| {
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_OBLIQUE)
};
if res != 1 {
debug!("adding slant(oblique) to pattern failed");
return Err(());
}
}

if style.weight.is_bold() {
let res = do "weight".to_c_str().with_ref |FC_WEIGHT| {
FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD)
Expand Down
15 changes: 13 additions & 2 deletions src/components/gfx/platform/linux/font_list.rs
Expand Up @@ -7,7 +7,7 @@ extern mod fontconfig;

use fontconfig::fontconfig::{
FcChar8, FcResultMatch, FcSetSystem, FcPattern,
FcResultNoMatch, FcMatchPattern, FC_SLANT_ITALIC, FC_WEIGHT_BOLD
FcResultNoMatch, FcMatchPattern, FC_SLANT_ITALIC, FC_WEIGHT_BOLD, FC_SLANT_OBLIQUE
};
use fontconfig::fontconfig::{
FcConfigGetCurrent, FcConfigGetFonts, FcPatternGetString,
Expand Down Expand Up @@ -168,10 +168,21 @@ pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, (
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC)
};
if res != 1 {
debug!("adding slant to pattern failed");
debug!("adding slant(italic) to pattern failed");
return Err(());
}
}

if style.oblique {
let res = do "slant".to_c_str().with_ref |FC_SLANT| {
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_OBLIQUE)
};
if res != 1 {
debug!("adding slant(oblique) to pattern failed");
return Err(());
}
}

if style.weight.is_bold() {
let res = do "weight".to_c_str().with_ref |FC_WEIGHT| {
FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD)
Expand Down

5 comments on commit ddcbb3f

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at deokjinkim@ddcbb3f

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging deokjinkim/servo/font_style = ddcbb3f into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deokjinkim/servo/font_style = ddcbb3f merged ok, testing candidate = da14203

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = da14203

Please sign in to comment.