<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>291667</bug_id>
          
          <creation_ts>2025-04-16 22:06:52 -0700</creation_ts>
          <short_desc>REGRESSION(288714@main): CanvasRenderingContext2D font with normal line height fails to parse</short_desc>
          <delta_ts>2025-05-15 12:43:22 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Canvas</component>
          <version>Safari 18</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 15</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=285707</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>wilson.louie</reporter>
          <assigned_to name="Sam Weinig">sam</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ej.sefah</cc>
    
    <cc>karlcow</cc>
    
    <cc>koivisto</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>sam</cc>
    
    <cc>vitor.roriz</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2111447</commentid>
    <comment_count>0</comment_count>
    <who name="">wilson.louie</who>
    <bug_when>2025-04-16 22:06:52 -0700</bug_when>
    <thetext>Overview:
Starting In Safari 18.4 (tested on macOS 15 Apple Silicon), when a font string containing a &quot;normal&quot; line-height value is set on the CanvasRenderingContext2D instance, it fails to parse. Getting the font value from the context just returns the default &apos;10px sans-serif&apos;.
This was not a problem in prior Safari versions, such as 18.3.1


Steps to Reproduce:
1) Go to this reproducible test case: https://codepen.io/wlouie1/pen/qEEBMGa?editors=1111
2) Look at the console log. Compare them in Safari 18.4, prior Safari versions, and Chrome.


Actual Results:
As shown in the CodePen link:
Set ctx.font = &apos;normal normal 400 normal 12px/normal Arial, Helvetica, sans-serif&apos;;
Log ctx.font: &apos;10px sans-serif&apos;

Also as shown in the CodePen link, either omitting the &quot;normal&quot; line-height (which should be equivalent because it&apos;s the default line-height value) from the font string, or specifying any other line-height value, like 14px, works as expected. Logging ctx.font gives the expected &apos;12px Arial, Helvetica, sans-serif&apos;

Chrome 135 or prior Safari versions correctly logs &apos;12px Arial, Helvetica, sans-serif&apos; for all 3 cases.


Expected Results:
Set ctx.font = &apos;normal normal 400 normal 12px/normal Arial, Helvetica, sans-serif&apos;;
Log ctx.font: &apos;12px Arial, Helvetica, sans-serif&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2111471</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2025-04-17 01:20:31 -0700</bug_when>
    <thetext>*** Safari Technology Preview 217 on macOS Sequoia ***

&quot;
Set: normal normal 400 normal 12px/normal Arial, Helvetica, sans-serif
Get: 10px sans-serif &lt;------------------------------------------ bug
&quot;
&quot;
Set: normal normal 400 normal 12px Arial, Helvetica, sans-serif
Get: 12px Arial, Helvetica, sans-serif
&quot;
&quot;
Set: normal normal 400 normal 12px/14px Arial, Helvetica, sans-serif
Get: 12px Arial, Helvetica, sans-serif
&quot;
*** Chrome Canary 137.0.7128.0 (Official Build) canary (arm64)  ***

&quot;
Set: normal normal 400 normal 12px/normal Arial, Helvetica, sans-serif
Get: 12px Arial, Helvetica, sans-serif
&quot;
&quot;
Set: normal normal 400 normal 12px Arial, Helvetica, sans-serif
Get: 12px Arial, Helvetica, sans-serif
&quot;
&quot;
Set: normal normal 400 normal 12px/14px Arial, Helvetica, sans-serif
Get: 12px Arial, Helvetica, sans-serif
&quot;

*** Firefox Nightly 139 (20250414211452) ***

&quot;
Set: normal normal 400 normal 12px/normal Arial, Helvetica, sans-serif
Get: 12px Arial, Helvetica, sans-serif
&quot;

&quot;
Set: normal normal 400 normal 12px Arial, Helvetica, sans-serif
Get: 12px Arial, Helvetica, sans-serif
&quot;

&quot;
Set: normal normal 400 normal 12px/14px Arial, Helvetica, sans-serif
Get: 12px Arial, Helvetica, sans-serif
&quot;

_________

STP 217 is broken as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2111472</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-04-17 01:21:05 -0700</bug_when>
    <thetext>&lt;rdar://problem/149459999&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2111501</commentid>
    <comment_count>3</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-04-17 04:40:40 -0700</bug_when>
    <thetext>it looks like a parsing error in the code. 

pass 12px/20px
pass 12px/12
fail 12px/a
fail 12px/normal

Canvas is using
https://searchfox.org/wubkat/rev/5df2953b4ca7158afd166f3f8c130d1a8888cf0f/Source/WebCore/css/parser/CSSPropertyParserConsumer%2BFont.cpp#345-376


https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-font

&gt; The font IDL attribute, on setting, must be parsed as a CSS &lt;&apos;font&apos;&gt; value (but without supporting property-independent style sheet syntax like &apos;inherit&apos;), and the resulting font must be assigned to the context, with the &apos;line-height&apos; component forced to &apos;normal&apos;, with the &apos;font-size&apos; component converted to CSS pixels, and with system fonts being computed to explicit values. If the new value is syntactically incorrect (including using property-independent style sheet syntax like &apos;inherit&apos; or &apos;initial&apos;), then it must be ignored, without assigning a new font value.

And 

&gt; When the &apos;font-size&apos; component is set to lengths using percentages, &apos;em&apos; or &apos;ex&apos; units, or the &apos;larger&apos; or &apos;smaller&apos; keywords, these must be interpreted relative to the computed value of the &apos;font-size&apos; property of the font style source object at the time that the attribute is set

I wonder if Safari is not right here (?) interpreting the spec. aka this part

&gt; If the new value is syntactically incorrect (including using property-independent style sheet syntax like &apos;inherit&apos; or &apos;initial&apos;), then it must be ignored, without assigning a new font value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2112133</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-04-20 18:58:12 -0700</bug_when>
    <thetext>Wilson
 Thanks for the bug report

Does it affect one of your products at Oracle?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2112323</commentid>
    <comment_count>5</comment_count>
    <who name="">wilson.louie</who>
    <bug_when>2025-04-21 18:45:32 -0700</bug_when>
    <thetext>(In reply to Karl Dubost from comment #4)
&gt; Wilson
&gt;  Thanks for the bug report
&gt; 
&gt; Does it affect one of your products at Oracle?

Thanks Karl, yes, and we&apos;re currently working around it by omitting the &quot;normal&quot; line-height value from the font string.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2115439</commentid>
    <comment_count>6</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2025-05-06 13:16:56 -0700</bug_when>
    <thetext>This is a regression of 288714@main.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2116304</commentid>
    <comment_count>7</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2025-05-10 11:09:20 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/45208</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2116373</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-05-11 13:32:42 -0700</bug_when>
    <thetext>Committed 294767@main (3606cb0acd00): &lt;https://commits.webkit.org/294767@main&gt;

Reviewed commits have been landed. Closing PR #45208 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2117398</commentid>
    <comment_count>9</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-05-15 12:43:22 -0700</bug_when>
    <thetext>Committed 289651.520@safari-7621-branch (d5311fc7eb27): &lt;https://commits.webkit.org/289651.520@safari-7621-branch&gt;

Reviewed commits have been landed. Closing PR #3090 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>