Bug 233070

Summary: [Cocoa] REGRESSION(r281291): Text Style fonts don't have the correct weight set
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: New BugsAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: changseok, esprehn+autocc, ews-watchlist, glenn, heycam, kondapallykalyan, pdr, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Needs test
none
Needs test
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch heycam: review+

Myles C. Maxfield
Reported 2021-11-12 13:30:56 PST
[Cocoa] Text style fonts shouldn't have their weight/width/slope overridden by font-weight/font-stretch/font-style
Attachments
Needs test (10.58 KB, patch)
2021-11-12 13:37 PST, Myles C. Maxfield
no flags
Needs test (10.58 KB, patch)
2021-11-12 13:39 PST, Myles C. Maxfield
no flags
Patch (12.58 KB, patch)
2021-11-12 14:35 PST, Myles C. Maxfield
no flags
Patch (17.42 KB, patch)
2021-11-18 23:48 PST, Myles C. Maxfield
no flags
Patch (20.97 KB, patch)
2021-11-19 15:09 PST, Myles C. Maxfield
no flags
Patch (12.96 KB, patch)
2021-11-23 14:32 PST, Myles C. Maxfield
no flags
Patch (11.54 KB, patch)
2021-11-23 17:13 PST, Myles C. Maxfield
heycam: review+
Myles C. Maxfield
Comment 1 2021-11-12 13:37:02 PST
Created attachment 444106 [details] Needs test
Myles C. Maxfield
Comment 2 2021-11-12 13:37:52 PST
Myles C. Maxfield
Comment 3 2021-11-12 13:39:27 PST
Created attachment 444107 [details] Needs test
Myles C. Maxfield
Comment 4 2021-11-12 14:35:14 PST
Myles C. Maxfield
Comment 5 2021-11-18 23:48:39 PST
Myles C. Maxfield
Comment 6 2021-11-19 15:09:14 PST
Myles C. Maxfield
Comment 7 2021-11-20 14:03:06 PST
This needs more investigation, I think. We do: textStyle = kCTUIFontTextStyleBody; fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr)); ... auto font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr)); ... fontDescription.setWeight(cssWeightOfSystemFont(font.get())); So we’re creating the text style font, pulling out its weight, then setting the font-weight property to that, which should work, if we then re-apply that same weight later. I think I need more investigation here. This patch might be wrong.
Myles C. Maxfield
Comment 8 2021-11-20 18:08:18 PST
Oh, I think I see what's happening. Just like: font: bold 48px 'Helvetica'; font-weight: normal; causes the text to be rendered with normal weight, not bold, font: -apple-system-body; font-weight: normal; causes text to be rendered with normal weight, not whatever weight -apple-system-body corresponds to.
Myles C. Maxfield
Comment 9 2021-11-23 14:09:50 PST
Aha! CFDictionaryGetValue(CTFontCopyTraits(CTFontCreateWithFontDescriptor(CTFontDescriptorCreateWithTextStyle(kCTUIFontTextStyleBody, contentSizeCategory(), nullptr))), kCTFontWeightTrait) is returning 0
Myles C. Maxfield
Comment 10 2021-11-23 14:23:08 PST
I can just use kCTFontCSSWeightAttribute instead.
Myles C. Maxfield
Comment 11 2021-11-23 14:32:30 PST
Myles C. Maxfield
Comment 12 2021-11-23 17:13:14 PST
Cameron McCormack (:heycam)
Comment 13 2021-11-23 17:55:38 PST
Comment on attachment 445055 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=445055&action=review > Source/WebCore/rendering/RenderThemeCocoa.mm:287 > + CFNumberRef resultRef = static_cast<CFNumberRef>(CTFontCopyAttribute(font, kCTFontCSSWeightAttribute)); "auto resultRef"
Myles C. Maxfield
Comment 14 2021-11-29 11:51:24 PST
Comment on attachment 445055 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=445055&action=review >> Source/WebCore/rendering/RenderThemeCocoa.mm:287 >> + CFNumberRef resultRef = static_cast<CFNumberRef>(CTFontCopyAttribute(font, kCTFontCSSWeightAttribute)); > > "auto resultRef" I wrote a memory leak :( this line needs an adoptCF().
Myles C. Maxfield
Comment 15 2021-11-29 12:25:26 PST
Note You need to log in before you can comment on or make changes to this bug.