Skip to content

Support font-variant-ligatures values - #36740

Closed
finnp wants to merge 2 commits into
react:mainfrom
finnp:font-variant-ligatures
Closed

Support font-variant-ligatures values#36740
finnp wants to merge 2 commits into
react:mainfrom
finnp:font-variant-ligatures

Conversation

@finnp

@finnpfinnp commented Mar 31, 2023

Copy link
Copy Markdown
Contributor

Summary

The text style prop fontVariant in React Native is supposed to map to the CSS font-variant property. The CSS property is a short-hand for the following CSS properties:

Currently React Native only supports a subset of the values from font-variant-numeric and font-variant-caps.

This change increases the font-variant support by adding all values from font-variant-ligatures.

Changelog:

[iOS] [Added] - Add all fontVariant values for font-variant-ligatures
[Android] [Added] - Add all fontVariant values for font-variant-ligatures

Test Plan:

See #36740 (comment)

Resources

@facebook-github-bot

Copy link
Copy Markdown
Contributor

Hi @finnp!

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@meta.com. Thanks!

@finnp

Copy link
Copy Markdown
ContributorAuthor

This change is related to increasing compability with web, linking #34425

@react-native-botreact-native-bot added Platform: iOS iOS applications. Type: Enhancement A new feature or enhancement of an existing feature. labels Mar 31, 2023
@facebook-github-bot

Copy link
Copy Markdown
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-botfacebook-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 Mar 31, 2023
@cortinico
cortinico requested a review from necolasMarch 31, 2023 14:07
@finnp

Copy link
Copy Markdown
ContributorAuthor

Here's a table of all the values:

NameAndroid TextView settingiOS Feature TypeiOS Feature Selector
common-ligatures'liga', 'clig'kLigaturesTypekCommonLigaturesOnSelector
no-common-ligatures'liga' off, 'clig' offkLigaturesTypekCommonLigaturesOffSelector
discretionary-ligatures'dlig'kLigaturesTypekRareLigaturesOnSelector
no-discretionary-ligatures'dlig' offkLigaturesTypekRareLigaturesOffSelector
historical-ligatures'hlig'kLigaturesTypekHistoricalLigaturesOnSelector
no-historical-ligatures'hlig' offkLigaturesTypekHistoricalLigaturesOffSelector
contextual'calt'kContextualAlternatesTypekContextualAlternatesOnSelector
no-contextual'calt off'kContextualAlternatesTypekContextualAlternatesOffSelector

@finnp
finnpforce-pushed the font-variant-ligatures branch from 1282a5b to 9a121c0CompareMarch 31, 2023 14:25
@finnp
finnp marked this pull request as ready for review March 31, 2023 14:26
@finnp
finnpforce-pushed the font-variant-ligatures branch from 9a121c0 to d8a7dbbCompareMarch 31, 2023 14:31

@necolasnecolas left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stamping

@finnp

finnp commented Mar 31, 2023

Copy link
Copy Markdown
ContributorAuthor

Test Plan

I started testing iOS with a test project with the following code: https://github.com/finnp/react-native-font-test/blob/main/A

The results looks like this:

To find proper fonts to test I searched Github and also used https://otf.show/onum.

The same test on Android looks like this

Both screenshot look as expected ✅

@finnp

finnp commented Apr 3, 2023

Copy link
Copy Markdown
ContributorAuthor

@cortinico@necolas Is anything else needed here to get this merged?

@cortinico

Copy link
Copy Markdown
Contributor

@cortinico@necolas Is anything else needed here to get this merged?

Yes we need CircleCI tests to be green before we can import this. Can I ask you to logoff/login to your CircleCI as your token got revoked. You can do so from this UI: https://app.circleci.com/pipelines/github/facebook/react-native/21404

@analysis-bot

analysis-bot commented Apr 3, 2023

Copy link
Copy Markdown
PlatformEngineArchSize (bytes)Diff
androidhermesarm64-v8a8,586,914-4,681
androidhermesarmeabi-v7a7,901,311-4,395
androidhermesx869,069,452-4,627
androidhermesx86_648,926,266-4,908
androidjscarm64-v8a9,174,285+1,537
androidjscarmeabi-v7a8,364,703+1,050
androidjscx869,231,816+1,693
androidjscx86_649,489,208+1,058

Base commit: 58ee6b2
Branch: main

@finnp
finnpforce-pushed the font-variant-ligatures branch from bfe9f9f to 554e14bCompareApril 4, 2023 20:36
finnp added 2 commits April 4, 2023 23:57
The text style prop `fontVariant` in React Native is supposed to map
to the CSS `font-variant` property. The CSS property is a short-hand
for the following CSS properties:
- `[font-variant-alternates](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-alternates)`
- `[font-variant-caps](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-caps)`
- `[font-variant-east-asian](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-east-asian)`
- `[font-variant-emoji](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-emoji)`
- `[font-variant-ligatures](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-ligatures)`
- `[font-variant-numeric](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-numeric)`
- `[font-variant-position](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-position)`
Currently React Native only supports a subset of the values from
`font-variant-numeric` and `font-variant-caps`.
This change increase the `font-variant` support by adding all values
from `font-variant-ligatures`.
- [Apple True Type Reference](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html)
- [Webkit Source Code](https://opensource.apple.com/source/WebCore/WebCore-7602.1.50.1.1/platform/graphics/cocoa/FontCacheCoreText.cpp)
- [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-ligatures)
- [Android TextView Documentation](https://developer.android.com/reference/android/widget/TextView#setFontFeatureSettings(java.lang.String))
@finnp
finnpforce-pushed the font-variant-ligatures branch from 554e14b to d9fa362CompareApril 4, 2023 21:57
@facebook-github-bot

Copy link
Copy Markdown
Contributor

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

@facebook-github-botfacebook-github-bot added the Merged This PR has been merged. label Apr 5, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@cortinico merged this pull request in f0893cf.

@finnp
finnp deleted the font-variant-ligatures branch April 5, 2023 23:25
@pkepke mentioned this pull request May 4, 2023
@professorkolik

Copy link
Copy Markdown

When this can be released?

@cortinico

Copy link
Copy Markdown
Contributor

When this can be released?

This will land in 0.73

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.MergedThis PR has been merged.Platform: iOSiOS applications.Type: EnhancementA new feature or enhancement of an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@finnp@facebook-github-bot@cortinico@analysis-bot@professorkolik@necolas@react-native-bot