From ddcbb3f0388c1ab5f657ed33df7e42e0bc4a12cf Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Fri, 3 Jan 2014 20:46:04 +0900 Subject: [PATCH] Support oblique(font-style) for linux and android Add oblique style to pattern to find proper font. --- src/components/gfx/platform/android/font_list.rs | 15 +++++++++++++-- src/components/gfx/platform/linux/font_list.rs | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/components/gfx/platform/android/font_list.rs b/src/components/gfx/platform/android/font_list.rs index 6f6b26064ee..87a355e35b9 100644 --- a/src/components/gfx/platform/android/font_list.rs +++ b/src/components/gfx/platform/android/font_list.rs @@ -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) diff --git a/src/components/gfx/platform/linux/font_list.rs b/src/components/gfx/platform/linux/font_list.rs index deadb966245..2c9c734da6c 100644 --- a/src/components/gfx/platform/linux/font_list.rs +++ b/src/components/gfx/platform/linux/font_list.rs @@ -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)