Skip to content

Commit

Permalink
use QFont::pointSizeF() for fractional pixel font size
Browse files Browse the repository at this point in the history
  • Loading branch information
mnutt committed Jul 31, 2023
1 parent f2789a6 commit 676bb0d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ QFont FontCascade::syntheticFont() const
QRawFont rawFont(primaryFont().getQtRawFont());
QFont f(rawFont.familyName());
if (rawFont.pixelSize())
f.setPixelSize(rawFont.pixelSize());
f.setPointSizeF(rawFont.pixelSize());
f.setWeight(rawFont.weight());
f.setStyle(rawFont.style());
if (m_letterSpacing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription&
{
Q_ASSERT(m_rawFont.isValid());
auto size = description.computedSize();
m_rawFont.setPixelSize(qreal(size));
m_rawFont.setPixelSize(size);
return FontPlatformData(m_rawFont);
}

Expand Down
9 changes: 5 additions & 4 deletions Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static inline QFont::Weight toQFontWeight(FontSelectionValue fontWeight)

void FontPlatformDataPrivate::platformDataInit(FontPlatformData& q, float size, const QRawFont& rawFont)
{
// ASSERT(qFuzzyCompare(static_cast<float>(rawFont.pixelSize()), size));
// ASSERT(qFuzzyCompare(static_cast<float>(rawFont.pointSizeF()), size));
q.m_data = adoptRef(new FontPlatformDataPrivate(rawFont));
q.updateSize(size);
}
Expand All @@ -81,7 +81,7 @@ FontPlatformData::FontPlatformData(const FontDescription& description, const Ato
auto requestedSize = description.computedSize();
font.setFamily(familyName.string());
if (requestedSize)
font.setPixelSize(requestedSize);
font.setPointSizeF(requestedSize);
font.setItalic(isItalic(description.italic()));
font.setWeight(toQFontWeight(description.weight()));

Expand All @@ -91,9 +91,9 @@ FontPlatformData::FontPlatformData(const FontDescription& description, const Ato
font.setStyleStrategy(QFont::ForceOutline);

// WebKit allows font size zero but QFont does not. We will return
// m_data->size if a font size of zero is requested and pixelSize()
// m_data->size if a font size of zero is requested and pointSizeF()
// otherwise.
auto size = (!requestedSize) ? requestedSize : font.pixelSize();
auto size = (!requestedSize) ? requestedSize : font.pointSizeF();
FontPlatformDataPrivate::platformDataInit(*this, size, QRawFont::fromFont(font, QFontDatabase::Any));
}

Expand All @@ -115,6 +115,7 @@ FontPlatformData FontPlatformData::cloneWithSize(const FontPlatformData& source,
void FontPlatformData::updateSize(float size)
{
m_size = size;
m_data->rawFont.setPixelSize(size);
}

QRawFont FontPlatformData::rawFont() const
Expand Down

0 comments on commit 676bb0d

Please sign in to comment.