| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QPLATFORMFONTDATABASE_H |
| 5 | #define QPLATFORMFONTDATABASE_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is part of the QPA API and is not meant to be used |
| 12 | // in applications. Usage of this API may make your code |
| 13 | // source and binary incompatible with future versions of Qt. |
| 14 | // |
| 15 | |
| 16 | #include <QtGui/qtguiglobal.h> |
| 17 | #include <QtCore/qloggingcategory.h> |
| 18 | #include <QtCore/QString> |
| 19 | #include <QtCore/QStringList> |
| 20 | #include <QtCore/QList> |
| 21 | #include <QtGui/QFontDatabase> |
| 22 | #include <QtGui/private/qfontengine_p.h> |
| 23 | #include <QtGui/private/qfont_p.h> |
| 24 | #include <QtGui/private/qfontdatabase_p.h> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcQpaFonts, Q_GUI_EXPORT) |
| 29 | |
| 30 | class QWritingSystemsPrivate; |
| 31 | |
| 32 | class Q_GUI_EXPORT QSupportedWritingSystems |
| 33 | { |
| 34 | public: |
| 35 | |
| 36 | QSupportedWritingSystems(); |
| 37 | QSupportedWritingSystems(const QSupportedWritingSystems &other); |
| 38 | QSupportedWritingSystems &operator=(const QSupportedWritingSystems &other); |
| 39 | ~QSupportedWritingSystems(); |
| 40 | |
| 41 | void setSupported(QFontDatabase::WritingSystem, bool supported = true); |
| 42 | bool supported(QFontDatabase::WritingSystem) const; |
| 43 | |
| 44 | private: |
| 45 | void detach(); |
| 46 | |
| 47 | QWritingSystemsPrivate *d; |
| 48 | |
| 49 | friend Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &); |
| 50 | friend Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &); |
| 51 | #ifndef QT_NO_DEBUG_STREAM |
| 52 | friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &); |
| 53 | #endif |
| 54 | }; |
| 55 | |
| 56 | Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &); |
| 57 | Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &); |
| 58 | |
| 59 | #ifndef QT_NO_DEBUG_STREAM |
| 60 | Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &); |
| 61 | #endif |
| 62 | |
| 63 | class QFontRequestPrivate; |
| 64 | class QFontEngineMulti; |
| 65 | |
| 66 | class Q_GUI_EXPORT QPlatformFontDatabase |
| 67 | { |
| 68 | public: |
| 69 | virtual ~QPlatformFontDatabase(); |
| 70 | virtual void populateFontDatabase(); |
| 71 | virtual bool populateFamilyAliases(const QString &missingFamily) { Q_UNUSED(missingFamily); return false; } |
| 72 | virtual void populateFamily(const QString &familyName); |
| 73 | virtual void invalidate(); |
| 74 | |
| 75 | virtual QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const; |
| 76 | virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *font = nullptr); |
| 77 | |
| 78 | virtual QFontEngine *fontEngine(const QFontDef &fontDef, void *handle); |
| 79 | virtual QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference); |
| 80 | virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script); |
| 81 | virtual void releaseHandle(void *handle); |
| 82 | |
| 83 | virtual QString fontDir() const; |
| 84 | |
| 85 | virtual QFont defaultFont() const; |
| 86 | virtual bool isPrivateFontFamily(const QString &family) const; |
| 87 | |
| 88 | virtual QString resolveFontFamilyAlias(const QString &family) const; |
| 89 | virtual bool fontsAlwaysScalable() const; |
| 90 | virtual QList<int> standardSizes() const; |
| 91 | |
| 92 | virtual bool supportsVariableApplicationFonts() const; |
| 93 | |
| 94 | // helper |
| 95 | static QSupportedWritingSystems writingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 [2]); |
| 96 | static QSupportedWritingSystems writingSystemsFromOS2Table(const char *os2Table, size_t length); |
| 97 | |
| 98 | //callback |
| 99 | static void registerFont(const QString &familyname, const QString &stylename, |
| 100 | const QString &foundryname, QFont::Weight weight, |
| 101 | QFont::Style style, QFont::Stretch stretch, bool antialiased, |
| 102 | bool scalable, int pixelSize, bool fixedPitch, |
| 103 | const QSupportedWritingSystems &writingSystems, void *handle); |
| 104 | |
| 105 | static void registerFontFamily(const QString &familyName); |
| 106 | static void registerAliasToFontFamily(const QString &familyName, const QString &alias); |
| 107 | |
| 108 | static void repopulateFontDatabase(); |
| 109 | |
| 110 | static bool isFamilyPopulated(const QString &familyName); |
| 111 | }; |
| 112 | |
| 113 | QT_END_NAMESPACE |
| 114 | |
| 115 | #endif // QPLATFORMFONTDATABASE_H |
| 116 | |