Closed Bug 1452973 Opened 3 years ago Closed 3 years ago

Update NS_FONT_STRETCH_* constants to percentage-based values in preparation for CSS Fonts 4


(Core :: Layout: Text and Fonts, enhancement)

Not set



Tracking Status
firefox61 --- fixed


(Reporter: jfkthame, Assigned: jfkthame)


(Blocks 1 open bug)



(1 file, 1 obsolete file)

Currently, we use constants in the range [-4 .. 4] to represent the 9 possible font-stretch values from ultra-condensed to ultra-expanded.

However, CSS Fonts 4 updates font-stretch to accept not just the 9 enumerated values, but any non-negative percentage value (with the enumerated values mapping to percentages from ultra-condensed at 50% to ultra-expanded at 200%).

In preparation for this, I propose revising the constants to values based on the CSS Fonts 4 percentage definitions. This allows us to make the necessary changes to the font-matching algorithm, and to begin mapping font-stretch values to the 'wdth' axis in OpenType variation fonts.

(At this point, I'm leaving the stretch fields in gfxFontStyle, gfxFontEntry, etc as integers, to minimize risk in this bug. The next step, when parsing is updated to accept floating-point percentage values in addition to the enumerated values, will be to switch to a floating- or fixed-point representation for all the affected font properties -- stretch, weight, style.)
This is mostly trivial: change the definitions in gfxFontConstants.h, and switch font-stretch fields/variables from signed to unsigned now that they're always non-negative. The only other thing is a minor update to the font-matching code where it's computing "distance" between styles based on the constants. Tryserver says this doesn't break anything (at least not anything too obvious):
Attachment #8966586 - Flags: review?(jwatt)
Assignee: nobody → jfkthame
Rebased this on top of the part-1 patch from bug 1436048.
Attachment #8967858 - Flags: review?(jwatt)
Attachment #8966586 - Attachment is obsolete: true
Attachment #8966586 - Flags: review?(jwatt)
Comment on attachment 8967858 [details] [diff] [review]
Update NS_FONT_STRETCH_* constants to values based on the percentage definitions in css fonts 4

Review of attachment 8967858 [details] [diff] [review]:

::: gfx/thebes/gfxDWriteCommon.h
@@ +20,5 @@
>  #include <windows.h>
>  #include <dwrite.h>
>  static inline DWRITE_FONT_STRETCH
> +DWriteFontStretchFromStretch(uint16_t aStretch) 

Might as well get rid of the trailing white space while you're here.
Attachment #8967858 - Flags: review?(jwatt) → review+
Pushed by
Update NS_FONT_STRETCH_* constants to values based on the percentage definitions in css fonts 4. r=jwatt
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in before you can comment on or make changes to this bug.