diff --git a/.gitignore b/.gitignore index 66ac4e7d61..529a5cc272 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ DerivedData *.ipa *.xcuserstate project.xcworkspace +.xcode.env.local # Android/IntelliJ build/ diff --git a/example/android/app/src/main/assets/fonts/Roboto-Regular.ttf b/example/android/app/src/main/assets/fonts/Roboto-Regular.ttf new file mode 100644 index 0000000000..0e58508a64 Binary files /dev/null and b/example/android/app/src/main/assets/fonts/Roboto-Regular.ttf differ diff --git a/example/assets/fonts/Roboto-Regular.ttf b/example/assets/fonts/Roboto-Regular.ttf new file mode 100644 index 0000000000..0e58508a64 Binary files /dev/null and b/example/assets/fonts/Roboto-Regular.ttf differ diff --git a/example/ios/RNSkia.xcodeproj/project.pbxproj b/example/ios/RNSkia.xcodeproj/project.pbxproj index d5bdea268b..3b357a3a87 100644 --- a/example/ios/RNSkia.xcodeproj/project.pbxproj +++ b/example/ios/RNSkia.xcodeproj/project.pbxproj @@ -13,6 +13,8 @@ 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; + 5B0EA9D62C2F3EA400296D87 /* Roboto-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 5B0EA9D52C2F3EA400296D87 /* Roboto-Regular.ttf */; }; + 5B0EA9D72C2F3EA400296D87 /* Roboto-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 5B0EA9D52C2F3EA400296D87 /* Roboto-Regular.ttf */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; 920236303BDDC53C86EFF4D2 /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DC46369C0C317A156CF6C5 /* ExpoModulesProvider.swift */; }; D555C8696CC0DBC087E2CA02 /* libPods-RNSkia-RNSkiaTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CB0B997B3D2380C2BA6A654 /* libPods-RNSkia-RNSkiaTests.a */; }; @@ -44,6 +46,7 @@ 44AC55D436C4FEDA9C7B9C6A /* Pods-RNSkia.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNSkia.debug.xcconfig"; path = "Target Support Files/Pods-RNSkia/Pods-RNSkia.debug.xcconfig"; sourceTree = ""; }; 4CB0B997B3D2380C2BA6A654 /* libPods-RNSkia-RNSkiaTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNSkia-RNSkiaTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 557F8F02EA28C46329E9D8A3 /* Pods-RNSkia-RNSkiaTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNSkia-RNSkiaTests.release.xcconfig"; path = "Target Support Files/Pods-RNSkia-RNSkiaTests/Pods-RNSkia-RNSkiaTests.release.xcconfig"; sourceTree = ""; }; + 5B0EA9D52C2F3EA400296D87 /* Roboto-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "Roboto-Regular.ttf"; path = "../../assets/fonts/Roboto-Regular.ttf"; sourceTree = ""; }; 7F704FBA624C51E2729AB2E1 /* Pods-RNSkia.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNSkia.release.xcconfig"; path = "Target Support Files/Pods-RNSkia/Pods-RNSkia.release.xcconfig"; sourceTree = ""; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = RNSkia/LaunchScreen.storyboard; sourceTree = ""; }; DA3AEA9438F7550E6C6FA83B /* libPods-RNSkia.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNSkia.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -135,6 +138,14 @@ name = RNSkiaTests; sourceTree = ""; }; + 5B0EA9D12C2EFAFF00296D87 /* Resources */ = { + isa = PBXGroup; + children = ( + 5B0EA9D52C2F3EA400296D87 /* Roboto-Regular.ttf */, + ); + path = Resources; + sourceTree = ""; + }; 832341AE1AAA6A7D00B99B32 /* Libraries */ = { isa = PBXGroup; children = ( @@ -145,6 +156,7 @@ 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( + 5B0EA9D12C2EFAFF00296D87 /* Resources */, 13B07FAE1A68108700A75B9A /* RNSkia */, 832341AE1AAA6A7D00B99B32 /* Libraries */, 00E356EF1AD99517003FC87E /* RNSkiaTests */, @@ -265,6 +277,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5B0EA9D72C2F3EA400296D87 /* Roboto-Regular.ttf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -272,6 +285,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5B0EA9D62C2F3EA400296D87 /* Roboto-Regular.ttf in Resources */, 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, ); diff --git a/example/ios/RNSkia/Info.plist b/example/ios/RNSkia/Info.plist index 551a600fe5..f4db736b8c 100644 --- a/example/ios/RNSkia/Info.plist +++ b/example/ios/RNSkia/Info.plist @@ -53,5 +53,9 @@ UIViewControllerBasedStatusBarAppearance + UIAppFonts + + Roboto-Regular.ttf + diff --git a/example/ios/RNSkiaTests/Info.plist b/example/ios/RNSkiaTests/Info.plist index ba72822e87..6e0892b6ee 100644 --- a/example/ios/RNSkiaTests/Info.plist +++ b/example/ios/RNSkiaTests/Info.plist @@ -20,5 +20,9 @@ ???? CFBundleVersion 1 + UIAppFonts + + Roboto-Regular.ttf + diff --git a/package/src/renderer/__tests__/e2e/Text.spec.tsx b/package/src/renderer/__tests__/e2e/Text.spec.tsx index 523a4c47b6..47ce8f05af 100644 --- a/package/src/renderer/__tests__/e2e/Text.spec.tsx +++ b/package/src/renderer/__tests__/e2e/Text.spec.tsx @@ -106,4 +106,14 @@ describe("Text", () => { ); checkImage(image, `snapshots/text/text-path2-${surface.OS}.png`); }); + + it("should recognize packaged fonts", async () => { + const fontFamilies = await surface.eval((Skia) => { + const fontMgr = Skia.FontMgr.System(); + return new Array(fontMgr.countFamilies()) + .fill(0) + .map((_, i) => fontMgr.getFamilyName(i)); + }); + expect(fontFamilies.includes("Roboto")).toBe(true); + }); });