mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Address review comments.
This commit is contained in:
parent
12978eeb50
commit
0c3cb39da3
4 changed files with 46 additions and 52 deletions
|
@ -109,8 +109,6 @@ pub struct Font {
|
|||
|
||||
impl Font {
|
||||
pub fn shape_text(&mut self, text: String, is_whitespace: bool) -> Arc<GlyphStore> {
|
||||
|
||||
//FIXME (ksh8281)
|
||||
self.make_shaper();
|
||||
let shaper = &self.shaper;
|
||||
self.shape_cache.find_or_create(&text, |txt| {
|
||||
|
|
|
@ -37,8 +37,8 @@ impl PartialEq for FontTemplateDescriptor {
|
|||
}
|
||||
|
||||
/// This describes all the information needed to create
|
||||
/// font instance handles. It contains a unique that is
|
||||
/// platform specific.
|
||||
/// font instance handles. It contains a unique
|
||||
/// FontTemplateData structure that is platform specific.
|
||||
pub struct FontTemplate {
|
||||
identifier: String,
|
||||
descriptor: Option<FontTemplateDescriptor>,
|
||||
|
|
|
@ -39,9 +39,7 @@ fn fixed_to_float_ft(f: i32) -> f64 {
|
|||
fixed_to_float(6, f)
|
||||
}
|
||||
|
||||
pub struct FontTable {
|
||||
_bogus: ()
|
||||
}
|
||||
pub struct FontTable;
|
||||
|
||||
impl FontTableMethods for FontTable {
|
||||
fn with_buffer(&self, _blk: |*u8, uint|) {
|
||||
|
@ -95,28 +93,28 @@ impl FontHandleMethods for FontHandle {
|
|||
Err(()) => Err(())
|
||||
};
|
||||
|
||||
fn create_face_from_buffer(lib: FT_Library, cbuf: *u8, cbuflen: uint, pt_size: Option<f64>)
|
||||
-> Result<FT_Face, ()> {
|
||||
unsafe {
|
||||
let mut face: FT_Face = ptr::null();
|
||||
let face_index = 0 as FT_Long;
|
||||
let result = FT_New_Memory_Face(lib, cbuf, cbuflen as FT_Long,
|
||||
face_index, &mut face);
|
||||
fn create_face_from_buffer(lib: FT_Library, cbuf: *u8, cbuflen: uint, pt_size: Option<f64>)
|
||||
-> Result<FT_Face, ()> {
|
||||
unsafe {
|
||||
let mut face: FT_Face = ptr::null();
|
||||
let face_index = 0 as FT_Long;
|
||||
let result = FT_New_Memory_Face(lib, cbuf, cbuflen as FT_Long,
|
||||
face_index, &mut face);
|
||||
|
||||
if !result.succeeded() || face.is_null() {
|
||||
return Err(());
|
||||
}
|
||||
let is_ok = match pt_size {
|
||||
Some(s) => FontHandle::set_char_size(face, s).is_ok(),
|
||||
None => true,
|
||||
};
|
||||
if is_ok {
|
||||
Ok(face)
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
if !result.succeeded() || face.is_null() {
|
||||
return Err(());
|
||||
}
|
||||
match pt_size {
|
||||
Some(s) => {
|
||||
match FontHandle::set_char_size(face, s) {
|
||||
Ok(_) => Ok(face),
|
||||
Err(_) => Err(()),
|
||||
}
|
||||
}
|
||||
None => Ok(face),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fn get_template(&self) -> Arc<FontTemplateData> {
|
||||
self.font_data.clone()
|
||||
|
|
|
@ -39,9 +39,7 @@ fn fixed_to_float_ft(f: i32) -> f64 {
|
|||
fixed_to_float(6, f)
|
||||
}
|
||||
|
||||
pub struct FontTable {
|
||||
_bogus: ()
|
||||
}
|
||||
pub struct FontTable;
|
||||
|
||||
impl FontTableMethods for FontTable {
|
||||
fn with_buffer(&self, _blk: |*u8, uint|) {
|
||||
|
@ -95,28 +93,28 @@ impl FontHandleMethods for FontHandle {
|
|||
Err(()) => Err(())
|
||||
};
|
||||
|
||||
fn create_face_from_buffer(lib: FT_Library, cbuf: *u8, cbuflen: uint, pt_size: Option<f64>)
|
||||
-> Result<FT_Face, ()> {
|
||||
unsafe {
|
||||
let mut face: FT_Face = ptr::null();
|
||||
let face_index = 0 as FT_Long;
|
||||
let result = FT_New_Memory_Face(lib, cbuf, cbuflen as FT_Long,
|
||||
face_index, &mut face);
|
||||
fn create_face_from_buffer(lib: FT_Library, cbuf: *u8, cbuflen: uint, pt_size: Option<f64>)
|
||||
-> Result<FT_Face, ()> {
|
||||
unsafe {
|
||||
let mut face: FT_Face = ptr::null();
|
||||
let face_index = 0 as FT_Long;
|
||||
let result = FT_New_Memory_Face(lib, cbuf, cbuflen as FT_Long,
|
||||
face_index, &mut face);
|
||||
|
||||
if !result.succeeded() || face.is_null() {
|
||||
return Err(());
|
||||
}
|
||||
let is_ok = match pt_size {
|
||||
Some(s) => FontHandle::set_char_size(face, s).is_ok(),
|
||||
None => true,
|
||||
};
|
||||
if is_ok {
|
||||
Ok(face)
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
if !result.succeeded() || face.is_null() {
|
||||
return Err(());
|
||||
}
|
||||
match pt_size {
|
||||
Some(s) => {
|
||||
match FontHandle::set_char_size(face, s) {
|
||||
Ok(_) => Ok(face),
|
||||
Err(_) => Err(()),
|
||||
}
|
||||
}
|
||||
None => Ok(face),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fn get_template(&self) -> Arc<FontTemplateData> {
|
||||
self.font_data.clone()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue