-
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-feature): adding stylistics from ss01 to ss20 as new fontVariant values #34003
Conversation
Hi @thuongtv-vn! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Base commit: 97291bf |
Base commit: 97291bf |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
@kacieb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
case "stylistic-three": | ||
features.add("'ss03'"); | ||
break; | ||
case "stylistic-five": | ||
features.add("'ss05'"); | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we adding only ss03 and ss05 here? What's your use case?
https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#ssxx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cortinico
Thank for your question. Because fontVariant now only have some regular setting features. In my case i would like to alternative 'a', 'g', '1' characters. It would be good if we can add all the font features. I am thinking about how dynamic it is. Do you have any advice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO either we include all of them, or we include none.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cortinico
Thank you for your suggestion. I updated my pull request with fully added 20 font stylistics.
527f4c3
to
2284daa
Compare
2284daa
to
a3b25c0
Compare
Could you rebase as the CI should be green now? |
a3b25c0
to
0df0a05
Compare
Hi @cortinico |
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This pull request was successfully merged by Thuong Tran in 163636d. When will my fix make it into a release? | Upcoming Releases |
…riant values (facebook#34003) Summary: Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20) stylistic-three(ss01) stylistic-two(ss02) stylistic-three(ss03) stylistic-four(ss04) stylistic-five(ss05) stylistic-six(ss06) stylistic-seven(ss07) stylistic-eight(ss08) stylistic-nine(ss09) stylistic-ten(ss10) stylistic-eleven(ss11) stylistic-twelve(ss12) stylistic-thirteen(ss13) stylistic-fourteen(ss14) stylistic-fifteen(ss15) stylistic-sixteen(ss16) stylistic-seventeen(ss17) stylistic-eighteen(ss18) stylistic-nineteen(ss19) stylistic-twenty(ss20) References: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type3 https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist Example: `<Text style={{ fontVariant: ['stylistic-three', 'stylistic-five'] }}> Hello World! </Text>` ## Changelog [iOS] [Added] - Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20) [Android] [Added] - Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20) Pull Request resolved: facebook#34003 Test Plan: ![Screen Shot 2022-06-13 at 16 02 46](https://user-images.githubusercontent.com/62107729/173318839-69da379c-df13-4351-9dfa-4b548664e43d.png) Reviewed By: cipolleschi Differential Revision: D37118078 Pulled By: cortinico fbshipit-source-id: 6a8366638f8181b5db6b2c12c48a5ad65e1e598f
…riant values (facebook#34003) Summary: Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20) stylistic-three(ss01) stylistic-two(ss02) stylistic-three(ss03) stylistic-four(ss04) stylistic-five(ss05) stylistic-six(ss06) stylistic-seven(ss07) stylistic-eight(ss08) stylistic-nine(ss09) stylistic-ten(ss10) stylistic-eleven(ss11) stylistic-twelve(ss12) stylistic-thirteen(ss13) stylistic-fourteen(ss14) stylistic-fifteen(ss15) stylistic-sixteen(ss16) stylistic-seventeen(ss17) stylistic-eighteen(ss18) stylistic-nineteen(ss19) stylistic-twenty(ss20) References: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type3 https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist Example: `<Text style={{ fontVariant: ['stylistic-three', 'stylistic-five'] }}> Hello World! </Text>` ## Changelog [iOS] [Added] - Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20) [Android] [Added] - Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20) Pull Request resolved: facebook#34003 Test Plan: ![Screen Shot 2022-06-13 at 16 02 46](https://user-images.githubusercontent.com/62107729/173318839-69da379c-df13-4351-9dfa-4b548664e43d.png) Reviewed By: cipolleschi Differential Revision: D37118078 Pulled By: cortinico fbshipit-source-id: 6a8366638f8181b5db6b2c12c48a5ad65e1e598f
PR For Docs Here. Thank you for the awesome work @thuongtv-vn |
Thanks a ton for adding this finally to RN @thuongtv-vn! One question though: was this tested on Android? I patched my 0.66.3 RN version with this PR and the Text component is now complaining about an invalid prop and not applying the correct variant:
Is there something to be done to make RN pick up on the patched JS files? Solvededit: Yes, it seems this would require to compile RN from source for Android (iOS works with just the patch). The property warning was fixed when I correctly patched the DeprecatedTextStyleProps file. |
First version to contain this is 0.71-rc.0 correct? |
@thuongtv-vn any reasons why we not just hand over the OTF variant values like this |
@pke the reason for stylistic values that it is following the current code style as you can see below on iOS and Android: |
I reckon that and I believe it was a bad choice whoever made it. I'd vote for changing all the current mapped values to the official keys and deprecating react natives ones. This would not only improve the DX but also reduce tedious documentation work and dramatically simplify the amount of code required to implement this (no more switch cases and mappings, joins etc) What do you all think? |
Yeah it would be nice if it would just follow the spec: https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant I just patched my react-native locally to add For these ss01 type features I believe a new propertly like |
Is there anyone with authority here that could assess if it would make sense to create a PR harmonising this? @cortinico |
It's probably something to raise in this thread |
Yes I'm in favour of all the W3C props conforming to standards for the reasons mentioned above. It's difficult if we merge changes without clear guidance that we need these APIs not to diverge from the standards. Commenting on this RFC will help me document what is needed going forward react-native-community/discussions-and-proposals#496 |
Summary
Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20)
stylistic-three(ss01)
stylistic-two(ss02)
stylistic-three(ss03)
stylistic-four(ss04)
stylistic-five(ss05)
stylistic-six(ss06)
stylistic-seven(ss07)
stylistic-eight(ss08)
stylistic-nine(ss09)
stylistic-ten(ss10)
stylistic-eleven(ss11)
stylistic-twelve(ss12)
stylistic-thirteen(ss13)
stylistic-fourteen(ss14)
stylistic-fifteen(ss15)
stylistic-sixteen(ss16)
stylistic-seventeen(ss17)
stylistic-eighteen(ss18)
stylistic-nineteen(ss19)
stylistic-twenty(ss20)
References:
https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type3
https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist
Example:
<Text style={{ fontVariant: ['stylistic-three', 'stylistic-five'] }}> Hello World! </Text>
Changelog
[iOS] [Added] - Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20)
[Android] [Added] - Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20)
Test Plan