diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-05-20 02:36:43 -0500 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-05-20 02:36:43 -0500 |
commit | 165bfd6d5f901ef2e2619dbcc010166106cebd0b (patch) | |
tree | fc3c26b44e6644bda2f5a93a9ad18b3d7926278e | |
parent | 64810583093dadfacbda942562853af1ae82e34e (diff) | |
parent | 51503a28162d2305c3e7a6f914689a8702c9aace (diff) | |
download | servo-165bfd6d5f901ef2e2619dbcc010166106cebd0b.tar.gz servo-165bfd6d5f901ef2e2619dbcc010166106cebd0b.zip |
Auto merge of #6143 - michaelwu:truetype-only, r=pcwalton
I have a number of pcf fonts installed. One of them is Adobe Helvetica, and it turns out many websites try to use Helvetica. This crashes servo.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6143)
<!-- Reviewable:end -->
-rw-r--r-- | components/gfx/platform/freetype/font_list.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/components/gfx/platform/freetype/font_list.rs b/components/gfx/platform/freetype/font_list.rs index 9f939fa9391..ea9a0cbcb48 100644 --- a/components/gfx/platform/freetype/font_list.rs +++ b/components/gfx/platform/freetype/font_list.rs @@ -31,6 +31,7 @@ use std::ptr; static FC_FAMILY: &'static [u8] = b"family\0"; static FC_FILE: &'static [u8] = b"file\0"; static FC_INDEX: &'static [u8] = b"index\0"; +static FC_FONTFORMAT: &'static [u8] = b"fontformat\0"; pub fn get_available_families<F>(mut callback: F) where F: FnMut(String) { unsafe { @@ -39,7 +40,20 @@ pub fn get_available_families<F>(mut callback: F) where F: FnMut(String) { for i in 0..((*fontSet).nfont as isize) { let font = (*fontSet).fonts.offset(i); let mut family: *mut FcChar8 = ptr::null_mut(); + let mut format: *mut FcChar8 = ptr::null_mut(); let mut v: c_int = 0; + if FcPatternGetString(*font, FC_FONTFORMAT.as_ptr() as *mut c_char, v, &mut format) != FcResultMatch { + continue; + } + + // Skip bitmap fonts. They aren't supported by FreeType. + let fontformat = c_str_to_string(format as *const c_char); + if fontformat != "TrueType" && + fontformat != "CFF" && + fontformat != "Type 1" { + continue; + } + while FcPatternGetString(*font, FC_FAMILY.as_ptr() as *mut c_char, v, &mut family) == FcResultMatch { let family_name = c_str_to_string(family as *const c_char); callback(family_name); |