diff --git a/app/common/html.cpp b/app/common/html.cpp
index 143d76544..74cc805f9 100644
--- a/app/common/html.cpp
+++ b/app/common/html.cpp
@@ -208,8 +208,9 @@ void Html::WriteCSSProperty(QString *style, const QString &key, const QStringLis
void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt)
{
- if (!fmt.fontFamily().isEmpty()) {
- WriteCSSProperty(style, QStringLiteral("font-family"), fmt.fontFamily());
+ QStringList families = fmt.fontFamilies().toStringList();
+ if (!families.isEmpty()) {
+ WriteCSSProperty(style, QStringLiteral("font-family"), families.first());
}
if (fmt.hasProperty(QTextFormat::FontPointSize)) {
@@ -287,7 +288,7 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes)
const QString &first_val = it.value().first();
if (it.key() == QStringLiteral("font-family")) {
- fmt.setFontFamily(first_val);
+ fmt.setFontFamilies({first_val});
} else if (it.key() == QStringLiteral("font-size")) {
if (first_val.endsWith(QStringLiteral("pt"), Qt::CaseInsensitive)) {
fmt.setFontPointSize(first_val.chopped(2).toDouble());
diff --git a/app/widget/viewer/viewertexteditor.cpp b/app/widget/viewer/viewertexteditor.cpp
index 99da81967..06a41afb4 100644
--- a/app/widget/viewer/viewertexteditor.cpp
+++ b/app/widget/viewer/viewertexteditor.cpp
@@ -152,15 +152,16 @@ void ViewerTextEditor::paintEvent(QPaintEvent *e)
void ViewerTextEditor::UpdateToolBar(ViewerTextEditorToolBar *toolbar, const QTextCharFormat &f, const QTextBlockFormat &b, Qt::Alignment alignment)
{
- QFontDatabase fd;
-
- QString family = f.fontFamily();
- if (family.isEmpty()) {
+ QStringList families = f.fontFamilies().toStringList();
+ QString family;
+ if (families.isEmpty()) {
family = qApp->font().family();
+ } else {
+ family = families.first();
}
QString style = f.fontStyleName().toString();
- QStringList styles = fd.styles(family);
+ QStringList styles = QFontDatabase::styles(family);
if (!styles.isEmpty() && (style.isEmpty() || !styles.contains(style))) {
// There seems to be no better way to find the "regular" style outside of this heuristic.
// Feel free to add more if a font isn't working right.