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

[iOS][font] Fix some vector icons using incorrect fonts #28747

Merged
merged 3 commits into from
May 10, 2024

Conversation

tsapeta
Copy link
Member

@tsapeta tsapeta commented May 10, 2024

Why

Fixes #28693

How

When the swizzled UIFont.fontNames(forFamilyName:) function cannot find any font names for the aliased font family, we can assume it was not a family name but a font name in which case we can return an array with this font name instead of an empty array. Thanks to this, the font resolution in RN will not enter this if: https://github.com/facebook/react-native/blob/00b251b8ee8752b82a536faabc424d92f7034ebe/packages/react-native/React/Views/RCTFont.mm#L448 but will enter this one: https://github.com/facebook/react-native/blob/00b251b8ee8752b82a536faabc424d92f7034ebe/packages/react-native/React/Views/RCTFont.mm#L471 which is the expected behavior as it would bypass the unwanted logic.
In other words, this change shifts the responsibility of handling font names passed as family names to us.

I also reverted #28407 which is no longer necessary and added some FontAwesome icons to our expo-font examples in native-component-list app.

Test Plan

Tested repros from #28693, #28407 and the new examples on both old and new architectures

Simulator Screenshot - iPhone 15 Pro Max - 2024-05-10 at 15 40 19

Also thanks for @alanjhughes for helping me investigate this issue and test various cases and fonts.

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label May 10, 2024
@expo-bot
Copy link
Collaborator

expo-bot commented May 10, 2024

The Pull Request introduced fingerprint changes against the base commit: 060e01d

Fingerprint diff
[
  {
    "type": "dir",
    "filePath": "../../packages/expo-font/ios",
    "reasons": [
      "expoAutolinkingIos"
    ],
    "hash": "f7dcef06a123de8ecd437c49239163de9a43e71d"
  }
]

Generated by PR labeler 🤖

@tsapeta tsapeta force-pushed the @tsapeta/ios/fix-vector-icons branch from 6183020 to d0edb10 Compare May 10, 2024 12:46
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels May 10, 2024
@tsapeta tsapeta marked this pull request as ready for review May 10, 2024 14:06
<Ionicons name="logo-google" size={25} />
<Ionicons name="alarm" size={25} />
</View>

<View style={{ paddingVertical: 10, paddingHorizontal: 15, flex: 1 }}>
<Text style={{ fontFamily: 'space-mono', fontSize: 16 }}>
Copy link
Member

Choose a reason for hiding this comment

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

we might want to also add a font that we name something totally unrelated like "A-Custom-Font-Name" to verify that we don't regress in that functionality

@tsapeta tsapeta merged commit f508079 into main May 10, 2024
12 checks passed
@tsapeta tsapeta deleted the @tsapeta/ios/fix-vector-icons branch May 10, 2024 17:09
@tsapeta tsapeta added the published Changes from the PR have been published to npm label May 10, 2024
@Chayma-Soussi
Copy link

hey please i have the same problem when i update sdk 51 this is my package.json {
"name": "lincare-app",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"email": "email dev"
},
"dependencies": {
"@expo/vector-icons": "^14.0.2",
"@react-email/components": "0.0.17",
"@react-native-async-storage/async-storage": "^1.23.1",
"@react-native-community/blur": "^4.4.0",
"@react-navigation/bottom-tabs": "^6.5.20",
"@react-navigation/native": "^6.1.16",
"@react-navigation/native-stack": "^6.9.26",
"@react-navigation/stack": "^6.3.28",
"@types/moment": "^2.13.0",
"@types/react": "~18.2.45",
"axios": "^1.6.8",
"expo": "~51.0.2",
"expo-auth-session": "~5.5.2",
"expo-constants": "~16.0.1",
"expo-crypto": "~13.0.2",
"expo-dev-client": "~4.0.11",
"expo-font": "~12.0.4",
"expo-image-picker": "~15.0.4",
"expo-linear-gradient": "~13.0.2",
"expo-mail-composer": "~13.0.1",
"expo-notifications": "~0.28.1",
"expo-random": "~14.0.1",
"expo-status-bar": "~1.12.1",
"expo-updates": "~0.25.9",
"expo-web-browser": "~13.0.3",
"formik": "^2.4.5",
"moment": "^2.30.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-email": "2.1.2",
"react-native": "^0.73.0",
"react-native-animatable": "^1.4.0",
"react-native-calendars": "^1.1304.1",
"react-native-gesture-handler": "~2.16.1",
"react-native-modal-datetime-picker": "^17.1.0",
"react-native-reanimated": "3.10.0",
"react-native-safe-area-context": "4.10.1",
"react-native-screens": "3.31.1",
"react-native-snap-carousel": "^3.9.1",
"react-native-svg": "15.2.0-rc.0",
"react-native-vector-icons": "^10.1.0",
"react-native-web": "~0.19.6",
"styled-components": "^6.1.8",
"typescript": "~5.3.3",
"undefined": "@react-native-async-storage/async-storage/async-storage",
"victory-native": "^40.1.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.2.45",
"@types/react-native": "^0.73.0"
},
"private": true
}

@Chayma-Soussi
Copy link

in android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint changed bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ios] FontAwesome5 does not import properly with SDK 51
5 participants