Skip to content

Commit

Permalink
uic: Generate QFont::HintingPreference
Browse files Browse the repository at this point in the history
Task-number: QTBUG-113670
Pick-to: 6.5
Change-Id: I326d310b2a0df9a6f11e33588e553dff66e5a6f4
Reviewed-by: Jarek Kobus <[email protected]>
  • Loading branch information
FriedemannKleint committed May 23, 2023
1 parent 67b8dec commit bfa557d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/tools/uic/cpp/cppwriteinitialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ int FontHandle::compare(const FontHandle &rhs) const
if (const int src = styleStrategy.compare(rhsStyleStrategy))
return src;

const QString hintingPreference = m_domFont->hasElementHintingPreference()
? m_domFont->elementHintingPreference() : QString();
const QString rhsHintingPreference = rhs.m_domFont->hasElementHintingPreference()
? rhs.m_domFont->elementHintingPreference() : QString();
if (const int src = hintingPreference.compare(rhsHintingPreference))
return src;

return 0;
}

Expand Down Expand Up @@ -1657,6 +1664,11 @@ QString WriteInitialization::writeFontProperties(const DomFont *f)
m_output << m_indent << fontName << ".setStyleStrategy(QFont"
<< language::qualifier << f->elementStyleStrategy() << ')' << language::eol;
}
if (f->hasElementHintingPreference()) {
m_output << m_indent << fontName << ".setHintingPreference(QFont"
<< language::qualifier << f->elementHintingPreference() << ')' << language::eol;
}

return fontName;
}

Expand Down
18 changes: 18 additions & 0 deletions src/tools/uic/ui4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3121,6 +3121,10 @@ void DomFont::read(QXmlStreamReader &reader)
setElementKerning(reader.readElementText() == u"true"_s);
continue;
}
if (!tag.compare(u"hintingpreference"_s, Qt::CaseInsensitive)) {
setElementHintingPreference(reader.readElementText());
continue;
}
reader.raiseError("Unexpected element "_L1 + tag);
}
break;
Expand Down Expand Up @@ -3166,6 +3170,9 @@ void DomFont::write(QXmlStreamWriter &writer, const QString &tagName) const
if (m_children & Kerning)
writer.writeTextElement(u"kerning"_s, (m_kerning ? u"true"_s : u"false"_s));

if (m_children & HintingPreference)
writer.writeTextElement(u"hintingpreference"_s, m_hintingPreference);

writer.writeEndElement();
}

Expand Down Expand Up @@ -3229,6 +3236,12 @@ void DomFont::setElementKerning(bool a)
m_kerning = a;
}

void DomFont::setElementHintingPreference(const QString &a)
{
m_children |= HintingPreference;
m_hintingPreference = a;
}

void DomFont::clearElementFamily()
{
m_children &= ~Family;
Expand Down Expand Up @@ -3279,6 +3292,11 @@ void DomFont::clearElementKerning()
m_children &= ~Kerning;
}

void DomFont::clearElementHintingPreference()
{
m_children &= ~HintingPreference;
}

DomPoint::~DomPoint() = default;

void DomPoint::read(QXmlStreamReader &reader)
Expand Down
9 changes: 8 additions & 1 deletion src/tools/uic/ui4.h
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,11 @@ class QDESIGNER_UILIB_EXPORT DomFont {
inline bool hasElementKerning() const { return m_children & Kerning; }
void clearElementKerning();

inline QString elementHintingPreference() const { return m_hintingPreference; }
void setElementHintingPreference(const QString &a);
inline bool hasElementHintingPreference() const { return m_children & HintingPreference; }
void clearElementHintingPreference();

private:

// child element data
Expand All @@ -1659,6 +1664,7 @@ class QDESIGNER_UILIB_EXPORT DomFont {
bool m_antialiasing = false;
QString m_styleStrategy;
bool m_kerning = false;
QString m_hintingPreference;

enum Child {
Family = 1,
Expand All @@ -1670,7 +1676,8 @@ class QDESIGNER_UILIB_EXPORT DomFont {
StrikeOut = 64,
Antialiasing = 128,
StyleStrategy = 256,
Kerning = 512
Kerning = 512,
HintingPreference = 1024
};
};

Expand Down

0 comments on commit bfa557d

Please sign in to comment.