Krita Source Code Documentation
Loading...
Searching...
No Matches
KoWritingSystemUtils.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KOWRITINGSYSTEMUTILS_H
7#define KOWRITINGSYSTEMUTILS_H
8
9#include <QFontDatabase>
10#include <QLocale>
11#include <kritaflake_export.h>
19class KRITAFLAKE_EXPORT KoWritingSystemUtils
20{
21public:
22 static QString scriptTagForWritingSystem(QFontDatabase::WritingSystem system);
23 static QFontDatabase::WritingSystem writingSystemForScriptTag(const QString &tag);
24
25 // Qt6 has a function to get the ISO 15924 for the QLocale::Script, but we're not qt 6 yet...
26 static QString scriptTagForQLocaleScript(QLocale::Script script);
27 static QLocale::Script scriptForScriptTag(const QString &tag);
28
29 static QString scriptTagForQCharScript(QChar::Script script);
30 static QChar::Script qCharScriptForScriptTag(const QString &tag);
31
38 static QMap<QString, QString> samples();
39
40 static QString sampleTagForQLocale(const QLocale &locale);
41
50 struct KRITAFLAKE_EXPORT Bcp47Locale {
52 QString scriptTag;
53 QString regionTag;
57
58 bool isValid() const;
59 QString toPosixLocaleFormat() const;
60 QString toString() const;
61 };
62
63 // Parse a BCP 47 string into a locale;
64 static Bcp47Locale parseBcp47Locale(const QString &locale);
65
66 // Return a QLocale for a bcp 47 locale struct.
67 static QLocale localeFromBcp47Locale(const Bcp47Locale &locale);
68
69 // Return a QLocale by parsing a BCP 47 string into a struct and constructing the QLocale from that.
70 static QLocale localeFromBcp47Locale(const QString &locale);
71};
72
73#endif // KOWRITINGSYSTEMUTILS_H
The KoScriptUtils class.
The Bcp47Locale class This holds a parsed BCP47 locale. QLocale is primarily made for POSIX locale fo...