⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181569 in webkit


Ignore:
Timestamp:
Mar 16, 2015, 11:30:34 AM (11 years ago)
Author:
ap@apple.com
Message:

[Mac] fast/forms/text-control-intrinsic-widths.html fails when MS Office is installed
https://bugs.webkit.org/show_bug.cgi?id=142720

Reviewed by Myles C. Maxfield.

Tools:

Activate system copies of Microsoft fonts for the current process, thus overriding
any other ones that could be preferred by the system otherwise.

  • DumpRenderTree/mac/DumpRenderTree.mm:

(activateSystemCoreWebFonts):
(adjustFonts):

  • WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:

(WTR::activateSystemCoreWebFonts):
(WTR::activateFonts):

LayoutTests:

  • platform/mac-mavericks/fast/forms/text-control-intrinsic-widths-expected.txt: Removed.

Mavericks result is no different from Yosemite.

Location:
trunk
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181566 r181569  
     12015-03-16  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [Mac] fast/forms/text-control-intrinsic-widths.html fails when MS Office is installed
     4        https://bugs.webkit.org/show_bug.cgi?id=142720
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        * platform/mac-mavericks/fast/forms/text-control-intrinsic-widths-expected.txt: Removed.
     9        Mavericks result is no different from Yosemite.
     10
    1112015-03-16  Brent Fulgham  <bfulgham@apple.com>
    212
  • trunk/Tools/ChangeLog

    r181532 r181569  
     12015-03-16  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [Mac] fast/forms/text-control-intrinsic-widths.html fails when MS Office is installed
     4        https://bugs.webkit.org/show_bug.cgi?id=142720
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Activate system copies of Microsoft fonts for the current process, thus overriding
     9        any other ones that could be preferred by the system otherwise.
     10
     11        * DumpRenderTree/mac/DumpRenderTree.mm:
     12        (activateSystemCoreWebFonts):
     13        (adjustFonts):
     14        * WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
     15        (WTR::activateSystemCoreWebFonts):
     16        (WTR::activateFonts):
     17
    1182015-03-16  Xabier Rodriguez Calvar  <calvaris@igalia.com>
    219
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r181359 r181569  
    474474}
    475475
     476// Activating system copies of these fonts overrides any others that could be preferred, such as ones
     477// in /Library/Fonts/Microsoft, and which don't always have the same metrics.
     478// FIXME: Switch to a solution from <rdar://problem/19553550> once it's available.
     479static void activateSystemCoreWebFonts()
     480{
     481    NSArray *coreWebFontNames = @[
     482        @"Andale Mono",
     483        @"Arial",
     484        @"Arial Black",
     485        @"Comic Sans MS",
     486        @"Courier New",
     487        @"Georgia",
     488        @"Impact",
     489        @"Times New Roman",
     490        @"Trebuchet MS",
     491        @"Verdana",
     492        @"Webdings"
     493    ];
     494
     495    NSArray *fontFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:@"/Library/Fonts" isDirectory:YES]
     496        includingPropertiesForKeys:@[NSURLFileResourceTypeKey, NSURLNameKey] options:0 error:0];
     497
     498    for (NSURL *fontURL in fontFiles) {
     499        NSString *resourceType;
     500        NSString *fileName;
     501        if (![fontURL getResourceValue:&resourceType forKey:NSURLFileResourceTypeKey error:0]
     502            || ![fontURL getResourceValue:&fileName forKey:NSURLNameKey error:0])
     503            continue;
     504        if (![resourceType isEqualToString:NSURLFileResourceTypeRegular])
     505            continue;
     506
     507        // Activate all font variations, such as Arial Bold Italic.ttf. This algorithm is not 100% precise, as it
     508        // also activates e.g. Arial Unicode, which is not a variation of Arial.
     509        for (NSString *coreWebFontName in coreWebFontNames) {
     510            if ([fileName hasPrefix:coreWebFontName]) {
     511                CTFontManagerRegisterFontsForURL((CFURLRef)fontURL, kCTFontManagerScopeProcess, 0);
     512                break;
     513            }
     514        }
     515    }
     516}
     517
    476518static void activateTestingFonts()
    477519{
     
    509551{
    510552    swizzleNSFontManagerMethods();
     553    activateSystemCoreWebFonts();
    511554    activateTestingFonts();
    512555}
  • trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm

    r180557 r181569  
    242242}
    243243
     244// Activating system copies of these fonts overrides any others that could be preferred, such as ones
     245// in /Library/Fonts/Microsoft, and which don't always have the same metrics.
     246// FIXME: Switch to a solution from <rdar://problem/19553550> once it's available.
     247static void activateSystemCoreWebFonts()
     248{
     249    NSArray *coreWebFontNames = @[
     250        @"Andale Mono",
     251        @"Arial",
     252        @"Arial Black",
     253        @"Comic Sans MS",
     254        @"Courier New",
     255        @"Georgia",
     256        @"Impact",
     257        @"Times New Roman",
     258        @"Trebuchet MS",
     259        @"Verdana",
     260        @"Webdings"
     261    ];
     262
     263    NSArray *fontFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:@"/Library/Fonts" isDirectory:YES]
     264        includingPropertiesForKeys:@[NSURLFileResourceTypeKey, NSURLNameKey] options:0 error:0];
     265
     266    for (NSURL *fontURL in fontFiles) {
     267        NSString *resourceType;
     268        NSString *fileName;
     269        if (![fontURL getResourceValue:&resourceType forKey:NSURLFileResourceTypeKey error:0]
     270            || ![fontURL getResourceValue:&fileName forKey:NSURLNameKey error:0])
     271            continue;
     272        if (![resourceType isEqualToString:NSURLFileResourceTypeRegular])
     273            continue;
     274
     275        // Activate all font variations, such as Arial Bold Italic.ttf. This algorithm is not 100% precise, as it
     276        // also activates e.g. Arial Unicode, which is not a variation of Arial.
     277        for (NSString *coreWebFontName in coreWebFontNames) {
     278            if ([fileName hasPrefix:coreWebFontName]) {
     279                CTFontManagerRegisterFontsForURL((CFURLRef)fontURL, kCTFontManagerScopeProcess, 0);
     280                break;
     281            }
     282        }
     283    }
     284}
     285
    244286#endif // USE(APPKIT)
    245287
     
    277319#if USE(APPKIT)
    278320    swizzleNSFontManagerMethods();
     321    activateSystemCoreWebFonts();
    279322#endif // USE(APPKIT)
    280323}
Note: See TracChangeset for help on using the changeset viewer.