feat: support custom fonts in system settings#729
Conversation
frysee
left a comment
There was a problem hiding this comment.
Looks good to me, but I'd rather avoid the breaking change for paks.
| { | ||
| printf("{\n"); | ||
| printf("\t\"font\": %i,\n", settings.font); | ||
| printf("\t\"font\": \"%s\",\n", settings.fontFile); |
There was a problem hiding this comment.
Can we avoid breaking paks here? Just return the default (font=1) for this if a custom font is selected, even though it is potentially wrong. Pak developers have an upgrade path via fontpath, which is the more portable way anyway (it has the whole path). We can then later deprecate this one in favour of fontpath
There was a problem hiding this comment.
Yep, that's the smart call. I went through all of the paks on the pak store. The biggest things affected are the OTA updater and Helaas's Apostrophe lib. Overall the standard fonts would have worked, but not intentionally, so fragile.
Here's a summary:
Audited all 87 pak store repos + 3 related projects (Apostrophe, Csthetics, NextUI Theme Manager) for any code that reads the font= setting from minuisettings.txt.
Findings:
84 paks have zero interaction with the font setting
2 projects read font=:
Apostrophe library (used by 20+ paks) — parses as integer via ap__read_nextui_setting_int("font", 1), constructs font%d.ttf
NextUI Updater — uses settings.contains("font=1") substring match
0 paks call nextval font or nextval fontpath
Fix: Built-in fonts now write integer values (font=0 for OG, font=1 for Next) to minuisettings.txt, preserving the original format. Custom fonts write the filename string. This applies to CFG_sync, CFG_get, and CFG_print — so both the settings file and nextval output maintain backward compat.
Existing paks continue working unchanged. Apostrophe-based paks with a custom font selected will gracefully fall back to font1.ttf (the default) until Apostrophe is updated to handle filename strings.
| else if (strcmp(settings.fontFile, "font2.ttf") == 0) | ||
| fprintf(file, "font=0\n"); | ||
| else | ||
| fprintf(file, "font=%s\n", settings.fontFile); |
There was a problem hiding this comment.
Else branch still breaks backwards compatibility.
There was a problem hiding this comment.
Fixed, nextval font now always returns an integer.
| else if (strcmp(settings.fontFile, "font2.ttf") == 0) | ||
| printf("\t\"font\": \"0\",\n"); | ||
| else | ||
| printf("\t\"font\": \"%s\",\n", settings.fontFile); |
There was a problem hiding this comment.
Fixed, nextval font now always returns an integer.
| #define ROOT_SYSTEM_PATH SDCARD_PATH "/.system/" | ||
| #define SYSTEM_PATH SDCARD_PATH "/.system/" PLATFORM | ||
| #define RES_PATH SDCARD_PATH "/.system/res" | ||
| #define FONTS_PATH RES_PATH "/fonts" |
There was a problem hiding this comment.
Whats the benefit of the subfolder? It just means having fonts in to separate locations, making the whole theming more confusing. I'd agree if we wouldnt have any fonts yet, but thats not the case here.
There was a problem hiding this comment.
It was to have a convenient place for users to drop fonts and find them easily to remove if they wanted. If they are dropping files in there they likely already understand where to find them later though, so I'll adjust to have them in /res with the shipped fonts.
Users can drop .ttf/.otf files into .system/res/fonts/ and they appear as options in the Settings font picker alongside the built-in "Next" and "OG" fonts. Font selection is stored by filename in minuisettings.txt with backward compatibility for existing font=0/1 integer values. Falls back to the default font if a custom font file is removed.
Write integer values (font=0, font=1) for built-in fonts so existing paks that parse the setting as an integer keep working. Custom fonts write the filename string. Affects CFG_sync, CFG_get, and CFG_print.
- nextval font always returns integer (0 or 1), never filename - CFG_print outputs font as integer to fix gabagool JSON parsing - Move custom fonts to .system/res/ alongside built-ins (no subfolder) - Remove FONTS_PATH define, all fonts use RES_PATH - Filter BPreplay system fonts from settings font picker - Move licenses dir to .system/res/licenses/
Users supply their own fonts; licensing is their responsibility.
ab5e05c to
6adbe9c
Compare
Summary
.system/res/and they appear in the Settings font pickerminuisettings.txt(font=0for OG,font=1for Next) for backward compatibility with existing paksfont=MyFont.ttf)nextval fontalways returns an integer (default1for custom fonts); paks should usenextval fontpathfor the full pathfont=0/font=1integer values on readNote: All binaries linking
config.c(nextui, minarch, nextval, settings, clock, etc.) must be rebuilt — the settings struct changed from integer to string for the font field internally.Pak compatibility
Audited all 87 pak store repos + 3 related projects. Only 2 read the
font=setting (Apostrophe library and NextUI Updater), both parsing it as an integer. Built-in font selections remain fully compatible. Custom font selections gracefully degrade — Apostrophe-based paks fall back to the default font until updated.Test plan
.system/res/, open Settings — font appears in pickerfont=0orfont=1in settings file still work