Commit 31297d1fbc

31297d1fbcf0e4791bede10ec3dc6d3a0c145eb1

parent: 96e2b60a30

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-22 17:46 UTC

Ship only SwiftMath's Latin Modern font

LatexPreview uses SwiftMath's default font. build-app.sh and a build phase in
the four Xcode targets that embed SwiftMath's bundle delete the other eleven
fonts and their math tables, then sign the copy again if it was signed. The
phase writes inside the bundle, so those targets run scripts unsandboxed.

Closes #208

Layout: unified · split

ios/Orgstar.xcodeproj/project.pbxproj +96
@@ -409,6 +409,7 @@
409409 FD11E99E3EE9450636C880B9 /* Sources */,
410410 843FAAECD041CD2466904790 /* Frameworks */,
411411 287027B677CE75B2D4715EE6 /* Resources */,
412 3B3A530168A4B0C6DC41A289 /* Remove unused math fonts */,
412413 269605D45C104F12CBCDC8FB /* Embed Foundation Extensions */,
413414 2EBC267BEE9E23673AE8DADC /* Embed Watch Content */,
414415 );
@@ -441,6 +442,7 @@
441442 E5AC38BB173B87555EBEC0AC /* Sources */,
442443 1439C48F60EF427CC7ADB87B /* Frameworks */,
443444 1A9DC7DD7E76A6C5A1DC674C /* Resources */,
445 C6B3DD5221D3870C9175CC69 /* Remove unused math fonts */,
444446 );
445447 buildRules = (
446448 );
@@ -538,6 +540,7 @@
538540 0EFD7F2537761E968D3FE030 /* Sources */,
539541 39CC8FCF3B50EC810191AF52 /* Frameworks */,
540542 EDF6CA650FB1A0A57A682074 /* Resources */,
543 C7926A563D8955E2098E6D1E /* Remove unused math fonts */,
541544 50EAF92A2ABF4715F69C1B26 /* Embed Foundation Extensions */,
542545 );
543546 buildRules = (
@@ -592,6 +595,7 @@
592595 296E85448BDDDD3245D3D432 /* Sources */,
593596 AE22603FB5DE3C5FFFBBC68E /* Frameworks */,
594597 EA6C64E8D42ADCFBC3B131FF /* Resources */,
598 52900680D96A1A4CD35C68D4 /* Remove unused math fonts */,
595599 );
596600 buildRules = (
597601 );
@@ -720,6 +724,27 @@
720724/* End PBXResourcesBuildPhase section */
721725
722726/* Begin PBXShellScriptBuildPhase section */
727 3B3A530168A4B0C6DC41A289 /* Remove unused math fonts */ = {
728 isa = PBXShellScriptBuildPhase;
729 buildActionMask = 2147483647;
730 files = (
731 );
732 inputFileListPaths = (
733 );
734 inputPaths = (
735 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/SwiftMath_SwiftMath.bundle",
736 );
737 name = "Remove unused math fonts";
738 outputFileListPaths = (
739 );
740 outputPaths = (
741 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/SwiftMath_SwiftMath.bundle",
742 "$(DERIVED_FILE_DIR)/math-fonts-removed",
743 );
744 runOnlyForDeploymentPostprocessing = 0;
745 shellPath = /bin/sh;
746 shellScript = "# LatexPreview uses only SwiftMath's default font, Latin Modern. A signed copy is signed again.\nfind \"$SCRIPT_OUTPUT_FILE_0\" -path '*/mathFonts.bundle/*' \\( -name '*.otf' -o -name '*.plist' \\) ! -name 'latinmodern-math.*' -delete\nif codesign -d \"$SCRIPT_OUTPUT_FILE_0\" 2> /dev/null; then\n codesign --force --sign \"${EXPANDED_CODE_SIGN_IDENTITY:--}\" \"$SCRIPT_OUTPUT_FILE_0\"\nfi\ntouch \"$SCRIPT_OUTPUT_FILE_1\"\n";
747 };
723748 4316AE7E93B32A6A11452968 /* Compile string catalog */ = {
724749 isa = PBXShellScriptBuildPhase;
725750 buildActionMask = 2147483647;
@@ -751,6 +776,27 @@
751776 shellPath = /bin/sh;
752777 shellScript = "# The catalog is compiled here rather than as a resource, so that Xcode doesn't sync it\n# from this target's sources; scripts/sync-strings.sh keeps it.\nxcrun xcstringstool compile \"$SCRIPT_INPUT_FILE_0\" --output-directory \"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\"\n";
753778 };
779 52900680D96A1A4CD35C68D4 /* Remove unused math fonts */ = {
780 isa = PBXShellScriptBuildPhase;
781 buildActionMask = 2147483647;
782 files = (
783 );
784 inputFileListPaths = (
785 );
786 inputPaths = (
787 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/SwiftMath_SwiftMath.bundle",
788 );
789 name = "Remove unused math fonts";
790 outputFileListPaths = (
791 );
792 outputPaths = (
793 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/SwiftMath_SwiftMath.bundle",
794 "$(DERIVED_FILE_DIR)/math-fonts-removed",
795 );
796 runOnlyForDeploymentPostprocessing = 0;
797 shellPath = /bin/sh;
798 shellScript = "# LatexPreview uses only SwiftMath's default font, Latin Modern. A signed copy is signed again.\nfind \"$SCRIPT_OUTPUT_FILE_0\" -path '*/mathFonts.bundle/*' \\( -name '*.otf' -o -name '*.plist' \\) ! -name 'latinmodern-math.*' -delete\nif codesign -d \"$SCRIPT_OUTPUT_FILE_0\" 2> /dev/null; then\n codesign --force --sign \"${EXPANDED_CODE_SIGN_IDENTITY:--}\" \"$SCRIPT_OUTPUT_FILE_0\"\nfi\ntouch \"$SCRIPT_OUTPUT_FILE_1\"\n";
799 };
754800 641BAD6CBA4413E3690E3513 /* Compile string catalog */ = {
755801 isa = PBXShellScriptBuildPhase;
756802 buildActionMask = 2147483647;
@@ -875,6 +921,48 @@
875921 shellPath = /bin/sh;
876922 shellScript = "# The catalog is compiled here rather than as a resource, so that Xcode doesn't sync it\n# from this target's sources; scripts/sync-strings.sh keeps it.\nxcrun xcstringstool compile \"$SCRIPT_INPUT_FILE_0\" --output-directory \"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\"\n";
877923 };
924 C6B3DD5221D3870C9175CC69 /* Remove unused math fonts */ = {
925 isa = PBXShellScriptBuildPhase;
926 buildActionMask = 2147483647;
927 files = (
928 );
929 inputFileListPaths = (
930 );
931 inputPaths = (
932 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/SwiftMath_SwiftMath.bundle",
933 );
934 name = "Remove unused math fonts";
935 outputFileListPaths = (
936 );
937 outputPaths = (
938 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/SwiftMath_SwiftMath.bundle",
939 "$(DERIVED_FILE_DIR)/math-fonts-removed",
940 );
941 runOnlyForDeploymentPostprocessing = 0;
942 shellPath = /bin/sh;
943 shellScript = "# LatexPreview uses only SwiftMath's default font, Latin Modern. A signed copy is signed again.\nfind \"$SCRIPT_OUTPUT_FILE_0\" -path '*/mathFonts.bundle/*' \\( -name '*.otf' -o -name '*.plist' \\) ! -name 'latinmodern-math.*' -delete\nif codesign -d \"$SCRIPT_OUTPUT_FILE_0\" 2> /dev/null; then\n codesign --force --sign \"${EXPANDED_CODE_SIGN_IDENTITY:--}\" \"$SCRIPT_OUTPUT_FILE_0\"\nfi\ntouch \"$SCRIPT_OUTPUT_FILE_1\"\n";
944 };
945 C7926A563D8955E2098E6D1E /* Remove unused math fonts */ = {
946 isa = PBXShellScriptBuildPhase;
947 buildActionMask = 2147483647;
948 files = (
949 );
950 inputFileListPaths = (
951 );
952 inputPaths = (
953 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/SwiftMath_SwiftMath.bundle",
954 );
955 name = "Remove unused math fonts";
956 outputFileListPaths = (
957 );
958 outputPaths = (
959 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/SwiftMath_SwiftMath.bundle",
960 "$(DERIVED_FILE_DIR)/math-fonts-removed",
961 );
962 runOnlyForDeploymentPostprocessing = 0;
963 shellPath = /bin/sh;
964 shellScript = "# LatexPreview uses only SwiftMath's default font, Latin Modern. A signed copy is signed again.\nfind \"$SCRIPT_OUTPUT_FILE_0\" -path '*/mathFonts.bundle/*' \\( -name '*.otf' -o -name '*.plist' \\) ! -name 'latinmodern-math.*' -delete\nif codesign -d \"$SCRIPT_OUTPUT_FILE_0\" 2> /dev/null; then\n codesign --force --sign \"${EXPANDED_CODE_SIGN_IDENTITY:--}\" \"$SCRIPT_OUTPUT_FILE_0\"\nfi\ntouch \"$SCRIPT_OUTPUT_FILE_1\"\n";
965 };
878966 C9A138A7D511613ADA30B0C1 /* Compile string catalog */ = {
879967 isa = PBXShellScriptBuildPhase;
880968 buildActionMask = 2147483647;
@@ -1020,6 +1108,7 @@
10201108 COMBINE_HIDPI_IMAGES = YES;
10211109 CURRENT_PROJECT_VERSION = 17;
10221110 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1111 ENABLE_USER_SCRIPT_SANDBOXING = NO;
10231112 GENERATE_INFOPLIST_FILE = NO;
10241113 INFOPLIST_FILE = OrgstarMac/Info.plist;
10251114 LD_RUNPATH_SEARCH_PATHS = (
@@ -1076,6 +1165,7 @@
10761165 CODE_SIGN_STYLE = Automatic;
10771166 CURRENT_PROJECT_VERSION = 17;
10781167 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1168 ENABLE_USER_SCRIPT_SANDBOXING = NO;
10791169 GENERATE_INFOPLIST_FILE = NO;
10801170 INFOPLIST_FILE = OrgstarShare/Info.plist;
10811171 LD_RUNPATH_SEARCH_PATHS = (
@@ -1098,6 +1188,7 @@
10981188 CODE_SIGN_STYLE = Automatic;
10991189 CURRENT_PROJECT_VERSION = 17;
11001190 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1191 ENABLE_USER_SCRIPT_SANDBOXING = NO;
11011192 GENERATE_INFOPLIST_FILE = NO;
11021193 INFOPLIST_FILE = OrgstarShare/Info.plist;
11031194 LD_RUNPATH_SEARCH_PATHS = (
@@ -1147,6 +1238,7 @@
11471238 CODE_SIGN_STYLE = Automatic;
11481239 CURRENT_PROJECT_VERSION = 17;
11491240 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1241 ENABLE_USER_SCRIPT_SANDBOXING = NO;
11501242 GENERATE_INFOPLIST_FILE = NO;
11511243 INFOPLIST_FILE = Orgstar/Info.plist;
11521244 INFOPLIST_KEY_CFBundleDisplayName = orgstar;
@@ -1246,6 +1338,7 @@
12461338 CODE_SIGN_STYLE = Automatic;
12471339 CURRENT_PROJECT_VERSION = 17;
12481340 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1341 ENABLE_USER_SCRIPT_SANDBOXING = NO;
12491342 GENERATE_INFOPLIST_FILE = NO;
12501343 INFOPLIST_FILE = OrgstarWidgets/Info.plist;
12511344 IPHONEOS_DEPLOYMENT_TARGET = 26.0;
@@ -1355,6 +1448,7 @@
13551448 CODE_SIGN_STYLE = Automatic;
13561449 CURRENT_PROJECT_VERSION = 17;
13571450 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1451 ENABLE_USER_SCRIPT_SANDBOXING = NO;
13581452 GENERATE_INFOPLIST_FILE = NO;
13591453 INFOPLIST_FILE = Orgstar/Info.plist;
13601454 INFOPLIST_KEY_CFBundleDisplayName = orgstar;
@@ -1379,6 +1473,7 @@
13791473 CODE_SIGN_STYLE = Automatic;
13801474 CURRENT_PROJECT_VERSION = 17;
13811475 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1476 ENABLE_USER_SCRIPT_SANDBOXING = NO;
13821477 GENERATE_INFOPLIST_FILE = NO;
13831478 INFOPLIST_FILE = OrgstarWidgets/Info.plist;
13841479 IPHONEOS_DEPLOYMENT_TARGET = 26.0;
@@ -1459,6 +1554,7 @@
14591554 COMBINE_HIDPI_IMAGES = YES;
14601555 CURRENT_PROJECT_VERSION = 17;
14611556 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1557 ENABLE_USER_SCRIPT_SANDBOXING = NO;
14621558 GENERATE_INFOPLIST_FILE = NO;
14631559 INFOPLIST_FILE = OrgstarMac/Info.plist;
14641560 LD_RUNPATH_SEARCH_PATHS = (
scripts/build-app.sh +4 −1
@@ -45,8 +45,11 @@ otool -l "$app/Contents/MacOS/Orgstar" | grep -q '@executable_path/../Frameworks
4545 || install_name_tool -add_rpath @executable_path/../Frameworks "$app/Contents/MacOS/Orgstar"
4646strip -x "$app/Contents/MacOS/Orgstar"
4747
48# SwiftMath's math fonts, which it finds in the app's resources.
48# SwiftMath's math fonts, which it finds in the app's resources. LatexPreview uses only the
49# default, Latin Modern.
4950cp -R "$(dirname "$binary")/SwiftMath_SwiftMath.bundle" "$app/Contents/Resources/"
51find "$app/Contents/Resources/SwiftMath_SwiftMath.bundle" -path '*/mathFonts.bundle/*' \
52 \( -name '*.otf' -o -name '*.plist' \) ! -name 'latinmodern-math.*' -delete
5053# MathJax, for PDF export.
5154cp -R "$(dirname "$binary")/Orgstar_OrgMathJax.bundle" "$app/Contents/Resources/"
5255