Changeset 167713 in webkit


Ignore:
Timestamp:
Apr 23, 2014 10:49:40 AM (10 years ago)
Author:
mmaxfield@apple.com
Message:

[OS X] Make checking if a font is the system font more robust
https://bugs.webkit.org/show_bug.cgi?id=132030

Reviewed by Dean Jackson.

Instead of inspecting a font's name to determine if it is a system font,
on OS X we can ask the system directly.

This patch also moves a platform-specific check into platform-specific
code, so that other platforms don't check for OS X-specific behavior.

Covered by existing tests.

  • platform/graphics/Font.cpp:

(WebCore::Font::hasValidAverageCharWidth):

  • platform/graphics/Font.h:
  • platform/graphics/mac/FontMac.mm:

(WebCore::Font::primaryFontDataIsSystemFont):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167712 r167713  
     12014-04-22  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [OS X] Make checking if a font is the system font more robust
     4        https://bugs.webkit.org/show_bug.cgi?id=132030
     5
     6        Reviewed by Dean Jackson.
     7
     8        Instead of inspecting a font's name to determine if it is a system font,
     9        on OS X we can ask the system directly.
     10
     11        This patch also moves a platform-specific check into platform-specific
     12        code, so that other platforms don't check for OS X-specific behavior.
     13
     14        Covered by existing tests.
     15
     16        * platform/graphics/Font.cpp:
     17        (WebCore::Font::hasValidAverageCharWidth):
     18        * platform/graphics/Font.h:
     19        * platform/graphics/mac/FontMac.mm:
     20        (WebCore::Font::primaryFontDataIsSystemFont):
     21
    1222014-04-23  Philippe Normand  <pnormand@igalia.com>
    223
  • trunk/Source/WebCore/platform/graphics/Font.cpp

    r167082 r167713  
    482482        return false;
    483483
    484     // Internal fonts on OS X also have an invalid entry in the table for avgCharWidth.
    485     // They are hidden by having a name that begins with a period, so simply search
    486     // for that here rather than try to keep the list up to date.
    487     if (family.startsWith('.'))
    488         return false;
     484#if PLATFORM(MAC) || PLATFORM(IOS)
     485    // Internal fonts on OS X and iOS also have an invalid entry in the table for avgCharWidth.
     486    if (primaryFontDataIsSystemFont())
     487        return false;
     488#endif
    489489
    490490    static HashSet<AtomicString>* fontFamiliesWithInvalidCharWidthMap = 0;
  • trunk/Source/WebCore/platform/graphics/Font.h

    r167473 r167713  
    189189    static CodePath characterRangeCodePath(const LChar*, unsigned) { return Simple; }
    190190    static CodePath characterRangeCodePath(const UChar*, unsigned len);
     191   
     192    bool primaryFontDataIsSystemFont() const;
    191193
    192194private:
  • trunk/Source/WebCore/platform/graphics/mac/FontMac.mm

    r166322 r167713  
    3535#import <wtf/MathExtras.h>
    3636
     37#if __has_include(<CoreText/CTFontDescriptorPriv.h>)
     38#import <CoreText/CTFontDescriptorPriv.h>
     39#endif
     40extern "C" bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
     41
    3742#if ENABLE(LETTERPRESS)
    3843#import "SoftLinking.h"
     
    536541#endif
    537542
    538 }
     543bool Font::primaryFontDataIsSystemFont() const
     544{
     545#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     546    RetainPtr<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(primaryFont()->platformData().ctFont());
     547    return CTFontDescriptorIsSystemUIFont(descriptor.get());
     548#else
     549    return false;
     550#endif
     551}
     552
     553}
Note: See TracChangeset for help on using the changeset viewer.