* Undo the previous change and try a different approach..

just cache the character set in CairoFaceInfo, but load them
as needed as we were doing before.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@32987 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ericwa 2011-05-05 20:05:13 +00:00
parent f61d9ee591
commit 09c3361700
4 changed files with 33 additions and 10 deletions

View file

@ -1,3 +1,9 @@
2011-05-05 Eric Wasylishen <ewasylishen@gmail.com>
* Undo the previous change and try a different approach..
just cache the character set in CairoFaceInfo, but load them
as needed as we were doing before.
2011-05-05 Eric Wasylishen <ewasylishen@gmail.com>
* Source/cairo/CairoFontEnumerator.m:

View file

@ -45,6 +45,8 @@
FcPattern *_pattern;
NSString *_familyName;
NSCharacterSet *_characterSet;
BOOL _hasNoCharacterSet;
}
- (id) initWithfamilyName: (NSString *)familyName

View file

@ -58,7 +58,7 @@
}
FcPatternDestroy(_pattern);
RELEASE(_familyName);
RELEASE(_characterSet);
[super dealloc];
}
@ -125,15 +125,30 @@
- (NSCharacterSet*)characterSet
{
FcCharSet *fcCharset;
NSCharacterSet *characterSet = nil;
if (FcResultMatch == FcPatternGetCharSet(_pattern, FC_CHARSET, 0, &fcCharset))
if (_characterSet == nil && !_hasNoCharacterSet)
{
characterSet = [[[FontconfigCharacterSet alloc] initWithFontconfigCharSet: fcCharset] autorelease];
}
return characterSet;
FcResult result;
FcPattern *resolved;
FcCharSet *charset;
FcConfigSubstitute(NULL, _pattern, FcMatchPattern);
FcDefaultSubstitute(_pattern);
resolved = FcFontMatch(NULL, _pattern, &result);
if (FcResultMatch == FcPatternGetCharSet(resolved, FC_CHARSET, 0, &charset))
{
_characterSet = [[FontconfigCharacterSet alloc] initWithFontconfigCharSet: charset];
}
/* Only try to get the character set once because FcFontMatch is expensive */
if (_characterSet == nil)
{
_hasNoCharacterSet = YES;
}
FcPatternDestroy(resolved);
}
return _characterSet;
}
@end

View file

@ -152,7 +152,7 @@ static NSArray *faFromFc(FcPattern *pat)
FcPattern *pat = FcPatternCreate();
FcObjectSet *os = FcObjectSetBuild(FC_FAMILY, FC_SLANT, FC_WEIGHT,
FC_SPACING, FC_CHARSET, NULL);
FC_SPACING, NULL);
FcFontSet *fs = FcFontList(NULL, pat, os);
FcPatternDestroy(pat);