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

Fix linux font styles. #394

Merged
merged 3 commits into from Apr 23, 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

@@ -22,12 +22,12 @@ impl Mul<Au,Au> for Au {
fn mul(&self, other: &Au) -> Au { Au(**self * **other) }
}

impl Div<Au,Au> for Au {
fn div(&self, other: &Au) -> Au { Au(**self / **other) }
impl Quot<Au,Au> for Au {
fn quot(&self, other: &Au) -> Au { Au(**self / **other) }
}

impl Modulo<Au,Au> for Au {
fn modulo(&self, other: &Au) -> Au { Au(**self % **other) }
impl Rem<Au,Au> for Au {
fn rem(&self, other: &Au) -> Au { Au(**self % **other) }
}

impl Neg<Au> for Au {
@@ -46,7 +46,7 @@ impl FontContextHandleMethods for FontContextHandle {
fn create_font_from_identifier(&self, name: ~str, style: UsedFontStyle)
-> Result<FontHandle, ()> {
debug!("Creating font handle for %s", name);
do path_from_identifier(name).chain |file_name| {
do path_from_identifier(name, &style).chain |file_name| {
debug!("Opening font face %s", file_name);
FontHandle::new_from_file(self, file_name, &style)
}
@@ -5,18 +5,20 @@
extern mod freetype;
extern mod fontconfig;

use self::fontconfig::fontconfig::{FcChar8, FcResultMatch, FcSetSystem,
FcResultNoMatch, FcMatchPattern};
use self::fontconfig::fontconfig::bindgen::{
use fontconfig::fontconfig::{
FcChar8, FcResultMatch, FcSetSystem,
FcResultNoMatch, FcMatchPattern, FC_SLANT_ITALIC, FC_WEIGHT_BOLD
};
use fontconfig::fontconfig::bindgen::{
FcConfigGetCurrent, FcConfigGetFonts, FcPatternGetString,
FcPatternDestroy, FcFontSetDestroy, FcConfigSubstitute,
FcDefaultSubstitute, FcPatternCreate, FcPatternAddString,
FcDefaultSubstitute, FcPatternCreate, FcPatternAddString, FcPatternAddInteger,
FcFontMatch, FcFontSetList, FcObjectSetCreate, FcObjectSetDestroy,
FcObjectSetAdd, FcPatternGetInteger
};


use font::FontHandleMethods;
use font::{FontHandleMethods, UsedFontStyle};
use font_context::FontContextHandleMethods;
use font_list::{FontEntry, FontFamily, FontFamilyMap};
use platform::font::FontHandle;
@@ -25,22 +27,6 @@ use platform::font_context::FontContextHandle;
use core::hashmap::HashMap;
use core::libc::c_int;
use core::ptr::Ptr;
use fontconfig::fontconfig::bindgen::{FcConfigGetCurrent};
use fontconfig::fontconfig::bindgen::{FcConfigGetFonts};
use fontconfig::fontconfig::bindgen::{FcDefaultSubstitute};
use fontconfig::fontconfig::bindgen::{FcPatternCreate};
use fontconfig::fontconfig::bindgen::{FcFontSetDestroy};
use fontconfig::fontconfig::bindgen::{FcConfigSubstitute};
use fontconfig::fontconfig::bindgen::{FcFontSetList};
use fontconfig::fontconfig::bindgen::{FcObjectSetCreate};
use fontconfig::fontconfig::bindgen::{FcObjectSetDestroy};
use fontconfig::fontconfig::bindgen::{FcObjectSetAdd};
use fontconfig::fontconfig::bindgen::{FcPatternAddString, FcFontMatch};
use fontconfig::fontconfig::bindgen::{FcPatternGetInteger};
use fontconfig::fontconfig::bindgen::{FcPatternGetString};
use fontconfig::fontconfig::bindgen::{FcPatternDestroy};
use fontconfig::fontconfig::{FcChar8, FcResultMatch, FcSetSystem};
use fontconfig::fontconfig::{FcMatchPattern, FcResultNoMatch};

pub struct FontListHandle {
fctx: FontContextHandle,
@@ -138,7 +124,7 @@ pub impl FontListHandle {
}
}

pub fn path_from_identifier(name: ~str) -> Result<~str, ()> {
pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, ()> {
unsafe {
let config = FcConfigGetCurrent();
let pattern = FcPatternCreate();
@@ -152,6 +138,25 @@ pub fn path_from_identifier(name: ~str) -> Result<~str, ()> {
return Err(());
}

if style.italic {
let res = do str::as_c_str("slant") |FC_SLANT| {
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC)
};
if res != 1 {
debug!("adding slant to pattern failed");
return Err(());
}
}
if style.weight.is_bold() {
let res = do str::as_c_str("weight") |FC_WEIGHT| {
FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD)
};
if res != 1 {
debug!("adding weight to pattern failed");
return Err(());
}
}

if FcConfigSubstitute(config, pattern, FcMatchPattern) != 1 {
debug!("substitution failed");
return Err(());

This file was deleted.

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.