feat(theme): draw the app in the shard's chosen type families (M12 phase 3) #36
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat/m12-phase-3-fonts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase 3 of M12 (
docs/android/THEMING_AND_NAV.md§5.3) — the fonts third of the admin's Appearance page, after phase 1's colors and phase 2's structure. Targetsedge; the milestone reachesmainas oneedge→mainmerge.ShardTypeface.resolve(theme)maps the three font stacks onto threeFontFamilyvalues andshardTypography(faces)draws the M5 type scale in them. Only the family moves — every size, weight, line height and tracking below it is the M5 value, so an unthemed instance reproduces the pre-M12 scale exactly. Resolution is pure, so every assertion is a plain JVM test with no Compose rule.Seven families are bundled beside the existing Cinzel (EB Garamond, Merriweather, Playfair Display, IM Fell English, Inter, Work Sans, Source Sans 3), taken verbatim from
google/fontsthe way M5 took Cinzel, each with its SIL OFL licence underapp/licenses/. Italics for the four familiesclient/index.htmlrequests one for; the rest are skewed, as every family in the app was before this PR.The APK nearly tripled, and that is a decision rather than a discovery
Measured unsigned release, R8 full-mode + resource shrink,
edge@7acbe54against this branch:The drafted §5.3 estimate was 1.5–2.5 MB, so this needs saying plainly: Merriweather is 6.08 MiB of the 8.15, because upstream ships it as a three-axis
[opsz,wdth,wght]variable font at 4.6 MB per style that deflates only 31% where the others manage 50–60%. The org lead chose to bundle it verbatim with the cheaper options costed — Google's own static 400/700 builds would have held the whole app near 6.8 MiB, and dropping it near 6.2 MiB at the price of a serif option that silently does nothing on Android. R8 does not shrinkres/font/; the APK's deflate is the only saving available.Three things the spec did not survive contact with
1. The per-role font list is not the set of values a role can hold. The server validates an admin-entered font against
FONT_OPTIONS[role], but a preset's tokens are copied verbatim byresolveThemeTokensand never pass through that dropdown —modernpublishes--display: 'Work Sans', Arial, sans-serif, which the display role does not offer, andfantasypublishes--sans: 'EB Garamond', Georgia, serif, which the sans role does not either. So the lookup is one global map keyed by the lowercased first family name, and both preset cases are asserted by name so a future per-role "tidy-up" fails loudly. Same trap phase 2 hit with--shadow-card, in a different token group.2. Every bundled family must supply all four weights, for the same reason: a family is not confined to the role its dropdown lives in, so Work Sans has to answer a display request at 600 and a label request at 500/700. The variable faces pin the four through
FontVariation. Two exceptions, both upstream facts rather than choices — IM Fell English has one weight per style (its 400 face answers all four and Android synthesises the bold, which is why the website labels it "no bold weight"), and Cinzel keeps M5's 500/600/700 since the server offers it in the display role alone, so nothing can ask it for 400 and adding an instance would have edited M5's type for no reachable case.3.
Typographyimplementsequals— like phase 2'sShapes, unlike phase 1'sColorScheme, checked the same way in the material3 1.3.0 bytecode. So AC-1's type half is one comparison against a verbatim copy of the pre-M12 scale held in the test, which also means a stray edit to a size or a letter-spacing inType.ktfails there rather than quietly redefining what "shipped" means.Why there is no
LocalShardTypefaceThe palette and the structure each needed a composition local for the part
MaterialThemecannot carry — five colors without a Material role, and aCardelevation that is a default argument. The families need none: every text style in the app comes fromMaterialTheme.typography, and the two composables that override anything (NotificationsScreen's hint,BlockRenderer's italic title) override the style, not the family.FontFamily.Monospaceon the recovery-codes screen stays fixed, as a semantic choice rather than a themed one.That is also why this phase has no call-site sweep, unlike phase 1's color imports and phase 2's 24
Card(sites:Cinzel/AppSerif/AppSanswere referenced fromType.ktand nowhere else, soval TypographybecomingshardTypography(faces)is the entire migration..gitattributesgains*.ttf binary.text=autoalready detects them, but a font is too easy to corrupt silently to leave to a heuristic now that eleven of them are in the tree.Tests
ShardTypefaceTest— 15 cases: the shipped families and the pre-M12 scale, therunic-gatewayno-op, both preset bypasses by name, all thirteen shortlist options, first-name parsing against quoting/casing/whitespace, per-field fallback, a colors-only theme, blank and comma-only stacks, and a themed scale proved to differ from the shipped one only in its families.401 unit tests green (386 + 15),
lintDebugandassembleDebugclean. Not exercised on device — that is AC-5, in phase 8, where IM Fell English's synthesised bold is the thing to look at.Docs: RunicGateway/docs#115.