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

Implemented font-variation-settings for iOS #44685

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davebcn87
Copy link

Summary:

This PR extends the support on React Native for variable fonts. This allow to customize any font setting: wght, slnt, wdth are common examples. A font designer can use any custom attribute, this is what we made this feature compatible with any property.

It follows the css standard font-variation-settings. This attribute is a string, formatted as a key value pairs separated by commas:

.boldText {
   font-variation-settings: "'whgt' 850";
}

Screenshots

Fabric Paper
Simulator Screenshot - iPhone 15 Pro - 2024-05-27 at 10 22 34 Simulator Screenshot - iPhone 15 Pro - 2024-05-27 at 10 36 58

The Android implementation of this feature is being implemented by another PR from @matinzd. We've been pairing on this solution to follow a similar implementation for both platforms.

Changelog:

[iOS] [ADDED] - Add fontVariationSettings support for variable fonts in iOS

Test Plan:

I've added examples in the rn-tester app using variable fonts. I've tested the following scenarios:

  • Common attributes: wght, wdth, slnt.
  • Custom attributes: FILL
  • Mixing font-variation-settings with other styles that affect font descriptors, like font-variant. See tabular-nums example.
  • It works in both architectures, Fabric and Paper (See screenshot).

This is an example of the final implementation usage code:

<Text style={{fontFamily: 'Inter', fontVariationSettings: '"wght" 800'}}>Inter wght 800</Text>

@facebook-github-bot
Copy link
Contributor

Hi @davebcn87!

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!

@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 May 27, 2024
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 19,542,634 +27
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 22,896,376 +15
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: a908387
Branch: main

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. p: Shopify Partner: Shopify Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants