Update to 0.6, make buildable on Linux.

This commit is contained in:
Josh Matthews 2013-04-04 13:18:28 -04:00
parent 762c7e0b5d
commit c193011381
7 changed files with 21 additions and 29 deletions

@ -1 +1 @@
Subproject commit 5fc77111bbb003fbcd9ba15e4813b31eccf6943c
Subproject commit 7d2543dceeb05741637e6070d700ae3a85495010

@ -1 +1 @@
Subproject commit 2cdbb170c3591c08a872e30584fcaf490680a100
Subproject commit a508df34eae1d5c2917200d94980989e309081cc

@ -1 +1 @@
Subproject commit 6852c4a04e44d29dc410666ef551654a7e181d6c
Subproject commit e7e82c62aae80d5502b89c8cbbb6f7d4b341b9e2

@ -1 +1 @@
Subproject commit 754ac8e774d9ac7b8577b6a0b775a54e1f00a262
Subproject commit c38348c219caf2be3cc50baa4ffa7a06f041e29b

View file

@ -1,25 +1,22 @@
extern mod freetype;
extern mod fontconfig;
use gfx_font::{FontHandle, FontHandleMethods};
use gfx_font::FontHandleMethods;
use gfx_font_list::{FontEntry, FontFamily, FontFamilyMap};
use gfx_font_context::FontContextHandleMethods;
use freetype_impl::font_context::FreeTypeFontContextHandle;
use freetype_impl::font::FreeTypeFontHandle;
use self::fontconfig::fontconfig::{FcConfig, FcFontSet, FcChar8,
FcResultMatch, FcSetSystem, FcPattern,
use self::fontconfig::fontconfig::{FcChar8, FcResultMatch, FcSetSystem,
FcResultNoMatch, FcMatchPattern};
use self::fontconfig::fontconfig::bindgen::{
FcConfigGetCurrent, FcConfigGetFonts, FcPatternGetString,
FcInitReinitialize, FcPatternDestroy, FcPatternReference,
FcFontSetDestroy, FcCharSetDestroy, FcConfigSubstitute,
FcPatternDestroy, FcFontSetDestroy, FcConfigSubstitute,
FcDefaultSubstitute, FcPatternCreate, FcPatternAddString,
FcFontMatch, FcFontSetCreate, FcFontSetList, FcPatternPrint,
FcObjectSetCreate, FcObjectSetDestroy, FcObjectSetAdd,
FcPatternGetInteger
FcFontMatch, FcFontSetList, FcObjectSetCreate, FcObjectSetDestroy,
FcObjectSetAdd, FcPatternGetInteger
};
use core::hashmap::linear;
use core::hashmap::HashMap;
use core::libc::c_int;
use core::ptr::Ptr;
use native;
@ -34,7 +31,7 @@ pub impl FontconfigFontListHandle {
}
fn get_available_families(&self) -> FontFamilyMap {
let mut family_map : FontFamilyMap = linear::LinearMap::new();
let mut family_map : FontFamilyMap = HashMap::new();
unsafe {
let config = FcConfigGetCurrent();
let fontSet = FcConfigGetFonts(config, FcSetSystem);
@ -65,13 +62,13 @@ pub impl FontconfigFontListHandle {
do str::as_c_str("family") |FC_FAMILY| {
do str::as_c_str(family.family_name) |family_name| {
let pattern = FcPatternCreate();
fail_unless!(pattern.is_not_null());
assert!(pattern.is_not_null());
let family_name = family_name as *FcChar8;
let ok = FcPatternAddString(pattern, FC_FAMILY, family_name);
fail_unless!(ok != 0);
assert!(ok != 0);
let object_set = FcObjectSetCreate();
fail_unless!(object_set.is_not_null());
assert!(object_set.is_not_null());
str::as_c_str("file", |FC_FILE| FcObjectSetAdd(object_set, FC_FILE) );
str::as_c_str("index", |FC_INDEX| FcObjectSetAdd(object_set, FC_INDEX) );

View file

@ -4,7 +4,6 @@ use native;
use freetype_impl::font_context::FreeTypeFontContextHandle;
use gfx_font::{
CSSFontWeight,
FontHandle,
FontHandleMethods,
FontMetrics,
FontTable,
@ -30,7 +29,6 @@ use text::util::{float_to_fixed, fixed_to_float};
use self::freetype::freetype::{
FTErrorMethods,
FT_Error,
FT_F26Dot6,
FT_Face,
FT_FaceRec,
@ -38,7 +36,6 @@ use self::freetype::freetype::{
FT_Library,
FT_Long,
FT_ULong,
FT_Size,
FT_SizeRec,
FT_UInt,
FT_Size_Metrics,
@ -47,8 +44,6 @@ use self::freetype::freetype::{
ft_sfnt_os2
};
use self::freetype::freetype::bindgen::{
FT_Init_FreeType,
FT_Done_FreeType,
FT_New_Memory_Face,
FT_Done_Face,
FT_Get_Char_Index,
@ -90,9 +85,10 @@ pub struct FreeTypeFontHandle {
face: FT_Face,
}
#[unsafe_destructor]
impl Drop for FreeTypeFontHandle {
fn finalize(&self) {
fail_unless!(self.face.is_not_null());
assert!(self.face.is_not_null());
if !FT_Done_Face(self.face).succeeded() {
fail!(~"FT_Done_Face failed");
}
@ -245,7 +241,7 @@ impl FontHandleMethods for FreeTypeFontHandle {
pub fn glyph_index(&self,
codepoint: char) -> Option<GlyphIndex> {
fail_unless!(self.face.is_not_null());
assert!(self.face.is_not_null());
let idx = FT_Get_Char_Index(self.face, codepoint as FT_ULong);
return if idx != 0 as FT_UInt {
Some(idx as GlyphIndex)
@ -257,13 +253,13 @@ impl FontHandleMethods for FreeTypeFontHandle {
pub fn glyph_h_advance(&self,
glyph: GlyphIndex) -> Option<FractionalPixel> {
fail_unless!(self.face.is_not_null());
assert!(self.face.is_not_null());
let res = FT_Load_Glyph(self.face, glyph as FT_UInt, 0);
if res.succeeded() {
unsafe {
let void_glyph = (*self.face).glyph;
let slot: FT_GlyphSlot = cast::transmute(void_glyph);
fail_unless!(slot.is_not_null());
assert!(slot.is_not_null());
debug!("metrics: %?", (*slot).metrics);
let advance = (*slot).metrics.horiAdvance;
debug!("h_advance for %? is %?", glyph, advance);
@ -324,7 +320,7 @@ pub impl FreeTypeFontHandle {
let x_scale = (metrics.x_ppem as float) / em_size as float;
// If this isn't true then we're scaling one of the axes wrong
fail_unless!(metrics.x_ppem == metrics.y_ppem);
assert!(metrics.x_ppem == metrics.y_ppem);
return geometry::from_frac_px(value * x_scale);
}

View file

@ -3,7 +3,6 @@ extern mod fontconfig;
use self::freetype::freetype::{
FTErrorMethods,
FT_Error,
FT_Library,
};
use self::freetype::freetype::bindgen::{
@ -25,7 +24,7 @@ struct FreeTypeLibraryHandle {
impl Drop for FreeTypeLibraryHandle {
fn finalize(&self) {
fail_unless!(self.ctx.is_not_null());
assert!(self.ctx.is_not_null());
FT_Done_FreeType(self.ctx);
}
}