RESOLVED FIXED 215707
[iOS] attachmentActionFont() Needs to use kCTFontSymbolicTrait: @(kCTFontTraitTightLeading | kCTFontTraitEmphasized) to get the short emphasized footnote font
https://bugs.webkit.org/show_bug.cgi?id=215707
Summary [iOS] attachmentActionFont() Needs to use kCTFontSymbolicTrait: @(kCTFontTrai...
Myles C. Maxfield
Reported 2020-08-20 11:47:40 PDT
[iOS] CTFontDescriptorCreateWithTextStyleAndAttributes() is faster than CTFontDescriptorCreateWithTextStyle()/CTFontDescriptorCreateCopyWithAttributes()
Attachments
Patch (5.34 KB, patch)
2020-08-20 11:54 PDT, Myles C. Maxfield
no flags
Patch (5.51 KB, patch)
2020-09-05 02:09 PDT, Myles C. Maxfield
no flags
Patch (6.04 KB, patch)
2020-09-06 15:59 PDT, Myles C. Maxfield
no flags
Patch (6.29 KB, patch)
2020-09-06 17:02 PDT, Myles C. Maxfield
no flags
Patch (6.19 KB, patch)
2020-09-06 17:07 PDT, Myles C. Maxfield
no flags
Patch (6.28 KB, patch)
2020-09-06 17:37 PDT, Myles C. Maxfield
darin: review+
Patch for committing (8.03 KB, patch)
2020-09-06 18:06 PDT, Myles C. Maxfield
no flags
Myles C. Maxfield
Comment 1 2020-08-20 11:54:45 PDT
Radar WebKit Bug Importer
Comment 2 2020-08-27 11:48:13 PDT
Myles C. Maxfield
Comment 3 2020-09-05 02:09:34 PDT
Sam Weinig
Comment 4 2020-09-05 08:58:58 PDT
Comment on attachment 408079 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408079&action=review > Source/WebCore/ChangeLog:4 > + [iOS] CTFontDescriptorCreateWithTextStyleAndAttributes() is faster than CTFontDescriptorCreateWithTextStyle()/CTFontDescriptorCreateCopyWithAttributes() > + https://bugs.webkit.org/show_bug.cgi?id=215707 Do you have any perf measurements for this claim? > Source/WTF/wtf/PlatformHave.h:740 > +#define HAVE_CTFONTDESCRIPTORCREATEWITHTEXTSTYLEANDATTRIBUTES 1 Please throw some underscores in there. This is not really readable as is.
Darin Adler
Comment 5 2020-09-05 09:05:34 PDT
Comment on attachment 408079 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408079&action=review > Source/WebCore/rendering/RenderThemeIOS.mm:1403 > + RetainPtr<CTFontDescriptorRef> emphasizedFontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyleAndAttributes(kCTUIFontTextStyleFootnote, RenderThemeIOS::contentSizeCategory(), (CFDictionaryRef)@{ (id)kCTFontTraitsAttribute: @{ (id)kCTFontSymbolicTrait: @(kCTFontTraitTightLeading | kCTFontTraitEmphasized) } })); auto
Myles C. Maxfield
Comment 6 2020-09-06 15:44:37 PDT
Myles C. Maxfield
Comment 7 2020-09-06 15:49:18 PDT
Oh, I see. Even if CTFontDescriptorCreateWithTextStyleAndAttributes() doesn’t exist, we should still modify the existing code to use (id)kCTFontSymbolicTrait: @(kCTFontTraitTightLeading | kCTFontTraitEmphasized). This is about correctness, not performance.
Myles C. Maxfield
Comment 8 2020-09-06 15:59:14 PDT
Darin Adler
Comment 9 2020-09-06 16:48:37 PDT
Comment on attachment 408147 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408147&action=review > Source/WebCore/rendering/RenderThemeIOS.mm:1408 > +#if HAVE(CTFONTDESCRIPTOR_CREATE_WITH_TEXT_STYLE_AND_ATTRIBUTES) > + auto emphasizedFontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyleAndAttributes(kCTUIFontTextStyleFootnote, RenderThemeIOS::contentSizeCategory(), (CFDictionaryRef)@{ (id)kCTFontTraitsAttribute: @{ (id)kCTFontSymbolicTrait: @(kCTFontTraitTightLeading | kCTFontTraitEmphasized) } })); > +#else > + auto fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(kCTUIFontTextStyleShortFootnote, RenderThemeIOS::singleton().contentSizeCategory(), 0)); > + auto emphasizedFontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithAttributes(fontDescriptor.get(), > + (CFDictionaryRef)@{ (id)kCTFontTraitsAttribute: @{ (id)kCTFontSymbolicTrait: @(kCTFontTraitTightLeading | kCTFontTraitEmphasized) } })); > +#endif Maybe we could put the attributes dictionary outside the #if? I wouldn’t mind having one more local variable for it.
Myles C. Maxfield
Comment 10 2020-09-06 17:02:22 PDT
Darin Adler
Comment 11 2020-09-06 17:06:30 PDT
Comment on attachment 408151 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408151&action=review > Source/WebCore/rendering/RenderThemeIOS.mm:1403 > + auto emphasizedFontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyleAndAttributes(kCTUIFontTextStyleFootnote, RenderThemeIOS::contentSizeCategory(), (CFDictionaryRef)@{ (id)kCTFontTraitsAttribute: @{ (id)kCTFontSymbolicTrait: @(kCTFontTraitTightLeading | kCTFontTraitEmphasized) } })); This calls RenderThemeIOS::contentSizeCategory(). > Source/WebCore/rendering/RenderThemeIOS.mm:1405 > + auto fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(kCTUIFontTextStyleShortFootnote, RenderThemeIOS::singleton().contentSizeCategory(), 0)); This calls RenderThemeIOS::singleton().contentSizeCategory(). Why the difference? I suggest refactoring so only the CTFontDescriptorCreateWithTextStyleAndAttributes call has an #if in it, and all the arguments are shared.
Myles C. Maxfield
Comment 12 2020-09-06 17:07:25 PDT
Myles C. Maxfield
Comment 13 2020-09-06 17:37:36 PDT
Darin Adler
Comment 14 2020-09-06 17:59:05 PDT
Comment on attachment 408155 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408155&action=review > Source/WebCore/rendering/RenderThemeIOS.mm:1404 > + CFStringRef style = kCTUIFontTextStyleFootnote; > + CFStringRef size = RenderThemeIOS::singleton().contentSizeCategory(); > + CFDictionaryRef attributes = static_cast<CFDictionaryRef>(@{ (id)kCTFontTraitsAttribute: @{ (id)kCTFontSymbolicTrait: @(kCTFontTraitTightLeading | kCTFontTraitEmphasized) } }); I would have used auto for all three of these.
Myles C. Maxfield
Comment 15 2020-09-06 18:06:01 PDT
Created attachment 408157 [details] Patch for committing
EWS
Comment 16 2020-09-06 23:19:42 PDT
Committed r266693: <https://trac.webkit.org/changeset/266693> All reviewed patches have been landed. Closing bug and clearing flags on attachment 408157 [details].
Note You need to log in before you can comment on or make changes to this bug.