RichTextReader is trusting fontWithName:size: to create legitimate fonts which it's not

This commit is contained in:
Robert Grant 2013-07-19 13:11:13 -04:00
parent ae02f989e9
commit 4e1562593c

View File

@ -376,7 +376,14 @@ static inline void flushPreviousString(NSRichTextReader *self) {
_currentCharset = [[info objectForKey:@"charset"] integerValue];
// Turns out fontWithName:size: is still returning fonts for font names it doesn't have
// For example "Helvetica". This check ensures that we only ask for fonts we have...
// Of course this is a general problem... so the full fix is elsewhere...
NSArray *availableFonts = [[NSFontManager sharedFontManager] availableFonts];
if ([availableFonts containsObject: fontname]) {
font=[NSFont fontWithName: fontname size: 12];
}
if (font == nil) {
// Try to get some default font for the given family
if([family isEqualToString:@"roman"])