mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #5604 - Ms2ger:int, r=mbrubeck
This commit is contained in:
commit
acadb2b0c5
2 changed files with 5 additions and 6 deletions
|
@ -76,8 +76,7 @@ impl FontHandleMethods for FontHandle {
|
||||||
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
||||||
if ft_ctx.is_null() { return Err(()); }
|
if ft_ctx.is_null() { return Err(()); }
|
||||||
|
|
||||||
let bytes = &template.bytes;
|
let face_result = create_face_from_buffer(ft_ctx, &template.bytes, pt_size);
|
||||||
let face_result = create_face_from_buffer(ft_ctx, bytes.as_ptr(), bytes.len(), pt_size);
|
|
||||||
|
|
||||||
// TODO: this could be more simply written as result::chain
|
// TODO: this could be more simply written as result::chain
|
||||||
// and moving buf into the struct ctor, but cant' move out of
|
// and moving buf into the struct ctor, but cant' move out of
|
||||||
|
@ -94,12 +93,12 @@ impl FontHandleMethods for FontHandle {
|
||||||
Err(()) => Err(())
|
Err(()) => Err(())
|
||||||
};
|
};
|
||||||
|
|
||||||
fn create_face_from_buffer(lib: FT_Library, cbuf: *const u8, cbuflen: uint, pt_size: Option<Au>)
|
fn create_face_from_buffer(lib: FT_Library, buffer: &[u8], pt_size: Option<Au>)
|
||||||
-> Result<FT_Face, ()> {
|
-> Result<FT_Face, ()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut face: FT_Face = ptr::null_mut();
|
let mut face: FT_Face = ptr::null_mut();
|
||||||
let face_index = 0 as FT_Long;
|
let face_index = 0 as FT_Long;
|
||||||
let result = FT_New_Memory_Face(lib, cbuf, cbuflen as FT_Long,
|
let result = FT_New_Memory_Face(lib, buffer.as_ptr(), buffer.len() as FT_Long,
|
||||||
face_index, &mut face);
|
face_index, &mut face);
|
||||||
|
|
||||||
if !result.succeeded() || face.is_null() {
|
if !result.succeeded() || face.is_null() {
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub fn get_available_families<F>(mut callback: F) where F: FnMut(String) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let config = FcConfigGetCurrent();
|
let config = FcConfigGetCurrent();
|
||||||
let fontSet = FcConfigGetFonts(config, FcSetSystem);
|
let fontSet = FcConfigGetFonts(config, FcSetSystem);
|
||||||
for i in 0..((*fontSet).nfont as int) {
|
for i in 0..((*fontSet).nfont as isize) {
|
||||||
let font = (*fontSet).fonts.offset(i);
|
let font = (*fontSet).fonts.offset(i);
|
||||||
let mut family: *mut FcChar8 = ptr::null_mut();
|
let mut family: *mut FcChar8 = ptr::null_mut();
|
||||||
let mut v: c_int = 0;
|
let mut v: c_int = 0;
|
||||||
|
@ -74,7 +74,7 @@ pub fn get_variations_for_family<F>(family_name: &str, mut callback: F)
|
||||||
|
|
||||||
debug!("found {} variations", (*matches).nfont);
|
debug!("found {} variations", (*matches).nfont);
|
||||||
|
|
||||||
for i in 0..((*matches).nfont as int) {
|
for i in 0..((*matches).nfont as isize) {
|
||||||
let font = (*matches).fonts.offset(i);
|
let font = (*matches).fonts.offset(i);
|
||||||
let mut file: *mut FcChar8 = ptr::null_mut();
|
let mut file: *mut FcChar8 = ptr::null_mut();
|
||||||
let file = if FcPatternGetString(*font, FC_FILE.as_ptr() as *mut c_char, 0, &mut file) == FcResultMatch {
|
let file = if FcPatternGetString(*font, FC_FILE.as_ptr() as *mut c_char, 0, &mut file) == FcResultMatch {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue