Bug 147033 - Web Inspector: [iOS] Allow inspector to retrieve a list of system fonts
Summary: Web Inspector: [iOS] Allow inspector to retrieve a list of system fonts
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-07-16 23:51 PDT by Devin Rousso
Modified: 2015-08-10 13:51 PDT (History)
9 users (show)

See Also:


Attachments
Patch (2.73 KB, patch)
2015-07-31 18:10 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (2.44 KB, patch)
2015-08-07 21:06 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2015-07-16 23:51:57 PDT
This will be really useful for a font picker and for autocompletion.  See https://bugs.webkit.org/show_bug.cgi?id=147009 for more details.
Comment 1 Radar WebKit Bug Importer 2015-07-16 23:52:15 PDT
<rdar://problem/21870250>
Comment 2 Devin Rousso 2015-07-31 18:10:10 PDT
Created attachment 257985 [details]
Patch
Comment 3 Joseph Pecoraro 2015-07-31 18:28:17 PDT
Comment on attachment 257985 [details]
Patch

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

r=me, but should probably get a nod from Myles.

> Source/WebCore/platform/graphics/ios/FontCacheIOS.mm:471
> +    NSDictionary *attributes = @{ };
> +    RetainPtr<CTFontDescriptorRef> fontDescriptor = adoptCF(CTFontDescriptorCreateWithAttributes((CFDictionaryRef)attributes));

You can just inline this dictionary.

> Source/WebCore/platform/graphics/ios/FontCacheIOS.mm:472
> +    RetainPtr<NSArray> matchedDescriptors = adoptNS((NSArray *)CTFontDescriptorCreateMatchingFontDescriptors(fontDescriptor.get(), nullptr));

Nit: static_cast.

Also, both of these can be "auto", the type is relatively easy to determine.

> Source/WebCore/platform/graphics/ios/FontCacheIOS.mm:474
> +    NSInteger numMatches = [matchedDescriptors.get() count];

Style: I actually think the ".git()" is unnecessary here. It should just work without it.

> Source/WebCore/platform/graphics/ios/FontCacheIOS.mm:480
> +        RetainPtr<CFStringRef> familyName = adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute((CTFontDescriptorRef)[matchedDescriptors.get() objectAtIndex:i], kCTFontFamilyNameAttribute)));

Nit: static_cast. You can split this out into a couple lines to be more readable. Could also be auto given the CFStringRef cast will be on the line anyways.
Comment 4 Myles C. Maxfield 2015-07-31 20:55:18 PDT
Comment on attachment 257985 [details]
Patch

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

>> Source/WebCore/platform/graphics/ios/FontCacheIOS.mm:480
>> +        RetainPtr<CFStringRef> familyName = adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute((CTFontDescriptorRef)[matchedDescriptors.get() objectAtIndex:i], kCTFontFamilyNameAttribute)));
> 
> Nit: static_cast. You can split this out into a couple lines to be more readable. Could also be auto given the CFStringRef cast will be on the line anyways.

Why are you using CF* here when everywhere else you are using NS*?

> Source/WebCore/platform/graphics/ios/FontCacheIOS.mm:488
> +        if (familyName.startsWith('.'))

Please move this check into the loop above.

> Source/WebCore/platform/graphics/ios/FontCacheIOS.mm:489
> +            continue;

I'm not sure this line will ever be hit. CT may not ever return these period-prefixed font names. It's worth checking (even on older operating systems)
Comment 5 Devin Rousso 2015-08-07 21:06:40 PDT
Created attachment 258558 [details]
Patch
Comment 6 Joseph Pecoraro 2015-08-10 11:30:34 PDT
Comment on attachment 258558 [details]
Patch

r=me
Comment 7 WebKit Commit Bot 2015-08-10 13:51:51 PDT
Comment on attachment 258558 [details]
Patch

Clearing flags on attachment: 258558

Committed r188227: <http://trac.webkit.org/changeset/188227>
Comment 8 WebKit Commit Bot 2015-08-10 13:51:57 PDT
All reviewed patches have been landed.  Closing bug.