Bug 132030 - [OS X] Make checking if a font is the system font more robust
Summary: [OS X] Make checking if a font is the system font more robust
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords:
Depends on: 132070
Blocks:
  Show dependency treegraph
 
Reported: 2014-04-22 17:01 PDT by Myles C. Maxfield
Modified: 2014-04-23 20:51 PDT (History)
5 users (show)

See Also:


Attachments
Patch (3.97 KB, patch)
2014-04-22 17:07 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (3.77 KB, patch)
2014-04-22 21:09 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (3.91 KB, patch)
2014-04-23 14:25 PDT, Myles C. Maxfield
darin: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2014-04-22 17:01:38 PDT
[OS X] Make checking if a font is the system font more robust
Comment 1 Myles C. Maxfield 2014-04-22 17:07:08 PDT
Created attachment 229925 [details]
Patch
Comment 2 Dean Jackson 2014-04-22 17:36:12 PDT
Comment on attachment 229925 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=229925&action=review

> Source/WebCore/platform/graphics/mac/FontMac.mm:40
> +extern "C" bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);

Do we want to wrap this in a #if __MAC_MIN thing as well, to make it clear we only use it on 1090+?

> Source/WebCore/platform/graphics/mac/FontMac.mm:545
> +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090

So this existed on 10.9 as well?
Comment 3 Tim Horton 2014-04-22 17:45:54 PDT
Comment on attachment 229925 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=229925&action=review

> Source/WebCore/platform/graphics/mac/FontMac.mm:37
> +#if defined(__has_include) && __has_include(<CoreText/CTFontDescriptorPriv.h>)

we don't need the defined() part

> Source/WebCore/platform/graphics/mac/FontMac.mm:548
> +    return firstFamily().startsWith('.');

does this actually make sense on any platform? were there dot-prefixed fonts in 10.8?
Comment 4 Myles C. Maxfield 2014-04-22 21:07:23 PDT
Comment on attachment 229925 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=229925&action=review

>> Source/WebCore/platform/graphics/mac/FontMac.mm:37
>> +#if defined(__has_include) && __has_include(<CoreText/CTFontDescriptorPriv.h>)
> 
> we don't need the defined() part

Done.

>> Source/WebCore/platform/graphics/mac/FontMac.mm:40
>> +extern "C" bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
> 
> Do we want to wrap this in a #if __MAC_MIN thing as well, to make it clear we only use it on 1090+?

I actually feel like this would do more harm than good. It would add more preprocessor bloat, and wouldn't actually be very valuable. There are many places in WebKit where functions are declared, yet never used or defined. Therefore, seeing a function declaration already doesn't necessarily mean that we ever use it.

>> Source/WebCore/platform/graphics/mac/FontMac.mm:545
>> +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090
> 
> So this existed on 10.9 as well?

Yep!

>> Source/WebCore/platform/graphics/mac/FontMac.mm:548
>> +    return firstFamily().startsWith('.');
> 
> does this actually make sense on any platform? were there dot-prefixed fonts in 10.8?

Conveniently, the only platforms with the dot prefix are also platforms which have the CTFontDescriptorIsSystemUIFont() call :) Done.
Comment 5 Myles C. Maxfield 2014-04-22 21:09:44 PDT
Created attachment 229951 [details]
Patch
Comment 6 Myles C. Maxfield 2014-04-23 10:50:51 PDT
First patch r+'ed by dino. Second patch simply addresses comments.

http://trac.webkit.org/changeset/167713
Comment 7 WebKit Commit Bot 2014-04-23 11:28:57 PDT
Re-opened since this is blocked by bug 132070
Comment 8 Myles C. Maxfield 2014-04-23 14:25:45 PDT
Created attachment 230010 [details]
Patch
Comment 9 Myles C. Maxfield 2014-04-23 14:34:13 PDT
Re-landed in http://trac.webkit.org/changeset/167724
Comment 10 Darin Adler 2014-04-23 20:32:28 PDT
Comment on attachment 230010 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=230010&action=review

I think you already landed this, but it was still marked review?

> Source/WebCore/platform/graphics/mac/FontMac.mm:546
> +    RetainPtr<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(primaryFont()->platformData().ctFont());

This needs an adoptCF, otherwise it will be a storage leak.
Comment 11 Myles C. Maxfield 2014-04-23 20:51:38 PDT
Yeah - I marked the bug as closed but forgot to clear the r?. Thanks for the review.