mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 07:00:37 +00:00
* Source/NSAttributedString.m (-_substituteFontFor:font:): Use
font descriptors for faster replacement font detection. * Source/GSFontInfo.m (GSFontEnumerator-matchingFontDescriptorsFor:): Special handling for NSFontCharacterSetAttribute. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39079 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0ea4141ac0
commit
bbac2bf53c
3 changed files with 46 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
|||
2015-10-17 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSAttributedString.m (-_substituteFontFor:font:): Use
|
||||
font descriptors for faster replacement font detection.
|
||||
* Source/GSFontInfo.m
|
||||
(GSFontEnumerator-matchingFontDescriptorsFor:): Special handling
|
||||
for NSFontCharacterSetAttribute.
|
||||
|
||||
2015-10-16 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSCell.m (-trackMouse:...untilMouseUp:): Check enabled
|
||||
|
|
|
@ -229,6 +229,14 @@ static GSFontEnumerator *sharedEnumerator = nil;
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if ([key isEqual: NSFontCharacterSetAttribute])
|
||||
{
|
||||
if (![valueB isSupersetOfSet: valueA])
|
||||
{
|
||||
match = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (![valueA isEqual: valueB])
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#import <Foundation/NSFileManager.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSRange.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
|
@ -50,6 +51,7 @@
|
|||
#import "AppKit/NSColor.h"
|
||||
#import "AppKit/NSFileWrapper.h"
|
||||
#import "AppKit/NSFont.h"
|
||||
#import "AppKit/NSFontDescriptor.h"
|
||||
#import "AppKit/NSFontManager.h"
|
||||
// For the colour name spaces
|
||||
#import "AppKit/NSGraphics.h"
|
||||
|
@ -1519,9 +1521,20 @@ static NSMutableDictionary *cachedCSets = nil;
|
|||
return 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];
|
||||
}
|
||||
|
||||
- (NSFont*)_substituteFontFor: (unichar)uchar font: (NSFont*)baseFont
|
||||
{
|
||||
NSFont *subFont;
|
||||
NSFontDescriptor *descriptor;
|
||||
|
||||
// Caching one font may lead to the selected substitution font not being
|
||||
// from the prefered list, although there is one there with this character.
|
||||
|
@ -1538,13 +1551,29 @@ static NSMutableDictionary *cachedCSets = nil;
|
|||
return subFont;
|
||||
}
|
||||
|
||||
// Fast way with font descriptors
|
||||
descriptor = [self _substituteFontDescriptorFor: uchar];
|
||||
if (descriptor != nil)
|
||||
{
|
||||
NSCharacterSet *newSet = [descriptor objectForKey: NSFontCharacterSetAttribute];
|
||||
if ([newSet characterIsMember: uchar])
|
||||
{
|
||||
NSString *fName = [descriptor objectForKey: NSFontFamilyAttribute];
|
||||
|
||||
ASSIGN(lastFont, fName);
|
||||
ASSIGN(lastSet, newSet);
|
||||
return [self _substituteFontWithName: fName font: baseFont];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
subFont = [self _substituteFontFor: uchar font: baseFont fromList:
|
||||
[[NSFontManager sharedFontManager] availableFonts]];
|
||||
if (subFont != nil)
|
||||
{
|
||||
return subFont;
|
||||
}
|
||||
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue