[Fonts] Migrate CardText surfaces to theme font role (#7538)

* [Fonts] Migrate CardText surfaces to theme font role

* [Fonts] Keep CardText call sites on the app font and fix px sizes

- CardText's unset fallback is qApp->font() again: only the three counter
  painters (paintNumberEllipse, GeneralCounter, PlayerCounter) were Serif
  before the role existed, and they now ask for it through
  ThemeManager::cardTextFont(). Card names, player names, counters, the
  overlay, the Archidekt and EDHREC labels and the completer delegate keep the
  app font they used before.
- Use setPixelSize for the EDHREC card name (20px) and commander name (28px)
  and details (16px) sizes: the stylesheets said px, and setPointSize made
  them about a third larger.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-11-04 07:57:54 +01:00 • committed by GitHub
parent 7a40ed9079
commit 396196b762
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 140 additions and 35 deletions

View file

@ -1,5 +1,6 @@
#include "archidekt_deck_preview_image_display_widget.h"
#include "../../../../../theme_manager.h"
#include "../../../../general/display/shadow_background_label.h"
#include <QFont>
@ -17,13 +18,9 @@ ArchidektDeckPreviewImageDisplayWidget::ArchidektDeckPreviewImageDisplayWidget(Q
bottomLeftLabel = new ShadowBackgroundLabel(this, "");
bottomRightLabel = new ShadowBackgroundLabel(this, "");
QFont f;
f.setBold(true);
f.setPointSize(16);
topLeftLabel->setFont(f);
topRightLabel->setFont(f);
bottomLeftLabel->setFont(f);
bottomRightLabel->setFont(f);
applyCardTextFont();
connect(themeManager, &ThemeManager::fontsChanged, this,
&ArchidektDeckPreviewImageDisplayWidget::applyCardTextFont);
// Raise so labels appear above image
topLeftLabel->raise();
@ -32,6 +29,18 @@ ArchidektDeckPreviewImageDisplayWidget::ArchidektDeckPreviewImageDisplayWidget(Q
bottomRightLabel->raise();
}
void ArchidektDeckPreviewImageDisplayWidget::applyCardTextFont()
{
// Family comes from the CardText theme role; size and weight stay caller-side as before.
QFont f = themeManager->appFont(AppFont::CardText);
f.setBold(true);
f.setPointSize(16);
topLeftLabel->setFont(f);
topRightLabel->setFont(f);
bottomLeftLabel->setFont(f);
bottomRightLabel->setFont(f);
}
void ArchidektDeckPreviewImageDisplayWidget::setAspectRatio(float ratio)
{
aspectRatio = ratio;

View file

@ -60,6 +60,9 @@ protected:
*/
void resizeEvent(QResizeEvent *event) override;
private slots:
void applyCardTextFont();
private:
float aspectRatio = 1.0f; ///< Aspect ratio to maintain for the preview image
};

View file

@ -1,5 +1,6 @@
#include "edhrec_api_response_card_details_display_widget.h"
#include "../../../../../../theme_manager.h"
#include "../../../../../cards/card_info_picture_widget.h"
#include "../../../../../cards/card_size_widget.h"
#include "../../../../../general/display/background_plate_widget.h"
@ -9,6 +10,7 @@
#include "edhrec_api_response_card_synergy_display_widget.h"
#include "libcockatrice/card/database/card_database_querier.h"
#include <QFont>
#include <QLabel>
#include <QMouseEvent>
#include <QObject>
@ -32,7 +34,9 @@ EdhrecApiResponseCardDetailsDisplayWidget::EdhrecApiResponseCardDetailsDisplayWi
nameLabel = new QLabel(this);
nameLabel->setText(toDisplay.name);
nameLabel->setAlignment(Qt::AlignHCenter);
nameLabel->setStyleSheet("font-size: 20px; font-weight: bold");
applyCardTextFont();
connect(themeManager, &ThemeManager::fontsChanged, this,
&EdhrecApiResponseCardDetailsDisplayWidget::applyCardTextFont);
inclusionDisplayWidget = new EdhrecApiResponseCardInclusionDisplayWidget(this, toDisplay);
@ -86,3 +90,14 @@ void EdhrecApiResponseCardDetailsDisplayWidget::actRequestPageNavigation()
{
emit requestUrl(toDisplay.url);
}
void EdhrecApiResponseCardDetailsDisplayWidget::applyCardTextFont()
{
// Family comes from the CardText theme role; the 20px size and bold
// weight previously carried by the stylesheet stay caller-side. Pixel
// size, not point size: the stylesheet said 20px, and 20pt is ~27px.
QFont cardFont = themeManager->appFont(AppFont::CardText);
cardFont.setPixelSize(20);
cardFont.setWeight(QFont::Bold);
nameLabel->setFont(cardFont);
}

View file

@ -30,6 +30,9 @@ public slots:
signals:
void requestUrl(QString url);
private slots:
void applyCardTextFont();
private:
EdhrecApiResponseCardDetails toDisplay;
QVBoxLayout *layout;

View file

@ -1,5 +1,6 @@
#include "edhrec_api_response_commander_details_display_widget.h"
#include "../../../../../../theme_manager.h"
#include "../../../../../cards/card_info_picture_widget.h"
#include "../../../../../cards/card_size_widget.h"
#include "../../api_response/cards/edhrec_commander_api_response_commander_details.h"
@ -8,6 +9,7 @@
#include "edhrec_commander_api_response_navigation_widget.h"
#include "libcockatrice/card/database/card_database_querier.h"
#include <QFont>
#include <QHBoxLayout>
#include <QLabel>
#include <QObject>
@ -48,15 +50,16 @@ EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCom
commanderName = new QLabel(this);
commanderName->setText(commanderDetails.getName());
commanderName->setAlignment(Qt::AlignCenter);
commanderName->setStyleSheet("font-size: 28px; font-weight: bold");
label = new QLabel(this);
label->setAlignment(Qt::AlignCenter);
label->setStyleSheet("font-size: 16px");
salt = new QLabel(this);
salt->setAlignment(Qt::AlignCenter);
salt->setStyleSheet("font-size: 16px");
applyCardTextFont();
connect(themeManager, &ThemeManager::fontsChanged, this,
&EdhrecCommanderResponseCommanderDetailsDisplayWidget::applyCardTextFont);
cardPricesDisplayWidget = new EdhrecApiResponseCardPricesDisplayWidget(this, commanderDetails.getPrices());
@ -83,3 +86,19 @@ void EdhrecCommanderResponseCommanderDetailsDisplayWidget::retranslateUi()
label->setText(commanderDetails.getLabel());
salt->setText(tr("Salt: ") + QString::number(commanderDetails.getSalt()));
}
void EdhrecCommanderResponseCommanderDetailsDisplayWidget::applyCardTextFont()
{
// Family comes from the CardText theme role; the sizes and the bold
// weight previously carried by the stylesheets stay caller-side. Pixel
// sizes, not point sizes: the stylesheets said 28px and 16px.
QFont nameFont = themeManager->appFont(AppFont::CardText);
nameFont.setPixelSize(28);
nameFont.setWeight(QFont::Bold);
commanderName->setFont(nameFont);
QFont detailsFont = themeManager->appFont(AppFont::CardText);
detailsFont.setPixelSize(16);
label->setFont(detailsFont);
salt->setFont(detailsFont);
}

View file

@ -30,6 +30,9 @@ public:
QString baseUrl);
void retranslateUi();
private slots:
void applyCardTextFont();
private:
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
QHBoxLayout *layout;