auto merge of #1454 : deokjinkim/servo/font_style, r=jdm

Add oblique style to pattern to find proper font.
This commit is contained in:
bors-servo 2014-01-03 06:52:30 -08:00
commit da14203f91
2 changed files with 26 additions and 4 deletions

View file

@ -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,
@ -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)

View file

@ -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,
@ -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)