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