mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
servo: Merge #6143 - Avoid selecting bitmap fonts from fontconfig (from 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. Source-Repo: https://github.com/servo/servo Source-Revision: 165bfd6d5f901ef2e2619dbcc010166106cebd0b
This commit is contained in:
parent
d49fb75099
commit
6b72c7862a
@ -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…
Reference in New Issue
Block a user