[wp-trac] [WordPress Trac] #63404: Incorrect endValue for font weights

WordPress Trac noreply at wordpress.org
Wed May 7 06:09:39 UTC 2025


#63404: Incorrect endValue for font weights
--------------------------+------------------------------
 Reporter:  greenskin43   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Editor        |     Version:  6.8
 Severity:  major         |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by sourav08):

 Hello @greenskin43 , Welcome to WordPress Core Trac

 The current implementation, while it may appear imprecise at first glance,
 does correctly handle variable font weight ranges like "100 900".

 Here’s what it does:

 1. It parses the first digit of the start and end values (e.g., "100" → 1,
 "900" → 9).

 2. It then uses a loop from startValue to endValue and multiplies by 100
 during formatting:


 {{{
 const fontWeightValue = `${i.toString()}00`;
 }}}

 So for a range like "100 900", the loop iterates from 1 to 9, and produces
 values "100", "200", ..., "900" — which is correct.

 The special case for "1000" converting to 10 is also handled explicitly to
 support rare variable font cases (e.g., 1000 weight).

 While this approach could be made more robust by directly parsing the full
 numeric values (parseInt(startValue) and parseInt(endValue)), the current
 logic is functionally correct and does generate the appropriate weight
 values for editor controls.

 Please let me know if there are any other concerns related to this? Thanks

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63404#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list