Commit e0501bfd authored by thatcher's avatar thatcher
Browse files

Reviewed by Geoff.

        <rdar://problem/4865325> please re-add auto font activation support in WebKit

        * platform/mac/WebFontCache.mm:
        (+[WebFontCache fontWithFamily:traits:size:]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@18680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 78847ce0
2007-01-08 Timothy Hatcher <timothy@apple.com>
Reviewed by Geoff.
<rdar://problem/4865325> please re-add auto font activation support in WebKit
* platform/mac/WebFontCache.mm:
(+[WebFontCache fontWithFamily:traits:size:]):
2007-01-08 Darin Adler <darin@apple.com>
Reviewed by Adam.
......
......@@ -113,30 +113,34 @@ static BOOL betterChoice(NSFontTraitMask desiredTraits, int desiredWeight,
+ (NSFont *)fontWithFamily:(NSString *)desiredFamily traits:(NSFontTraitMask)desiredTraits size:(float)size
{
NSFontManager *fontManager = [NSFontManager sharedFontManager];
NSFont *font= nil;
// Look for an exact match first.
NSEnumerator *availableFonts = [[fontManager availableFonts] objectEnumerator];
NSString *availableFont;
while ((availableFont = [availableFonts nextObject])) {
if ([desiredFamily caseInsensitiveCompare:availableFont] == NSOrderedSame) {
NSFont *nameMatchedFont = [NSFont fontWithName:availableFont size:size];
// Special case Osaka-Mono. According to <rdar://problem/3999467>, we need to
// treat Osaka-Mono as fixed pitch.
if ([desiredFamily caseInsensitiveCompare:@"Osaka-Mono"] == NSOrderedSame && desiredTraits == 0)
return nameMatchedFont;
return nameMatchedFont;
NSFontTraitMask traits = [fontManager traitsOfFont:nameMatchedFont];
if ((traits & desiredTraits) == desiredTraits){
font = [fontManager convertFont:nameMatchedFont toHaveTrait:desiredTraits];
return font;
}
if ((traits & desiredTraits) == desiredTraits)
return [fontManager convertFont:nameMatchedFont toHaveTrait:desiredTraits];
break;
}
}
// font was not immediately available, try auto activated fonts <rdar://problem/4564955>
NSFont *font = [NSFont fontWithName:desiredFamily size:size];
if (font) {
NSFontTraitMask traits = [fontManager traitsOfFont:font];
if ((traits & desiredTraits) == desiredTraits)
return [fontManager convertFont:font toHaveTrait:desiredTraits];
}
// Do a simple case insensitive search for a matching font family.
// NSFontManager requires exact name matches.
// This addresses the problem of matching arial to Arial, etc., but perhaps not all the issues.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment