Ignore bad characters that may not be parsable i.e. emoticons, etc

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@40226 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Marcian Lytwyn 2016-11-18 19:59:34 +00:00
parent 1ada7d514d
commit b6991cdc0c

View file

@ -1524,11 +1524,17 @@ static NSMutableDictionary *cachedCSets = nil;
- (NSFontDescriptor*)_substituteFontDescriptorFor: (unichar)uchar
{
NSString *chars = [NSString stringWithCharacters: &uchar length: 1];
NSCharacterSet *requiredCharacterSet = [NSCharacterSet characterSetWithCharactersInString: chars];
NSDictionary *fontAttributes = [NSDictionary dictionaryWithObjectsAndKeys: requiredCharacterSet, NSFontCharacterSetAttribute, nil];
NSSet *mandatoryKeys = [NSSet setWithObjects: NSFontCharacterSetAttribute, nil];
NSFontDescriptor *fd = [NSFontDescriptor fontDescriptorWithFontAttributes: fontAttributes];
return [fd matchingFontDescriptorWithMandatoryKeys: mandatoryKeys];
// Emoticons can be pasted that won't be parsed properly...
if (chars != nil)
{
NSCharacterSet *requiredCharacterSet = [NSCharacterSet characterSetWithCharactersInString: chars];
NSDictionary *fontAttributes = [NSDictionary dictionaryWithObjectsAndKeys: requiredCharacterSet, NSFontCharacterSetAttribute, nil];
NSSet *mandatoryKeys = [NSSet setWithObjects: NSFontCharacterSetAttribute, nil];
NSFontDescriptor *fd = [NSFontDescriptor fontDescriptorWithFontAttributes: fontAttributes];
return [fd matchingFontDescriptorWithMandatoryKeys: mandatoryKeys];
}
return nil;
}
- (NSFont*)_substituteFontFor: (unichar)uchar font: (NSFont*)baseFont