expo-font 12.0.3 → 12.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,10 +10,20 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 12.0.3 — 2024-04-24
13
+ ## 12.0.5 — 2024-05-10
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fixed some vector icons not rendering correctly. ([#28747](https://github.com/expo/expo/pull/28747) by [@tsapeta](https://github.com/tsapeta))
18
+
19
+ ## 12.0.4 — 2024-04-24
14
20
 
15
21
  _This version does not introduce any user-facing changes._
16
22
 
23
+ ## 12.0.3 — 2024-04-24
24
+
25
+ - Fix font name lookup when name is not the same as family. ([#28407](https://github.com/expo/expo/pull/28407) by [@brentvatne](https://github.com/brentvatne))
26
+
17
27
  ## 12.0.2 — 2024-04-23
18
28
 
19
29
  _This version does not introduce any user-facing changes._
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'host.exp.exponent'
4
- version = '12.0.3'
4
+ version = '12.0.5'
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  apply from: expoModulesCorePlugin
@@ -14,6 +14,6 @@ android {
14
14
  namespace "expo.modules.font"
15
15
  defaultConfig {
16
16
  versionCode 29
17
- versionName "12.0.3"
17
+ versionName "12.0.5"
18
18
  }
19
19
  }
@@ -39,15 +39,9 @@ internal struct FontFamilyAliasManager {
39
39
  }
40
40
 
41
41
  /**
42
- Swizzles ``UIFont.fontNames(forFamilyName:)`` and ``UIFont(name:size:)`` to support font family aliases.
42
+ Swizzles ``UIFont.fontNames(forFamilyName:)`` to support font family aliases.
43
43
  This is necessary because the user provides a custom family name that is then used in stylesheets,
44
44
  however the font usually has a different name encoded in the binary, thus the system may use a different name.
45
-
46
- ``UIFont(name:size:)`` covers cases where there the font family has variants. For example, the ``CGFont fullName``
47
- value for "Helvetica-Light-Oblique.ttf" would be something like "Helvetica Light Oblique", which
48
- ``UIFont.fullNames`` won't recognize, because that is a font name rather than a font family name. We have to use
49
- ``UIFont(name:size:)`` instead, because it accepts a font name. React Native does this looking up / falling back
50
- for us, we just need to ensure both methods are swizzled so they both support aliasing.
51
45
  */
52
46
  private func maybeSwizzleUIFont() {
53
47
  if hasSwizzled {
@@ -61,13 +55,5 @@ private func maybeSwizzleUIFont() {
61
55
  } else {
62
56
  log.error("expo-font is unable to swizzle `UIFont.fontNames(forFamilyName:)`")
63
57
  }
64
- let originalInitMethod = class_getClassMethod(UIFont.self, #selector(UIFont.init(name:size:)))
65
- let newInitMethod = class_getClassMethod(UIFont.self, #selector(UIFont._expo_init(name:size:)))
66
-
67
- if let originalInitMethod, let newInitMethod {
68
- method_exchangeImplementations(originalInitMethod, newInitMethod)
69
- } else {
70
- log.error("expo-font is unable to swizzle `UIFont.init(name:size:)`")
71
- }
72
58
  hasSwizzled = true
73
59
  }
@@ -7,21 +7,20 @@ public extension UIFont {
7
7
  */
8
8
  @objc
9
9
  static dynamic func _expo_fontNames(forFamilyName familyName: String) -> [String] {
10
+ // Get font names from the original function.
10
11
  let fontNames = UIFont._expo_fontNames(forFamilyName: familyName)
11
12
 
13
+ // If no font names were found, let's try with the alias.
12
14
  if fontNames.isEmpty, let aliasedFamilyName = FontFamilyAliasManager.familyName(forAlias: familyName) {
13
- // Note that this actually calls the original method implementation (if swizzled).
14
- return UIFont._expo_fontNames(forFamilyName: aliasedFamilyName)
15
- }
16
- return fontNames
17
- }
18
- @objc
19
- static dynamic func _expo_init(name fontName: String, size fontSize: CGFloat) -> UIFont? {
20
- let font = UIFont._expo_init(name: fontName, size: fontSize)
15
+ let fontNames = UIFont._expo_fontNames(forFamilyName: aliasedFamilyName)
21
16
 
22
- if let aliasedFamilyName = FontFamilyAliasManager.familyName(forAlias: fontName) {
23
- return UIFont._expo_init(name: aliasedFamilyName, size: fontSize)
17
+ // If we still don't find any font names, we can assume it was not a family name but a font name.
18
+ // In that case we can safely return the original font name.
19
+ if fontNames.isEmpty {
20
+ return [aliasedFamilyName]
21
+ }
22
+ return fontNames
24
23
  }
25
- return font
24
+ return fontNames
26
25
  }
27
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-font",
3
- "version": "12.0.3",
3
+ "version": "12.0.5",
4
4
  "description": "Load fonts at runtime and use them in React Native components.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -42,5 +42,5 @@
42
42
  "peerDependencies": {
43
43
  "expo": "*"
44
44
  },
45
- "gitHead": "f8f9d041c6467f325b58c7913e0f5ed1af102e11"
45
+ "gitHead": "e4b8d86442482c7316365a6b7ec1141eec73409d"
46
46
  }