Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Localize font family names if possible.
Wolthera van Hövell tot Westerflier0e856264fe47
diff --git a/libs/flake/resources/KoFontFamily.cpp b/libs/flake/resources/KoFontFamily.cppindex aac96ceef9..5b658e9a66 100644--- a/libs/flake/resources/KoFontFamily.cpp+++ b/libs/flake/resources/KoFontFamily.cpp@@ -79,8 +79,9 @@ QString generateSVG(QString sample, QString fontFamily) {return QString::fromUtf8(buffer.data());}-QHash<QString, QVariant> localeHashtoVariantHash(QHash<QLocale, QString> names) {- QHash<QString, QVariant> newNames;+QMap<QString, QVariant> localeHashtoVariantMap(QHash<QLocale, QString> names) {+ // Needs to be a map to be accessible in qml (see https://bugreports.qt.io/browse/QTBUG-62014)+ QMap<QString, QVariant> newNames;Q_FOREACH(const QLocale key, names.keys()) {newNames.insert(key.bcp47Name(), QVariant::fromValue(names.value(key)));}@@ -94,9 +95,9 @@ KoFontFamily::KoFontFamily(KoFontFamilyWWSRepresentation representation){setName(representation.fontFamilyName);addMetaData(TYPOGRAPHIC_NAME, representation.typographicFamilyName);- addMetaData(LOCALIZED_FONT_FAMILY, localeHashtoVariantHash(representation.localizedFontFamilyNames));- addMetaData(LOCALIZED_TYPOGRAPHIC_NAME, localeHashtoVariantHash(representation.localizedTypographicFamily));- addMetaData(LOCALIZED_TYPOGRAPHIC_STYLE, localeHashtoVariantHash(representation.localizedTypographicStyles));+ addMetaData(LOCALIZED_FONT_FAMILY, localeHashtoVariantMap(representation.localizedFontFamilyNames));+ addMetaData(LOCALIZED_TYPOGRAPHIC_NAME, localeHashtoVariantMap(representation.localizedTypographicFamily));+ addMetaData(LOCALIZED_TYPOGRAPHIC_STYLE, localeHashtoVariantMap(representation.localizedTypographicStyles));QVariantHash samples;Q_FOREACH(const QLocale::Script &key, representation.sampleStrings.keys()) {diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cppindex a141cb0c49..b18e7d79aa 100644--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp@@ -132,8 +132,10 @@ TextPropertiesDock::TextPropertiesDock()d->tagModel = new KisTagModel(ResourceType::FontFamilies);QList<QLocale> locales;+ QStringList wellFormedBCPNames;Q_FOREACH (const QString langCode, KLocalizedString::languages()) {locales.append(QLocale(langCode));+ wellFormedBCPNames.append(langCode.split("_").join("-"));}d->axesModel.setLocales(locales);d->stylesModel.setLocales(locales);@@ -146,6 +148,7 @@ TextPropertiesDock::TextPropertiesDock()m_quickWidget->rootContext()->setContextProperty("fontTagModel", QVariant::fromValue(d->tagModel));m_quickWidget->rootContext()->setContextProperty("fontStylesModel", QVariant::fromValue(&d->stylesModel));m_quickWidget->rootContext()->setContextProperty("fontAxesModel", QVariant::fromValue(&d->axesModel));+ m_quickWidget->rootContext()->setContextProperty("locales", QVariant::fromValue(wellFormedBCPNames));connect(d->textModel, SIGNAL(textPropertyChanged()),this, SLOT(slotTextPropertiesChanged()));m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);diff --git a/plugins/dockers/textproperties/qml/FontFamily.qml b/plugins/dockers/textproperties/qml/FontFamily.qmlindex 7788013e4b..89601f524f 100644--- a/plugins/dockers/textproperties/qml/FontFamily.qml+++ b/plugins/dockers/textproperties/qml/FontFamily.qml@@ -67,23 +67,35 @@ CollapsibleGroupProperty {highlighted: mainFamilyCmb.highlightedIndex === model.index;contentItem: KoShapeQtQuickLabel{id: fontFamilyDelegate;- property bool colorBitmap : model.metadata["color_bitmap"];- property bool colorCLRV0 : model.metadata["color_clrv0"];- property bool colorCLRV1 : model.metadata["color_clrv1"];- property bool colorSVG : model.metadata["color_svg"];- property bool isVariable : model.metadata["is_variable"];- property int type : model.metadata["font_type"];+ property bool colorBitmap : model.metadata.color_bitmap;+ property bool colorCLRV0 : model.metadata.color_clrv0;+ property bool colorCLRV1 : model.metadata.color_clrv1;+ property bool colorSVG : model.metadata.color_svg;+ property bool isVariable : model.metadata.is_variable;+ property int type : model.metadata.font_type;+ property string fontName: model.name;Layout.fillWidth: true;- svgData: model.metadata["sample_svg"];+ svgData: model.metadata.sample_svg;imageScale: 3;imagePadding: nameLabel.height;foregroundColor: sysPalette.text;fullColor: colorBitmap || colorCLRV0 || colorCLRV1 || colorSVG;+ Component.onCompleted: {+ var localizedDict = model.metadata.localized_font_family;+ for (var i in locales) {+ var key = locales[i];+ if (key in localizedDict) {+ fontName = localizedDict[key];+ break;+ }+ }+ }+Label {id: nameLabel;- text: model.name;+ text: fontFamilyDelegate.fontName;anchors.top: parent.top;anchors.left: parent.left;}