-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: font variation settings (wip) #36371
Conversation
Base commit: cfa03db |
Your comments are welcome regarding the implementation! @NickGerleman @cortinico |
bb4dee0
to
50d0f73
Compare
50d0f73
to
38692ac
Compare
Any luck on pushing this @matinzd ? |
@matinzd hey! is this pr close to ready for review? |
Also interested on this. Any way I can help make some progress here @matinzd? |
I was away for some time from the community. I will try to see if I can continue. There has been a lot of conflicts since then :) I may need to open a new PR. |
@matinzd if you need any help I can give a hand on this task |
@davebcn87 Sure! I am up for it. Try to see if you have push access on my branch. We can work on it together. My username is the same on Discord if you want to continue the conversation further. |
awesome, let's chat on Discord then. Maybe it be nice we start a nice branch as you mentioned so we avoid all the conflicts. |
Got some progress on iOS side, all the variations that I tried and that the variable font supports work for now: <Text style={{fontFamily: 'Inter', fontVariationSettings: '"wght" 100'}}>Inter wght 100</Text>
<Text style={{fontFamily: 'Inter', fontVariationSettings: '"wght" 150'}}>Inter wght 150</Text>
...
<Text style={{fontFamily: 'Inter', fontVariationSettings: '"wght" 750'}}>Inter wght 750</Text>
<Text style={{fontFamily: 'Inter', fontVariationSettings: '"wght" 800'}}>Inter wght 800</Text>
<Text style={{fontFamily: 'Inter', fontVariationSettings: "'wght' 700"}}>Inter wght 1000</Text>
<Text style={{fontFamily: 'Inter', fontVariant: ['tabular-nums'], fontVariationSettings: "'wght' 700"}}>Inter wght 1000 w/ tabular-nums</Text>
<Text style={{fontFamily: 'Amstelvar', fontVariationSettings: "'wght' 700, 'wdth' 60"}}>Amstelvar wght 700 wdth 60</Text>
<Text style={{fontFamily: 'Amstelvar', fontVariationSettings: "'wght' 700, 'wdth' 120"}}>Amstelvar wght 700 wdth 120</Text>
<Text style={{fontFamily: 'Amstelvar', fontVariationSettings: "'wght' 700, 'opsz' 12"}}>Amstelvar wght 700 opsz 12</Text>
<Text style={{fontFamily: 'Amstelvar', fontVariationSettings: "'wght' 700, 'opsz' 32"}}>Amstelvar wght 700 opsz 32</Text> |
Follow here for the updated PR: #44667 |
Summary
This PR adds font variation settings feature for variable fonts in react native. The
fontVariationSettings
property provides low-level control over variable font characteristics, by specifying the four letter axis names of the characteristics you want to vary, along with their values.Registered axes are the most commonly encountered — common enough that the authors of the specification felt they were worth standardizing. Note that this doesn't mean that the author has to include all of these in their font.
Custom axes can be anything the font designer wants to vary in their font, for example ascender or descender heights, the size of serifs, or anything else they can imagine. Any axis can be used as long as it is given a unique 4-character axis. Some will end up becoming more common, and may even become registered over time.
Example:
Font characteristics set using
fontVariationSettings
will always override those set using the corresponding basic font properties, e.g.fontWeight
regardless of the order.Android reference: https://developer.android.com/reference/android/graphics/fonts/FontVariationAxis
iOS reference: https://developer.apple.com/documentation/coretext/kctfontvariationattribute
MDN reference: https://developer.mozilla.org/en-US/docs/Web/CSS/font-variation-settings
Spec: https://learn.microsoft.com/en-us/typography/opentype/spec/otvaroverview
Changelog
[General] [Added] - add fontVariationSettings support for variable font
Test Plan
TBD