Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix string::raw::from_buf deprecation warning
  • Loading branch information
mttr committed Jan 8, 2015
1 parent df6a795 commit 9881ecf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions components/gfx/platform/freetype/font.rs
Expand Up @@ -28,7 +28,7 @@ use freetype::tt_os2::TT_OS2;
use std::mem;
use std::num::Float;
use std::ptr;
use std::string;
use std::string::String;

use std::sync::Arc;

Expand Down Expand Up @@ -121,10 +121,10 @@ impl FontHandleMethods for FontHandle {
self.font_data.clone()
}
fn family_name(&self) -> String {
unsafe { string::raw::from_buf(&*(*self.face).family_name as *const i8 as *const u8) }
unsafe { String::from_raw_buf(&*(*self.face).family_name as *const i8 as *const u8) }
}
fn face_name(&self) -> String {
unsafe { string::raw::from_buf(&*FT_Get_Postscript_Name(self.face) as *const i8 as *const u8) }
unsafe { String::from_raw_buf(&*FT_Get_Postscript_Name(self.face) as *const i8 as *const u8) }
}
fn is_italic(&self) -> bool {
unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC != 0 }
Expand Down
8 changes: 4 additions & 4 deletions components/gfx/platform/freetype/font_list.rs
Expand Up @@ -23,7 +23,7 @@ use fontconfig::fontconfig::{
use libc;
use libc::c_int;
use std::ptr;
use std::string;
use std::string::String;

static FC_FAMILY: &'static [u8] = b"family\0";
static FC_FILE: &'static [u8] = b"file\0";
Expand All @@ -38,7 +38,7 @@ pub fn get_available_families(callback: |String|) {
let mut family: *mut FcChar8 = ptr::null_mut();
let mut v: c_int = 0;
while FcPatternGetString(*font, FC_FAMILY.as_ptr() as *mut i8, v, &mut family) == FcResultMatch {
let family_name = string::raw::from_buf(family as *const i8 as *const u8);
let family_name = String::from_raw_buf(family as *const i8 as *const u8);
callback(family_name);
v += 1;
}
Expand Down Expand Up @@ -73,7 +73,7 @@ pub fn get_variations_for_family(family_name: &str, callback: |String|) {
let font = (*matches).fonts.offset(i);
let mut file: *mut FcChar8 = ptr::null_mut();
let file = if FcPatternGetString(*font, FC_FILE.as_ptr() as *mut i8, 0, &mut file) == FcResultMatch {
string::raw::from_buf(file as *const i8 as *const u8)
String::from_raw_buf(file as *const i8 as *const u8)
} else {
panic!();
};
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn get_system_default_family(generic_name: &str) -> Option<String> {
let family_name = if result == FcResultMatch {
let mut match_string: *mut FcChar8 = ptr::null_mut();
FcPatternGetString(family_match, FC_FAMILY.as_ptr() as *mut i8, 0, &mut match_string);
let result = string::raw::from_buf(match_string as *const i8 as *const u8);
let result = String::from_raw_buf(match_string as *const i8 as *const u8);
FcPatternDestroy(family_match);
Some(result)
} else {
Expand Down

0 comments on commit 9881ecf

Please sign in to comment.