6#include <QtGui/private/qguiapplication_p.h>
7#include <qpa/qplatformscreen.h>
10#include <QtCore/QLibraryInfo>
12#include <QtCore/QtEndian>
13#include <QtCore/QLoggingCategory>
14#include <QtCore/QUuid>
20#include FT_TRUETYPE_TABLES_H
23#include FT_MULTIPLE_MASTERS_H
24#include FT_SFNT_NAMES_H
25#include FT_TRUETYPE_IDS_H
39 qWarning(
"QFontDatabase: Cannot find font directory %s.\n"
40 "Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.",
45 static const QString nameFilters[] = {
64 faceId.
index = fontfile->indexValue;
72 memcpy(&
id, &usrPtr,
sizeof(usrPtr));
110 FT_Face
face =
reinterpret_cast<FT_Face
>(face_);
116#if (FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100 + FREETYPE_PATCH) >= 20900
117 FT_MM_Var *
var =
nullptr;
119 if (
var !=
nullptr) {
120 std::unique_ptr<FT_MM_Var,
void(*)(FT_MM_Var*)> varGuard(
var, [](FT_MM_Var *
res) {
124 for (FT_UInt
i = 0;
i <
var->num_namedstyles; ++
i) {
125 FT_UInt
id =
var->namedstyle[
i].strid;
130 for (FT_UInt axis = 0; axis <
var->num_axis; ++axis) {
136 FT_UInt ital =
var->namedstyle[
i].coords[axis] >> 16;
144 FT_UInt
count = FT_Get_Sfnt_Name_Count(
face);
145 for (FT_UInt
j = 0;
j <
count; ++
j) {
150 if (
name.name_id !=
id)
154 if (
name.encoding_id != TT_MS_ID_UNICODE_CS)
159 for (FT_UInt k = 0; k <
name.string_len; k += 2)
160 instanceName +=
QChar((
name.string[k] << 8) +
name.string[k + 1]);
161 if (instanceName != styleName) {
169 qCDebug(lcFontDb) <<
"Registering named instance" <<
i
170 <<
":" << instanceName
171 <<
"for font family" << family
172 <<
"with weight" << instanceWeight
173 <<
", style" << instanceStyle
174 <<
", stretch" << instanceStretch;
221 if (
error != FT_Err_Ok) {
225 numFaces =
face->num_faces;
230 if (
face->style_flags & FT_STYLE_FLAG_ITALIC)
233 if (
face->style_flags & FT_STYLE_FLAG_BOLD)
236 bool fixedPitch = (
face->face_flags & FT_FACE_FLAG_FIXED_WIDTH);
239 for (
int i = 0;
i <
face->num_charmaps; ++
i) {
240 FT_CharMap cm =
face->charmaps[
i];
241 if (cm->encoding == FT_ENCODING_ADOBE_CUSTOM
242 || cm->encoding == FT_ENCODING_MS_SYMBOL) {
249 TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(
face, ft_sfnt_os2);
258 quint32(os2->ulCodePageRange1),
264 if (os2->usWeightClass) {
266 }
else if (os2->panose[2]) {
267 int w = os2->panose[2];
288 switch (os2->usWidthClass) {
329 if (applicationFont !=
nullptr) {
337 applicationFont->properties.append(
properties);
340 registerFont(family, styleName,
QString(),
weight, style, stretch,
true,
true, 0, fixedPitch, writingSystems, fontFile);
342 addNamedInstancesForFace(
face,
index, family, styleName,
weight, stretch, style, fixedPitch, writingSystems,
file,
fontData);
344 families.append(family);
348 }
while (
index < numFaces);
354#if (FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100 + FREETYPE_PATCH) >= 20900
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
static QFontEngineFT * create(const QFontDef &fontDef, FaceId faceId, const QByteArray &fontData=QByteArray())
Stretch
Predefined stretch values that follow the CSS naming convention.
Weight
Qt uses a weighting scale from 1 to 1000 compatible with OpenType.
Style
This enum describes the different styles of glyphs that are used to display text.
static void addNamedInstancesForFace(void *face, int faceIndex, const QString &family, const QString &styleName, QFont::Weight weight, QFont::Stretch stretch, QFont::Style style, bool fixedPitch, const QSupportedWritingSystems &writingSystems, const QByteArray &fileName, const QByteArray &fontData)
bool supportsVariableApplicationFonts() const override
Returns true if this font database supports loading named instances from variable application fonts.
QFontEngine * fontEngine(const QFontDef &fontDef, void *handle) override
Returns the font engine that can be used to render the font described by the font definition,...
void populateFontDatabase() override
This function is called once at startup by Qt's internal font database.
static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file, QFontDatabasePrivate::ApplicationFont *applicationFont=nullptr)
void releaseHandle(void *handle) override
Releases the specified font handle.
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *applicationFont=nullptr) override
Adds an application font described by the font contained supplied fontData or using the font containe...
static QList< QString > fromReadOnlyData(const QString(&t)[N]) noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QSupportedWritingSystems class is used when registering fonts with the internal Qt fontdatabase.
void setSupported(QFontDatabase::WritingSystem, bool supported=true)
Sets or clears support for the specified writingSystem based on the value given by support.
QByteArray toByteArray(StringFormat mode=WithBraces) const
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
static const QCssKnownValue properties[NumProperties - 1]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError * error
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
FT_Library qt_getFreetype()
FT_Library qt_getFreetype()
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLenum GLsizeiptr const void GLsizei faceIndex
GLuint64 GLenum void * handle
GLfloat GLfloat GLfloat w
[0]
GLenum GLenum GLsizei count
GLuint GLuint GLfloat weight
GLenum GLsizeiptr const void * fontData
#define qPrintable(string)
QMap< QFont::Tag, float > variableAxisValues
QMap< QFont::Tag, float > variableAxes
The QFont::Tag type provides access to advanced font features.
constexpr quint32 value() const noexcept
Returns the numerical value of this tag.