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: Add space-separated string support for fontVariant #34641

Conversation

gabrieldonadel
Copy link
Collaborator

Summary

This updates fontVariant to support space-separated string values, i.e., 'small-caps common-ligatures', thus aligning it with the CSS Fonts Module Level 4 specification as requested on #34425. This also adds unit tests to the processFontVariant function ensuring the style processing works as expected.

Changelog

[General] [Added] - Add space-separated string support for fontVariant

Test Plan

This can be tested either through processFontVariant-tests or by using the following code:

 <Text
   style={{ 
     fontVariant: 'small-caps common-ligatures',
  }} />

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Sep 9, 2022
@react-native-bot react-native-bot added the Type: Enhancement A new feature or enhancement of an existing feature. label Sep 9, 2022
@analysis-bot
Copy link

analysis-bot commented Sep 9, 2022

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,642,346 -39,267
android hermes armeabi-v7a 7,054,430 -31,943
android hermes x86 7,943,926 -40,744
android hermes x86_64 7,915,954 -41,622
android jsc arm64-v8a 9,514,689 -38,652
android jsc armeabi-v7a 8,290,301 -31,306
android jsc x86 9,454,026 -40,121
android jsc x86_64 10,045,097 -40,987

Base commit: bfb36c2
Branch: main

@analysis-bot
Copy link

analysis-bot commented Sep 9, 2022

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

Base commit: bfb36c2
Branch: main

@facebook-github-bot
Copy link
Contributor

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


// $FlowFixMe[incompatible-type]
const match: ?____FontVariantArray_Internal = fontVariant.match(
new RegExp(/([a-zA-Z'-]+)/gm),
Copy link
Contributor

Choose a reason for hiding this comment

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

Quoting @javache:

Can we avoid regular expressions here since it's just a string split by space? This also seems like it would cause the regex to be re-compiled on every process call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, let me update this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FIxed @cipolleschi

@facebook-github-bot
Copy link
Contributor

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

@gabrieldonadel gabrieldonadel deleted the feat/font-variant-string-support branch September 14, 2022 12:13
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @gabrieldonadel in 09d4207.

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 Sep 14, 2022
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
)

Summary:
This updates `fontVariant` to support space-separated string values, i.e., `'small-caps common-ligatures'`, thus aligning it with the [CSS Fonts Module Level 4](https://drafts.csswg.org/css-fonts/#font-variant-prop) specification as requested on facebook#34425. This also adds unit tests to the `processFontVariant` function ensuring the style processing works as expected.

## Changelog

[General] [Added] - Add space-separated string support for fontVariant

Pull Request resolved: facebook#34641

Test Plan:
This can be tested either through `processFontVariant-tests` or by using the following code:

```js
 <Text
   style={{
     fontVariant: 'small-caps common-ligatures',
  }} />
```

Reviewed By: javache

Differential Revision: D39423317

Pulled By: cipolleschi

fbshipit-source-id: ad971addb423ed338e178528a11fe9d456c03e6e
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. 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.

5 participants