Changeset 31689 in webkit


Ignore:
Timestamp:
Apr 7, 2008 1:08:30 PM (16 years ago)
Author:
mitz@apple.com
Message:

Reviewed by Dave Hyatt.

  • platform/mac/WebFontCache.mm: (+[WebFontCache internalFontWithFamily:traits:weight:size:]): Changed to match by family name first, and only if that fails, look for a match by full (PostScript) name. Reverted the full name-based match logic to only distinguish between the broad categories of "bold" and "not bold".
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31688 r31689  
     12008-04-07  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=18311
     6          <rdar://problem/5842980> REGRESSION (r31620): Font variants (e.g. Helvetica Neue *Light*) don't render correctly
     7
     8        * platform/mac/WebFontCache.mm:
     9        (+[WebFontCache internalFontWithFamily:traits:weight:size:]): Changed to
     10        match by family name first, and only if that fails, look for a match by
     11        full (PostScript) name. Reverted the full name-based match logic to only
     12        distinguish between the broad categories of "bold" and "not bold".
     13
    1142008-04-07  Timothy Hatcher  <timothy@apple.com>
    215
  • trunk/WebCore/platform/mac/WebFontCache.mm

    r31627 r31689  
    115115    NSFontManager *fontManager = [NSFontManager sharedFontManager];
    116116
    117     // Look for an exact match first.
    118     NSEnumerator *availableFonts = [[fontManager availableFonts] objectEnumerator];
    119     NSString *availableFont;
    120     NSFont *nameMatchedFont = nil;
    121     while ((availableFont = [availableFonts nextObject])) {
    122         if ([desiredFamily caseInsensitiveCompare:availableFont] == NSOrderedSame) {
    123             nameMatchedFont = [NSFont fontWithName:availableFont size:size];
    124 
    125             // Special case Osaka-Mono.  According to <rdar://problem/3999467>, we need to
    126             // treat Osaka-Mono as fixed pitch.
    127             if ([desiredFamily caseInsensitiveCompare:@"Osaka-Mono"] == NSOrderedSame && desiredTraits == 0)
    128                 return nameMatchedFont;
    129 
    130             NSFontTraitMask traits = [fontManager traitsOfFont:nameMatchedFont];
    131             NSInteger weight = [fontManager weightOfFont:nameMatchedFont];
    132             fixUpWeight(weight, availableFont);
    133 
    134             if ((traits & desiredTraits) == desiredTraits && weight == desiredWeight)
    135                 return [fontManager convertFont:nameMatchedFont toHaveTrait:desiredTraits];
    136             break;
    137         }
    138     }
    139 
    140117    // Do a simple case insensitive search for a matching font family.
    141118    // NSFontManager requires exact name matches.
     
    148125    }
    149126
    150     if (!availableFamily)
    151         availableFamily = [nameMatchedFont familyName];
     127    if (!availableFamily) {
     128        // Match by PostScript name.
     129        NSEnumerator *availableFonts = [[fontManager availableFonts] objectEnumerator];
     130        NSString *availableFont;
     131        NSFont *nameMatchedFont = nil;
     132        NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (desiredWeight >= 7 ? NSBoldFontMask : 0);
     133        while ((availableFont = [availableFonts nextObject])) {
     134            if ([desiredFamily caseInsensitiveCompare:availableFont] == NSOrderedSame) {
     135                nameMatchedFont = [NSFont fontWithName:availableFont size:size];
     136
     137                // Special case Osaka-Mono.  According to <rdar://problem/3999467>, we need to
     138                // treat Osaka-Mono as fixed pitch.
     139                if ([desiredFamily caseInsensitiveCompare:@"Osaka-Mono"] == NSOrderedSame && desiredTraitsForNameMatch == 0)
     140                    return nameMatchedFont;
     141
     142                NSFontTraitMask traits = [fontManager traitsOfFont:nameMatchedFont];
     143                if ((traits & desiredTraitsForNameMatch) == desiredTraitsForNameMatch)
     144                    return [fontManager convertFont:nameMatchedFont toHaveTrait:desiredTraitsForNameMatch];
     145
     146                availableFamily = [nameMatchedFont familyName];
     147                break;
     148            }
     149        }
     150    }
    152151
    153152    // Found a family, now figure out what weight and traits to use.
Note: See TracChangeset for help on using the changeset viewer.