[Fonts] Resolve CardText sizes against the shipped theme

Seeding themes/<name>/fonts.toml made getAvailableThemes() resolve the user dir, which shadowed the shipped theme.cfg and stylesheet: styleName came back empty and QSS was cleared. Fall back to the shipped theme dir for theme.cfg and QSS when the user dir exists, and resolve CardText sizes through FontConfig's 6..72 range so a migrated 80..100 renders at the size the editor shows. Insert CardTextMaxSize inside [Fonts] when another section follows.
This commit is contained in:
Lukas Brübach 2026-11-07 19:02:51 +01:00
parent 8f2e2339e8
commit d8f7f3bfac
10 changed files with 416 additions and 80 deletions

View file

@ -136,12 +136,30 @@ struct PaletteConfig
*/
struct FontConfig
{
/// Point-size range the theme font editor can represent. CardText is
/// resolved through the same bounds where it is rendered, so the board never
/// draws a size the editor cannot show and would clamp away on save.
static constexpr int MIN_FONT_SIZE = 6;
static constexpr int MAX_FONT_SIZE = 72;
/// CardText shrink-to-fit floor, editable below the general font floor.
static constexpr int CARD_TEXT_MIN_SIZE = 1;
/// CardText size when neither CardTextMaxSize nor a CardText family is set.
static constexpr int DEFAULT_CARD_TEXT_SIZE = 12;
QMap<AppFont::Role, QFont> fonts;
int cardTextMinSize = 1;
int cardTextMinSize = CARD_TEXT_MIN_SIZE;
/// Optional size-only maximum for CardText, used by the retired maxFontSize
/// migration so seeding it does not have to pin a family.
int cardTextMaxSize = 0;
/// CardText min/max resolved to what the font editor shows and a save would
/// write: the stored values (max falling back to the CardText point size,
/// then the default) clamped into the representable range. A seeded legacy
/// size above the editor's maximum therefore renders at that maximum instead
/// of at a size the editor would silently rewrite.
int resolvedCardTextMinSize() const;
int resolvedCardTextMaxSize() const;
bool operator==(const FontConfig &rhs) const
{
return fonts == rhs.fonts && cardTextMinSize == rhs.cardTextMinSize && cardTextMaxSize == rhs.cardTextMaxSize;