Skip to content

Custom typeface: import a TTF or OTF file - #52

Open
user12xxxxxx wants to merge 2 commits into
MasterPushers:mainfrom
user12xxxxxx:custom-font
Open

user12xxxxxx wants to merge 2 commits into
MasterPushers:mainfrom
user12xxxxxx:custom-font

Conversation

@user12xxxxxx

Copy link
Copy Markdown

What

Settings → Appearance → Typeface gains "Choose a font file…": pick any TTF or OTF on the phone through the system file picker (no new permission, no new dependency). The font is used for all text in the launcher.

  • The file is copied to files/fonts/custom only after Typeface.Builder(file).build() confirms Android can load it. Anything else is refused with a toast ("That is not a TTF or OTF font") and the previous font stays.
  • One slot: a new pick replaces the old font. Once imported, the font is listed by its file name in the Typeface dialog so you can switch back to it.
  • FocusTheme falls back to the default face when the file is missing (for example after restoring settings on another phone), and Appearance then shows Sans.
  • The split clock measures the custom font's "00:00" width instead of using the fixed sans/mono constants, so a wide font does not overflow its half.

Files

  • ui/theme/CustomFont.kt (new): import, validate, load, measure
  • data/Settings.kt: FontChoice.CUSTOM, customFontName
  • ui/theme/Theme.kt, ui/home/HomeScreen.kt, ui/settings/LauncherPages.kt
  • SettingsBackupTest: round-trips CUSTOM + name
  • README and brain (3-details/ui-system.md, journal)

Limits

  • One font file: light, medium and bold are synthesised by Compose unless the font has those weights itself.
  • The font file is not part of the settings backup (a backup is one small JSON file).

Verified

  • ./gradlew :app:testDebugUnitTest :app:lintDebug: 37 tests pass, lint 0 errors.
  • Pixel 9 emulator (Android 17, debug build), through the system file picker: a TTF and an OTF each imported and showed in settings and on home, and the split clock fitted. A text file renamed .ttf was refused with the toast. With the stored file deleted, the app restarted in Sans with no crash.
  • Not tested on a real phone, or with variable fonts.

🤖 Generated with Claude Code

user12xxxxxx and others added 2 commits November 8, 2026 08:37
Appearance -> Typeface gains "Choose a font file...", which opens the system
file picker (no permission). The picked file is copied to files/fonts/custom
after Typeface.Builder confirms Android can load it; anything else is refused
with a toast and the previous font stays. One slot: a new pick replaces it.

FontChoice.CUSTOM plus Settings.customFontName (label only). FocusTheme uses
the imported font everywhere and falls back to the default face when the
file is missing, e.g. after restoring settings on another phone; Appearance
then shows Sans. The split clock measures the font's "00:00" width instead
of assuming the sans/mono constants.

The font file is not part of the settings backup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant