Skip to content
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

Closed

Conversation

thuongtv-vn
Copy link

@thuongtv-vn thuongtv-vn commented Jun 13, 2022

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

Screen Shot 2022-06-13 at 16 02 46

@facebook-github-bot
Copy link
Contributor

Hi @thuongtv-vn!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@react-native-bot react-native-bot added Platform: iOS iOS applications. Type: Enhancement A new feature or enhancement of an existing feature. labels Jun 13, 2022
@analysis-bot
Copy link

analysis-bot commented Jun 13, 2022

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 97291bf
Branch: main

@analysis-bot
Copy link

analysis-bot commented Jun 13, 2022

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,825,846 +1,524
android hermes armeabi-v7a 7,213,153 +1,527
android hermes x86 8,136,369 +1,528
android hermes x86_64 8,116,924 +1,525
android jsc arm64-v8a 9,692,435 +1,810
android jsc armeabi-v7a 8,448,662 +1,828
android jsc x86 9,643,724 +1,808
android jsc x86_64 10,241,101 +1,830

Base commit: 97291bf
Branch: main

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 13, 2022
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 13, 2022
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot
Copy link
Contributor

@kacieb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment on lines 88 to 102
case "stylistic-three":
features.add("'ss03'");
break;
case "stylistic-five":
features.add("'ss05'");
break;
Copy link
Contributor

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

Copy link
Author

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?

Copy link
Contributor

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.

Copy link
Author

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.

@thuongtv-vn thuongtv-vn changed the title feat(font) adding stylistic ss03, ss05 as fontVariant value feat(font-feature) adding stylistic ss03, ss05 as fontVariant value Jun 14, 2022
@thuongtv-vn thuongtv-vn changed the title feat(font-feature) adding stylistic ss03, ss05 as fontVariant value feat(font-feature): adding stylistic ss03, ss05 as fontVariant value Jun 14, 2022
@thuongtv-vn thuongtv-vn changed the title feat(font-feature): adding stylistic ss03, ss05 as fontVariant value feat(font-feature): adding stylistic 'stylistic-three','stylistic-five' as new fontVariant value Jun 14, 2022
@thuongtv-vn thuongtv-vn changed the title feat(font-feature): adding stylistic 'stylistic-three','stylistic-five' as new fontVariant value feat(font-feature): adding stylistics from ss01 to ss20 as new fontVariant values Jun 21, 2022
@cortinico
Copy link
Contributor

Could you rebase as the CI should be green now?

@thuongtv-vn
Copy link
Author

Hi @cortinico
I had rebased my pull request. Do I need to update any further to get it merge?

@facebook-github-bot
Copy link
Contributor

@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by Thuong Tran in 163636d.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Aug 17, 2022
roryabraham pushed a commit to Expensify/react-native that referenced this pull request Aug 17, 2022
…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
roryabraham pushed a commit to Expensify/react-native that referenced this pull request Aug 17, 2022
…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
@gedeagas
Copy link
Contributor

PR For Docs Here.
facebook/react-native-website#3272

Thank you for the awesome work @thuongtv-vn

@pke
Copy link

pke commented Nov 4, 2022

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:

 Warning: Failed prop type: Invalid prop `fontVariant[0]` of value `stylistic-three` supplied to `Text`, expected one of ["small-caps","oldstyle-nums","lining-nums","tabular-nums","proportional-nums"].
Bad object: {
  "fontWeight": "700",
  "fontVariant": [
    "stylistic-three"
  ],

Is there something to be done to make RN pick up on the patched JS files?

Solved

edit: 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.

@pke
Copy link

pke commented Nov 4, 2022

First version to contain this is 0.71-rc.0 correct?

@pke
Copy link

pke commented Nov 7, 2022

@thuongtv-vn any reasons why we not just hand over the OTF variant values like this fontVariant: "ss01"?

@thuongtv-vn
Copy link
Author

@thuongtv-vn any reasons why we not just hand over the OTF variant values like this fontVariant: "ss01"?

@pke the reason for stylistic values that it is following the current code style as you can see below on iOS and Android:

Screenshot 2022-11-22 at 10 59 32

Screenshot 2022-11-22 at 10 59 07

@pke
Copy link

pke commented Nov 22, 2022

I reckon that and I believe it was a bad choice whoever made it.
Instead of using what Web devs already know and what is the official nomenclature for OTF the react native team decided to invent their own keys and force everyone to read up the docs to understand the mapping.

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?

@finnp
Copy link
Contributor

finnp commented Jan 6, 2023

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 no-contextual and no-commonl-ligatures

For these ss01 type features I believe a new propertly like fontFeatureSettings would have been more appropriate.

@pke
Copy link

pke commented Jan 24, 2023

Is there anyone with authority here that could assess if it would make sense to create a PR harmonising this? @cortinico

@cortinico
Copy link
Contributor

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

@necolas
Copy link
Contributor

necolas commented Jan 30, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: iOS iOS applications. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. Type: Enhancement A new feature or enhancement of an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants