mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-07 10:33:24 -08:00
[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:
parent
e87cd80c9b
commit
47bb103a87
9 changed files with 415 additions and 79 deletions
|
|
@ -282,6 +282,42 @@ TEST(FontConfigTest, CardTextMaxSizeWithoutFamily)
|
|||
EXPECT_EQ(loaded, cfg);
|
||||
}
|
||||
|
||||
TEST(FontConfigTest, MigratedCardTextMaxResolvesIntoTheEditorsRange)
|
||||
{
|
||||
// appearance/maxFontSize came from a control that allowed values above 72
|
||||
// and the migration seeds it verbatim, so fonts.toml can hold a size the
|
||||
// font editor cannot show. 72 is what the editor displays and would save,
|
||||
// so the board has to draw 72 too instead of rendering 100 until the next
|
||||
// save silently rewrites the theme.
|
||||
QTemporaryDir tmp;
|
||||
ASSERT_TRUE(tmp.isValid());
|
||||
const QString filePath = writeTempFile(tmp, "fonts.toml", "[Fonts]\nCardTextMaxSize = 100\n");
|
||||
|
||||
const FontConfig migrated = FontConfig::fromFile(filePath);
|
||||
ASSERT_EQ(migrated.cardTextMaxSize, 100);
|
||||
EXPECT_EQ(migrated.resolvedCardTextMaxSize(), 72);
|
||||
}
|
||||
|
||||
TEST(FontConfigTest, CardTextSizesResolveIntoTheEditorsRange)
|
||||
{
|
||||
// The same bound applies when the size comes from the CardText family, a
|
||||
// stored size below the editor's control floor rises to it, and the max is
|
||||
// never below the resolved shrink-to-fit floor.
|
||||
FontConfig fromFamily;
|
||||
fromFamily.fonts[AppFont::CardText] = makeFont("Noto Serif", 100);
|
||||
EXPECT_EQ(fromFamily.resolvedCardTextMaxSize(), 72);
|
||||
|
||||
FontConfig belowFloor;
|
||||
belowFloor.cardTextMaxSize = 3;
|
||||
EXPECT_EQ(belowFloor.resolvedCardTextMaxSize(), 6);
|
||||
|
||||
FontConfig narrow;
|
||||
narrow.cardTextMinSize = 20;
|
||||
narrow.cardTextMaxSize = 12;
|
||||
EXPECT_EQ(narrow.resolvedCardTextMinSize(), 20);
|
||||
EXPECT_EQ(narrow.resolvedCardTextMaxSize(), 20);
|
||||
}
|
||||
|
||||
TEST(FontConfigTest, CardTextMaxDefaultIsOmitted)
|
||||
{
|
||||
FontConfig cfg;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue