Support for Retina screens.

This commit is contained in:
Roman Telezhynskyi 2024-02-23 15:35:21 +02:00
parent c69267466e
commit ae59938dc9

View File

@ -353,8 +353,8 @@ void PreferencesPatternPage::InitSingleLineFonts()
const qreal dpiY = primaryScreen->physicalDotsPerInchY();
const qreal scale = primaryScreen->devicePixelRatio();
int previewWidth = 128;
int previewHeight = QFontMetrics(QGuiApplication::font()).height() / 2;
int const previewWidth = qRound(250. / scale);
int const previewHeight = qRound(QFontMetrics(QGuiApplication::font()).height() / scale);
// Calculate the desired image size in physical pixels
const int desiredWidthInPixels = qRound(previewWidth * dpiX / 96.0);
@ -368,7 +368,7 @@ void PreferencesPatternPage::InitSingleLineFonts()
ui->comboBoxSingleLineFont->setMinimumSize(QSize(previewScaledWidthPixels, 0));
ui->comboBoxSingleLineFont->setIconSize(QSize(previewScaledWidthPixels, previewScaledHeightPixels));
QPen pen(Qt::SolidPattern, 1, Qt::SolidLine, Qt::RoundCap, Qt::SvgMiterJoin);
QPen pen(Qt::SolidPattern, 1 * scale, Qt::SolidLine, Qt::RoundCap, Qt::SvgMiterJoin);
pen.setColor(ui->comboBoxSingleLineFont->palette().color(QPalette::Text));
VSvgFontDatabase *db = VAbstractApplication::VApp()->SVGFontDatabase();
@ -377,7 +377,7 @@ void PreferencesPatternPage::InitSingleLineFonts()
for (const auto &family : families)
{
VSvgFontEngine engine = db->FontEngine(family, SVGFontStyle::Normal, SVGFontWeight::Thin);
VSvgFontEngine engine = db->FontEngine(family, SVGFontStyle::Normal, SVGFontWeight::Normal);
VSvgFont const svgFont = engine.Font();
if (!svgFont.IsValid())
@ -396,7 +396,6 @@ void PreferencesPatternPage::InitSingleLineFonts()
engine.Draw(&painter, QPointF(0, 0), engine.FontSample());
ui->comboBoxSingleLineFont->addItem(pixmap, svgFont.FamilyName(), svgFont.FamilyName());
}
ui->comboBoxSingleLineFont->setInsertPolicy(QComboBox::NoInsert);