Fix dynamic borrow check errors.

This reduces the scope of the borrow on `family` to the single FFI call that
needs it.
This commit is contained in:
Jack Moffitt 2013-05-16 09:23:18 -06:00
parent c8520e9249
commit 5fd0fcbc91

View file

@ -66,19 +66,25 @@ pub impl FontListHandle {
let font_set = FcConfigGetFonts(config, FcSetSystem);
let font_set_array_ptr = ptr::to_unsafe_ptr(&font_set);
unsafe {
do str::as_c_str("family") |FC_FAMILY| {
do str::as_c_str(family.family_name) |family_name| {
let pattern = FcPatternCreate();
let pattern = FcPatternCreate();
assert!(pattern.is_not_null());
let family_name = family_name as *FcChar8;
let ok = FcPatternAddString(pattern, FC_FAMILY, family_name);
do str::as_c_str("family") |FC_FAMILY| {
do str::as_c_str(family.family_name) |family_name| {
let ok = FcPatternAddString(pattern, FC_FAMILY, family_name as *FcChar8);
assert!(ok != 0);
}
}
let object_set = FcObjectSetCreate();
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) );
do str::as_c_str("file") |FC_FILE| {
FcObjectSetAdd(object_set, FC_FILE);
}
do str::as_c_str("index") |FC_INDEX| {
FcObjectSetAdd(object_set, FC_INDEX);
}
let matches = FcFontSetList(config, font_set_array_ptr, 1, pattern, object_set);
@ -121,8 +127,6 @@ pub impl FontListHandle {
}
}
}
}
}
pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, ()> {
unsafe {