expo-font 12.0.2 → 12.0.3
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
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'host.exp.exponent'
|
|
4
|
-
version = '12.0.
|
|
4
|
+
version = '12.0.3'
|
|
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.
|
|
17
|
+
versionName "12.0.3"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -39,21 +39,35 @@ internal struct FontFamilyAliasManager {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
Swizzles ``UIFont.fontNames(forFamilyName:)`` to support font family aliases.
|
|
42
|
+
Swizzles ``UIFont.fontNames(forFamilyName:)`` and ``UIFont(name:size:)`` 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.
|
|
45
51
|
*/
|
|
46
52
|
private func maybeSwizzleUIFont() {
|
|
47
53
|
if hasSwizzled {
|
|
48
54
|
return
|
|
49
55
|
}
|
|
50
|
-
let
|
|
51
|
-
let
|
|
56
|
+
let originalFontNamesMethod = class_getClassMethod(UIFont.self, #selector(UIFont.fontNames(forFamilyName:)))
|
|
57
|
+
let newFontNamesMethod = class_getClassMethod(UIFont.self, #selector(UIFont._expo_fontNames(forFamilyName:)))
|
|
52
58
|
|
|
53
|
-
if let
|
|
54
|
-
method_exchangeImplementations(
|
|
59
|
+
if let originalFontNamesMethod, let newFontNamesMethod {
|
|
60
|
+
method_exchangeImplementations(originalFontNamesMethod, newFontNamesMethod)
|
|
55
61
|
} else {
|
|
56
62
|
log.error("expo-font is unable to swizzle `UIFont.fontNames(forFamilyName:)`")
|
|
57
63
|
}
|
|
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
|
+
}
|
|
58
72
|
hasSwizzled = true
|
|
59
73
|
}
|
|
@@ -15,4 +15,13 @@ public extension UIFont {
|
|
|
15
15
|
}
|
|
16
16
|
return fontNames
|
|
17
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)
|
|
21
|
+
|
|
22
|
+
if let aliasedFamilyName = FontFamilyAliasManager.familyName(forAlias: fontName) {
|
|
23
|
+
return UIFont._expo_init(name: aliasedFamilyName, size: fontSize)
|
|
24
|
+
}
|
|
25
|
+
return font
|
|
26
|
+
}
|
|
18
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-font",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.3",
|
|
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": "
|
|
45
|
+
"gitHead": "f8f9d041c6467f325b58c7913e0f5ed1af102e11"
|
|
46
46
|
}
|