mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
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 -->
This commit is contained in:
commit
165bfd6d5f
1 changed files with 14 additions and 0 deletions
|
@ -31,6 +31,7 @@ use std::ptr;
|
||||||
static FC_FAMILY: &'static [u8] = b"family\0";
|
static FC_FAMILY: &'static [u8] = b"family\0";
|
||||||
static FC_FILE: &'static [u8] = b"file\0";
|
static FC_FILE: &'static [u8] = b"file\0";
|
||||||
static FC_INDEX: &'static [u8] = b"index\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) {
|
pub fn get_available_families<F>(mut callback: F) where F: FnMut(String) {
|
||||||
unsafe {
|
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) {
|
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 format: *mut FcChar8 = ptr::null_mut();
|
||||||
let mut v: c_int = 0;
|
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 {
|
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);
|
let family_name = c_str_to_string(family as *const c_char);
|
||||||
callback(family_name);
|
callback(family_name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue