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 @@
409 FD11E99E3EE9450636C880B9 /* Sources */, 409 FD11E99E3EE9450636C880B9 /* Sources */,
410 843FAAECD041CD2466904790 /* Frameworks */, 410 843FAAECD041CD2466904790 /* Frameworks */,
411 287027B677CE75B2D4715EE6 /* Resources */, 411 287027B677CE75B2D4715EE6 /* Resources */,
412 3B3A530168A4B0C6DC41A289 /* Remove unused math fonts */,
412 269605D45C104F12CBCDC8FB /* Embed Foundation Extensions */, 413 269605D45C104F12CBCDC8FB /* Embed Foundation Extensions */,
413 2EBC267BEE9E23673AE8DADC /* Embed Watch Content */, 414 2EBC267BEE9E23673AE8DADC /* Embed Watch Content */,
414 ); 415 );
@@ -441,6 +442,7 @@
441 E5AC38BB173B87555EBEC0AC /* Sources */, 442 E5AC38BB173B87555EBEC0AC /* Sources */,
442 1439C48F60EF427CC7ADB87B /* Frameworks */, 443 1439C48F60EF427CC7ADB87B /* Frameworks */,
443 1A9DC7DD7E76A6C5A1DC674C /* Resources */, 444 1A9DC7DD7E76A6C5A1DC674C /* Resources */,
445 C6B3DD5221D3870C9175CC69 /* Remove unused math fonts */,
444 ); 446 );
445 buildRules = ( 447 buildRules = (
446 ); 448 );
@@ -538,6 +540,7 @@
538 0EFD7F2537761E968D3FE030 /* Sources */, 540 0EFD7F2537761E968D3FE030 /* Sources */,
539 39CC8FCF3B50EC810191AF52 /* Frameworks */, 541 39CC8FCF3B50EC810191AF52 /* Frameworks */,
540 EDF6CA650FB1A0A57A682074 /* Resources */, 542 EDF6CA650FB1A0A57A682074 /* Resources */,
543 C7926A563D8955E2098E6D1E /* Remove unused math fonts */,
541 50EAF92A2ABF4715F69C1B26 /* Embed Foundation Extensions */, 544 50EAF92A2ABF4715F69C1B26 /* Embed Foundation Extensions */,
542 ); 545 );
543 buildRules = ( 546 buildRules = (
@@ -592,6 +595,7 @@
592 296E85448BDDDD3245D3D432 /* Sources */, 595 296E85448BDDDD3245D3D432 /* Sources */,
593 AE22603FB5DE3C5FFFBBC68E /* Frameworks */, 596 AE22603FB5DE3C5FFFBBC68E /* Frameworks */,
594 EA6C64E8D42ADCFBC3B131FF /* Resources */, 597 EA6C64E8D42ADCFBC3B131FF /* Resources */,
598 52900680D96A1A4CD35C68D4 /* Remove unused math fonts */,
595 ); 599 );
596 buildRules = ( 600 buildRules = (
597 ); 601 );
@@ -720,6 +724,27 @@
720/* End PBXResourcesBuildPhase section */ 724/* End PBXResourcesBuildPhase section */
721 725
722/* Begin PBXShellScriptBuildPhase section */ 726/* 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 };
723 4316AE7E93B32A6A11452968 /* Compile string catalog */ = { 748 4316AE7E93B32A6A11452968 /* Compile string catalog */ = {
724 isa = PBXShellScriptBuildPhase; 749 isa = PBXShellScriptBuildPhase;
725 buildActionMask = 2147483647; 750 buildActionMask = 2147483647;
@@ -751,6 +776,27 @@
751 shellPath = /bin/sh; 776 shellPath = /bin/sh;
752 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"; 777 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";
753 }; 778 };
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 };
754 641BAD6CBA4413E3690E3513 /* Compile string catalog */ = { 800 641BAD6CBA4413E3690E3513 /* Compile string catalog */ = {
755 isa = PBXShellScriptBuildPhase; 801 isa = PBXShellScriptBuildPhase;
756 buildActionMask = 2147483647; 802 buildActionMask = 2147483647;
@@ -875,6 +921,48 @@
875 shellPath = /bin/sh; 921 shellPath = /bin/sh;
876 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"; 922 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";
877 }; 923 };
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 };
878 C9A138A7D511613ADA30B0C1 /* Compile string catalog */ = { 966 C9A138A7D511613ADA30B0C1 /* Compile string catalog */ = {
879 isa = PBXShellScriptBuildPhase; 967 isa = PBXShellScriptBuildPhase;
880 buildActionMask = 2147483647; 968 buildActionMask = 2147483647;
@@ -1020,6 +1108,7 @@
1020 COMBINE_HIDPI_IMAGES = YES; 1108 COMBINE_HIDPI_IMAGES = YES;
1021 CURRENT_PROJECT_VERSION = 17; 1109 CURRENT_PROJECT_VERSION = 17;
1022 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1110 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1111 ENABLE_USER_SCRIPT_SANDBOXING = NO;
1023 GENERATE_INFOPLIST_FILE = NO; 1112 GENERATE_INFOPLIST_FILE = NO;
1024 INFOPLIST_FILE = OrgstarMac/Info.plist; 1113 INFOPLIST_FILE = OrgstarMac/Info.plist;
1025 LD_RUNPATH_SEARCH_PATHS = ( 1114 LD_RUNPATH_SEARCH_PATHS = (
@@ -1076,6 +1165,7 @@
1076 CODE_SIGN_STYLE = Automatic; 1165 CODE_SIGN_STYLE = Automatic;
1077 CURRENT_PROJECT_VERSION = 17; 1166 CURRENT_PROJECT_VERSION = 17;
1078 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1167 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1168 ENABLE_USER_SCRIPT_SANDBOXING = NO;
1079 GENERATE_INFOPLIST_FILE = NO; 1169 GENERATE_INFOPLIST_FILE = NO;
1080 INFOPLIST_FILE = OrgstarShare/Info.plist; 1170 INFOPLIST_FILE = OrgstarShare/Info.plist;
1081 LD_RUNPATH_SEARCH_PATHS = ( 1171 LD_RUNPATH_SEARCH_PATHS = (
@@ -1098,6 +1188,7 @@
1098 CODE_SIGN_STYLE = Automatic; 1188 CODE_SIGN_STYLE = Automatic;
1099 CURRENT_PROJECT_VERSION = 17; 1189 CURRENT_PROJECT_VERSION = 17;
1100 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1190 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1191 ENABLE_USER_SCRIPT_SANDBOXING = NO;
1101 GENERATE_INFOPLIST_FILE = NO; 1192 GENERATE_INFOPLIST_FILE = NO;
1102 INFOPLIST_FILE = OrgstarShare/Info.plist; 1193 INFOPLIST_FILE = OrgstarShare/Info.plist;
1103 LD_RUNPATH_SEARCH_PATHS = ( 1194 LD_RUNPATH_SEARCH_PATHS = (
@@ -1147,6 +1238,7 @@
1147 CODE_SIGN_STYLE = Automatic; 1238 CODE_SIGN_STYLE = Automatic;
1148 CURRENT_PROJECT_VERSION = 17; 1239 CURRENT_PROJECT_VERSION = 17;
1149 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1240 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1241 ENABLE_USER_SCRIPT_SANDBOXING = NO;
1150 GENERATE_INFOPLIST_FILE = NO; 1242 GENERATE_INFOPLIST_FILE = NO;
1151 INFOPLIST_FILE = Orgstar/Info.plist; 1243 INFOPLIST_FILE = Orgstar/Info.plist;
1152 INFOPLIST_KEY_CFBundleDisplayName = orgstar; 1244 INFOPLIST_KEY_CFBundleDisplayName = orgstar;
@@ -1246,6 +1338,7 @@
1246 CODE_SIGN_STYLE = Automatic; 1338 CODE_SIGN_STYLE = Automatic;
1247 CURRENT_PROJECT_VERSION = 17; 1339 CURRENT_PROJECT_VERSION = 17;
1248 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1340 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1341 ENABLE_USER_SCRIPT_SANDBOXING = NO;
1249 GENERATE_INFOPLIST_FILE = NO; 1342 GENERATE_INFOPLIST_FILE = NO;
1250 INFOPLIST_FILE = OrgstarWidgets/Info.plist; 1343 INFOPLIST_FILE = OrgstarWidgets/Info.plist;
1251 IPHONEOS_DEPLOYMENT_TARGET = 26.0; 1344 IPHONEOS_DEPLOYMENT_TARGET = 26.0;
@@ -1355,6 +1448,7 @@
1355 CODE_SIGN_STYLE = Automatic; 1448 CODE_SIGN_STYLE = Automatic;
1356 CURRENT_PROJECT_VERSION = 17; 1449 CURRENT_PROJECT_VERSION = 17;
1357 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1450 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1451 ENABLE_USER_SCRIPT_SANDBOXING = NO;
1358 GENERATE_INFOPLIST_FILE = NO; 1452 GENERATE_INFOPLIST_FILE = NO;
1359 INFOPLIST_FILE = Orgstar/Info.plist; 1453 INFOPLIST_FILE = Orgstar/Info.plist;
1360 INFOPLIST_KEY_CFBundleDisplayName = orgstar; 1454 INFOPLIST_KEY_CFBundleDisplayName = orgstar;
@@ -1379,6 +1473,7 @@
1379 CODE_SIGN_STYLE = Automatic; 1473 CODE_SIGN_STYLE = Automatic;
1380 CURRENT_PROJECT_VERSION = 17; 1474 CURRENT_PROJECT_VERSION = 17;
1381 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1475 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1476 ENABLE_USER_SCRIPT_SANDBOXING = NO;
1382 GENERATE_INFOPLIST_FILE = NO; 1477 GENERATE_INFOPLIST_FILE = NO;
1383 INFOPLIST_FILE = OrgstarWidgets/Info.plist; 1478 INFOPLIST_FILE = OrgstarWidgets/Info.plist;
1384 IPHONEOS_DEPLOYMENT_TARGET = 26.0; 1479 IPHONEOS_DEPLOYMENT_TARGET = 26.0;
@@ -1459,6 +1554,7 @@
1459 COMBINE_HIDPI_IMAGES = YES; 1554 COMBINE_HIDPI_IMAGES = YES;
1460 CURRENT_PROJECT_VERSION = 17; 1555 CURRENT_PROJECT_VERSION = 17;
1461 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1556 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1557 ENABLE_USER_SCRIPT_SANDBOXING = NO;
1462 GENERATE_INFOPLIST_FILE = NO; 1558 GENERATE_INFOPLIST_FILE = NO;
1463 INFOPLIST_FILE = OrgstarMac/Info.plist; 1559 INFOPLIST_FILE = OrgstarMac/Info.plist;
1464 LD_RUNPATH_SEARCH_PATHS = ( 1560 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
45 || install_name_tool -add_rpath @executable_path/../Frameworks "$app/Contents/MacOS/Orgstar" 45 || install_name_tool -add_rpath @executable_path/../Frameworks "$app/Contents/MacOS/Orgstar"
46strip -x "$app/Contents/MacOS/Orgstar" 46strip -x "$app/Contents/MacOS/Orgstar"
47 47
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.
49cp -R "$(dirname "$binary")/SwiftMath_SwiftMath.bundle" "$app/Contents/Resources/" 50cp -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
50# MathJax, for PDF export. 53# MathJax, for PDF export.
51cp -R "$(dirname "$binary")/Orgstar_OrgMathJax.bundle" "$app/Contents/Resources/" 54cp -R "$(dirname "$binary")/Orgstar_OrgMathJax.bundle" "$app/Contents/Resources/"
52 55