Author: mlytwyn Date: Fri Nov 18 20:59:34 2016 New Revision: 40226 URL: http://svn.gna.org/viewcvs/gnustep?rev=40226&view=rev Log: Ignore bad characters that may not be parsable i.e. emoticons, etc
Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSAttributedString.m Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSAttributedString.m URL: http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSAttributedString.m?rev=40226&r1=40225&r2=40226&view=diff ============================================================================== --- libs/gui/branches/gnustep_testplant_branch/Source/NSAttributedString.m (original) +++ libs/gui/branches/gnustep_testplant_branch/Source/NSAttributedString.m Fri Nov 18 20:59:34 2016 @@ -1524,11 +1524,17 @@ - (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 _______________________________________________ Gnustep-cvs mailing list Gnustep-cvs@gna.org https://mail.gna.org/listinfo/gnustep-cvs