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

Test detection of packaged fonts #2512

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ DerivedData
*.ipa
*.xcuserstate
project.xcworkspace
.xcode.env.local

# Android/IntelliJ
build/
Expand Down
Binary file not shown.
Binary file added example/assets/fonts/Roboto-Regular.ttf
Binary file not shown.
14 changes: 14 additions & 0 deletions example/ios/RNSkia.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
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 = "<group>"; };
5B0EA9D52C2F3EA400296D87 /* Roboto-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "Roboto-Regular.ttf"; path = "../../assets/fonts/Roboto-Regular.ttf"; sourceTree = "<group>"; };
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 = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = RNSkia/LaunchScreen.storyboard; sourceTree = "<group>"; };
DA3AEA9438F7550E6C6FA83B /* libPods-RNSkia.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNSkia.a"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -135,6 +138,14 @@
name = RNSkiaTests;
sourceTree = "<group>";
};
5B0EA9D12C2EFAFF00296D87 /* Resources */ = {
isa = PBXGroup;
children = (
5B0EA9D52C2F3EA400296D87 /* Roboto-Regular.ttf */,
);
path = Resources;
sourceTree = "<group>";
};
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
Expand All @@ -145,6 +156,7 @@
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
5B0EA9D12C2EFAFF00296D87 /* Resources */,
13B07FAE1A68108700A75B9A /* RNSkia */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
00E356EF1AD99517003FC87E /* RNSkiaTests */,
Expand Down Expand Up @@ -265,13 +277,15 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5B0EA9D72C2F3EA400296D87 /* Roboto-Regular.ttf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
13B07F8E1A680F5B00A75B9A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5B0EA9D62C2F3EA400296D87 /* Roboto-Regular.ttf in Resources */,
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
);
Expand Down
4 changes: 4 additions & 0 deletions example/ios/RNSkia/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIAppFonts</key>
<array>
<string>Roboto-Regular.ttf</string>
</array>
</dict>
</plist>
4 changes: 4 additions & 0 deletions example/ios/RNSkiaTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>UIAppFonts</key>
<array>
<string>Roboto-Regular.ttf</string>
</array>
</dict>
</plist>
10 changes: 10 additions & 0 deletions package/src/renderer/__tests__/e2e/Text.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Loading