build(perf): trim build outputs for hooks, CI, and the shipped font
Headline numbers from a fresh `./gradlew assemble`:
- :commons material_symbols_outlined.ttf 11M -> 409K (subset to the 210
codepoints actually referenced from MaterialSymbols.kt)
- :amethyst per-ABI APKs no longer built in CI (-PdisableAbiSplits=true);
~600M of stripped_native_libs intermediates skipped per run
Changes:
- .git-hooks/pre-push runs only :amethyst:testPlayDebugUnitTest plus jvmTest
on the KMP modules instead of `./gradlew test`, which was compiling all six
amethyst variants (play/fdroid x debug/release/benchmark)
- amethyst/build.gradle adds three opt-in fast-build flags:
-PdisableAbiSplits=true skip per-ABI APK splits
-PdisableUniversalApk=true skip the universal APK output
-Pamethyst.skipMapping=true disable R8 (release+benchmark)
Defaults are unchanged; release pipelines must not set skipMapping.
- .github/workflows/build.yml uses gradle/actions/setup-gradle@v4 with
cache-read-only on PRs / cache-write on main, drops --no-daemon, collapses
the Android job to a single Gradle invocation (lint + focused debug unit
tests + assembleBenchmark with -PdisableAbiSplits=true), and globs both
APK naming patterns for the upload step.
- tools/material-symbols-subset/{subset.sh,README.md} regenerates the font
from upstream + MaterialSymbols.kt; run after adding/removing icons.
Verified: ./gradlew :amethyst:help with all three new -P flags parses cleanly,
and ./gradlew :commons:jvmJar --rerun-tasks succeeds with the subsetted font
(commons-jvm jar shrinks from ~13M to 2.9M).
https://claude.ai/code/session_01YSmkagXXN5AwGcY4upiUh1
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
# Material Symbols Subset
|
||||
|
||||
The font shipped at
|
||||
`commons/src/commonMain/composeResources/font/material_symbols_outlined.ttf`
|
||||
is a **subset** of Google's [Material Symbols
|
||||
Outlined](https://github.com/google/material-design-icons) variable font,
|
||||
trimmed to only the codepoints referenced from
|
||||
`commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/icons/symbols/MaterialSymbols.kt`.
|
||||
|
||||
| | Full upstream | Subset |
|
||||
|---|---|---|
|
||||
| Size | ~11 MB | ~410 KB |
|
||||
| Glyphs | ~3500 | ~210 |
|
||||
|
||||
The subset cuts >10 MB out of every commons build artifact, every Android APK,
|
||||
and every Desktop app bundle.
|
||||
|
||||
## When to regenerate
|
||||
|
||||
Run `subset.sh` whenever you:
|
||||
|
||||
- add or remove a `MaterialSymbol("\uXXXX")` entry in `MaterialSymbols.kt`
|
||||
- pin a newer upstream font version
|
||||
|
||||
## Prerequisites
|
||||
|
||||
```bash
|
||||
pip install fonttools brotli
|
||||
```
|
||||
|
||||
## Regenerating
|
||||
|
||||
From the repo root:
|
||||
|
||||
```bash
|
||||
./tools/material-symbols-subset/subset.sh
|
||||
```
|
||||
|
||||
That downloads the upstream variable font, intersects its codepoints with the
|
||||
ones referenced from `MaterialSymbols.kt`, and overwrites the checked-in
|
||||
`material_symbols_outlined.ttf`.
|
||||
|
||||
If you already have an upstream `.ttf` on disk:
|
||||
|
||||
```bash
|
||||
./tools/material-symbols-subset/subset.sh /path/to/MaterialSymbolsOutlined-Regular.ttf
|
||||
```
|
||||
|
||||
Commit the regenerated `.ttf` alongside the `MaterialSymbols.kt` change.
|
||||
|
||||
## How it works
|
||||
|
||||
`pyftsubset` (from `fonttools`) reads the codepoints we care about, drops every
|
||||
glyph and OpenType feature not reachable from those codepoints, and rewrites
|
||||
`name`, `cmap`, and `GSUB` tables accordingly. The Compose resource pipeline
|
||||
treats the result as a normal TTF — no code changes needed.
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Subset commons/.../material_symbols_outlined.ttf to only the codepoints
|
||||
# referenced from MaterialSymbols.kt. The full Google variable font is ~11 MB
|
||||
# (≈3500 glyphs); the subset is ~410 KB.
|
||||
#
|
||||
# Run this whenever MaterialSymbols.kt gains or loses a codepoint, or when
|
||||
# pulling a newer upstream font release.
|
||||
#
|
||||
# Inputs:
|
||||
# $1 (optional) — path to a full upstream MaterialSymbolsOutlined-Regular.ttf
|
||||
# to subset. If omitted, the script downloads the variable
|
||||
# font from Google Fonts.
|
||||
#
|
||||
# Output:
|
||||
# Overwrites commons/src/commonMain/composeResources/font/material_symbols_outlined.ttf
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
SYMBOLS_KT="$REPO_ROOT/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/icons/symbols/MaterialSymbols.kt"
|
||||
TARGET="$REPO_ROOT/commons/src/commonMain/composeResources/font/material_symbols_outlined.ttf"
|
||||
|
||||
if ! command -v pyftsubset >/dev/null 2>&1; then
|
||||
echo "pyftsubset not found. Install with: pip install fonttools brotli" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${1:-}" ]; then
|
||||
SOURCE_TTF="$1"
|
||||
else
|
||||
SOURCE_TTF="$(mktemp -t material_symbols.XXXXXX.ttf)"
|
||||
trap 'rm -f "$SOURCE_TTF"' EXIT
|
||||
echo "Downloading upstream Material Symbols Outlined variable font..."
|
||||
curl -fsSL -o "$SOURCE_TTF" \
|
||||
"https://github.com/google/material-design-icons/raw/master/variablefont/MaterialSymbolsOutlined%5BFILL%2CGRAD%2Copsz%2Cwght%5D.ttf"
|
||||
fi
|
||||
|
||||
CODEPOINTS_FILE="$(mktemp -t material_symbols_cp.XXXXXX.txt)"
|
||||
trap 'rm -f "$CODEPOINTS_FILE" ${SOURCE_TTF:+}' EXIT
|
||||
|
||||
# Pull every \uXXXX literal out of MaterialSymbols.kt as U+XXXX, deduplicated.
|
||||
grep -oE '\\u[A-Fa-f0-9]{4}' "$SYMBOLS_KT" | sort -u | sed 's/\\u/U+/' > "$CODEPOINTS_FILE"
|
||||
|
||||
count=$(wc -l < "$CODEPOINTS_FILE")
|
||||
echo "Subsetting to $count codepoints from MaterialSymbols.kt"
|
||||
|
||||
pyftsubset "$SOURCE_TTF" \
|
||||
--unicodes-file="$CODEPOINTS_FILE" \
|
||||
--output-file="$TARGET" \
|
||||
--layout-features='*' \
|
||||
--no-hinting \
|
||||
--desubroutinize \
|
||||
--notdef-outline \
|
||||
--recommended-glyphs \
|
||||
--name-IDs='*' \
|
||||
--name-legacy \
|
||||
--name-languages='*' \
|
||||
--glyph-names \
|
||||
--symbol-cmap
|
||||
|
||||
echo "Wrote $TARGET ($(du -h "$TARGET" | cut -f1))"
|
||||
Reference in New Issue
Block a user