Krita Source Code Documentation
Loading...
Searching...
No Matches
KoFontRegistry.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KOFONTREGISTRY_H
7#define KOFONTREGISTRY_H
8
9#include <QObject>
10#include <QScopedPointer>
11#include <QVector>
12
14#include <KoFFWWSConverter.h>
15
16#include "KoCSSFontInfo.h"
17#include "kritaflake_export.h"
18
30class KRITAFLAKE_EXPORT KoFontRegistry: public QObject
31{
32 Q_OBJECT
33public:
34 KoFontRegistry(QObject *parent = nullptr);
36
37 static KoFontRegistry *instance();
38
49 std::vector<FT_FaceSP> facesForCSSValues(QVector<int> &lengths,
51 const QString &text = "",
52 quint32 xRes = 72,
53 quint32 yRes = 72,
54 bool disableFontMatching = false,
55 const QString &language = QString());
56
67 bool configureFaces(const std::vector<FT_FaceSP> &faces,
68 qreal size,
69 qreal fontSizeAdjust,
70 quint32 xRes,
71 quint32 yRes,
72 const QMap<QString, qreal> &axisSettings);
73
78 QList<KoFontFamilyWWSRepresentation> collectRepresentations() const;
79
87 std::optional<KoFontFamilyWWSRepresentation> representationByFamilyName(const QString &familyName) const;
88
89 // Get the closest font family resource name for a given font family name, used by the selectors.
90 std::optional<QString> wwsNameByFamilyName(const QString familyName) const;
91
98 static QFont::Style slantMode(FT_FaceSP face);
99
100 KoSvgText::FontMetrics fontMetricsForCSSValues(KoCSSFontInfo info = KoCSSFontInfo(),
101 const bool isHorizontal = true,
103 const QString &text = "",
104 quint32 xRes = 72,
105 quint32 yRes = 72,
106 bool disableFontMatching = false,
107 const QString &language = QString());
108
109 static KoSvgText::FontMetrics generateFontMetrics(FT_FaceSP face, bool isHorizontal = true, QString script = QString(), const KoSvgText::TextRendering rendering = KoSvgText::RenderingAuto);
110
111 static int32_t loadFlagsForFace(FT_Face face, bool isHorizontal = true, int32_t loadFlags = 0, const KoSvgText::TextRendering rendering = KoSvgText::RenderingAuto);
112
113 // For PSD we only get the postscript name, and we'll need a bit
114 // more information to get a proper css representation.
115 KoCSSFontInfo getCssDataForPostScriptName (const QString postScriptName,
116 QString *foundPostScriptName);
117private Q_SLOTS:
122private:
123 class Private;
124
125 friend class TestSvgText;
126 friend class SvgTextCursorTest;
127
135 bool addFontFilePathToRegistry(const QString &path);
136
143 bool addFontFileDirectoryToRegistry(const QString &path);
144
145 QScopedPointer<Private> d;
146
148};
149
150#endif // KOFONTREGISTRY_H
PythonPluginManager * instance
The KoFontRegistry class A wrapper around a freetype library.
QScopedPointer< Private > d
Q_DISABLE_COPY(KoFontRegistry)
void updateConfig()
@ RenderingAuto
Definition KoSvgText.h:315
The KoCSSFontInfo class Convenience struct to make it easier to use KoFontRegistry....
The FontMetrics class A class to keep track of a variety of font metrics. Note that values are in Fre...
Definition KoSvgText.h:327