expo-font 12.0.5 → 12.0.7

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,6 +10,18 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 12.0.7 — 2024-06-06
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - On `iOS`, store the font `postscriptName` instead of `fullName` which is what `iOS` will use to register the font. ([#29502](https://github.com/expo/expo/pull/29502) by [@alanjhughes](https://github.com/alanjhughes))
18
+
19
+ ## 12.0.6 — 2024-05-29
20
+
21
+ ### 🐛 Bug fixes
22
+
23
+ - [iOS] Fix font registration failing when font was in use. ([#28989](https://github.com/expo/expo/pull/28989) by [@aleqsio](https://github.com/aleqsio))
24
+
13
25
  ## 12.0.5 — 2024-05-10
14
26
 
15
27
  ### 🐛 Bug fixes
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'host.exp.exponent'
4
- version = '12.0.5'
4
+ version = '12.0.7'
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.5"
17
+ versionName "12.0.7"
18
18
  }
19
19
  }
@@ -12,7 +12,9 @@ public final class FontLoaderModule: Module {
12
12
  // If the font was already registered, unregister it first. Otherwise CTFontManagerRegisterGraphicsFont
13
13
  // would fail because of a duplicated font name when the app reloads or someone wants to override a font.
14
14
  if let familyName = FontFamilyAliasManager.familyName(forAlias: fontFamilyAlias) {
15
- try unregisterFont(named: familyName)
15
+ guard try unregisterFont(named: familyName) else {
16
+ return
17
+ }
16
18
  }
17
19
 
18
20
  // Create a font object from the given file
@@ -23,8 +25,8 @@ public final class FontLoaderModule: Module {
23
25
 
24
26
  // The real font name might be different than it's been requested by the user,
25
27
  // so we save the provided name as an alias.
26
- if let fullName = font.fullName as? String {
27
- FontFamilyAliasManager.setAlias(fontFamilyAlias, forFamilyName: fullName)
28
+ if let postScriptName = font.postScriptName as? String {
29
+ FontFamilyAliasManager.setAlias(fontFamilyAlias, forFamilyName: postScriptName)
28
30
  }
29
31
  }
30
32
  }
@@ -66,20 +66,33 @@ internal func registerFont(_ font: CGFont) throws {
66
66
 
67
67
  /**
68
68
  Unregisters the given font, so the app will no longer be able to render it.
69
+ Returns a boolean indicating if the font is successfully unregistered after this function completes.
69
70
  */
70
- internal func unregisterFont(_ font: CGFont) throws {
71
+ internal func unregisterFont(_ font: CGFont) throws -> Bool {
71
72
  var error: Unmanaged<CFError>?
72
73
 
73
74
  if !CTFontManagerUnregisterGraphicsFont(font, &error), let error = error?.takeRetainedValue() {
74
- throw FontRegistrationFailedException(error)
75
+ if let ctFontManagerError = CTFontManagerError(rawValue: CFErrorGetCode(error as CFError)) {
76
+ switch ctFontManagerError {
77
+ case .systemRequired, .inUse:
78
+ return false
79
+ case .notRegistered:
80
+ return true
81
+ default:
82
+ throw FontRegistrationFailedException(error)
83
+ }
84
+ }
75
85
  }
86
+ return true
76
87
  }
77
88
 
78
89
  /**
79
90
  Unregisters a font with the given name, so the app will no longer be able to render it.
91
+ Returns a boolean indicating if the font is successfully unregistered after this function completes.
80
92
  */
81
- internal func unregisterFont(named fontName: String) throws {
93
+ internal func unregisterFont(named fontName: String) throws -> Bool {
82
94
  if let font = CGFont(fontName as CFString) {
83
- try unregisterFont(font)
95
+ return try unregisterFont(font)
84
96
  }
97
+ return true
85
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-font",
3
- "version": "12.0.5",
3
+ "version": "12.0.7",
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": "e4b8d86442482c7316365a6b7ec1141eec73409d"
45
+ "gitHead": "f424c7ea50d8787fa8d3354a33fe402160b63032"
46
46
  }