44 #include <QtGui/private/qapplication_p.h> 45 #include <QtGui/QPlatformScreen> 47 #include <QtCore/QFile> 48 #include <QtCore/QLibraryInfo> 49 #include <QtCore/QDir> 52 #include <QtGui/private/qfontengine_ft_p.h> 53 #include <QtGui/private/qfontengine_p.h> 56 #include FT_TRUETYPE_TABLES_H 58 #define SimplifiedChineseCsbBit 18 59 #define TraditionalChineseCsbBit 20 60 #define JapaneseCsbBit 17 61 #define KoreanCsbBit 21 137 bool hasScript =
false;
143 int flag = 1 << (bit&31);
144 if (bit != 126 && unicodeRange[index] & flag) {
148 flag = 1 << (bit&31);
149 if (bit == 127 || unicodeRange[index] & flag) {
179 return writingSystems;
194 qFatal(
"QFontDatabase: Cannot find font directory %s - is Qt installed correctly?",
203 for (
int i = 0; i < int(dir.
count()); ++i) {
221 if (!engine->
init(fid,antialias,format)) {
231 if (!hbFace || !hbFace->supported_scripts[script]) {
272 error = FT_New_Memory_Face(library, (
const FT_Byte *)fontData.
constData(), fontData.
size(),
index, &face);
276 if (error != FT_Err_Ok) {
277 qDebug() <<
"FT_New_Face failed with index" << index <<
":" <<
hex <<
error;
280 numFaces = face->num_faces;
285 if (face->style_flags & FT_STYLE_FLAG_ITALIC)
288 if (face->style_flags & FT_STYLE_FLAG_BOLD)
293 for (
int i = 0; i < face->num_charmaps; ++i) {
294 FT_CharMap cm = face->charmaps[i];
295 if (cm->encoding == ft_encoding_adobe_custom
296 || cm->encoding == ft_encoding_symbol) {
302 TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
322 registerFont(family,
"",weight,style,stretch,
true,
true,0,writingSystems,fontFile);
328 }
while (index < numFaces);
The QDir class provides access to directory structures and their contents.
void setSupported(QFontDatabase::WritingSystem, bool supported=true)
Sets the supported state of the writing system given by writingSystem to the value specified by suppo...
static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file)
void populateFontDatabase()
This function is called once at startup by Qts internal fontdatabase.
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
QString absoluteFilePath(const QString &fileName) const
Returns the absolute path name of a file in the directory.
The QByteArray class provides an array of bytes.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Weight
Qt uses a weighting scale from 0 to 99 similar to, but not the same as, the scales used in Windows or...
The QString class provides a Unicode character string.
uint count() const
Returns the total number of directories and files in the directory.
Stretch
Predefined stretch values that follow the CSS naming convention.
Q_CORE_EXPORT QTextStream & hex(QTextStream &s)
void setNameFilters(const QStringList &nameFilters)
Sets the name filters used by entryList() and entryInfoList() to the list of filters specified by nam...
bool init(FaceId faceId, bool antiaalias, GlyphFormat defaultFormat=Format_None, const QByteArray &fontData=QByteArray())
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
void refresh() const
Refreshes the directory information.
Q_CORE_EXPORT void qDebug(const char *,...)
#define SimplifiedChineseCsbBit
void append(const T &t)
Inserts value at the end of the list.
QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
Returns a list of alternative fonts for the specified family and style and script using the styleHint...
struct FT_FaceRec_ * FT_Face
static QFontEngine::FaceId fontFile(const QByteArray &_xname, QFreetypeFace **freetype, int *synth)
The QStringList class provides a list of strings.
The QSupportedWritingSystems class is used when registering fonts with the internal Qt fontdatabase...
const char * styleHint(const QFontDef &request)
#define TraditionalChineseCsbBit
static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2]
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Style
This enum describes the different styles of glyphs that are used to display text. ...
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName)
Adds an application font described by the font contained supplied fontData or using the font containe...
const char * constData() const
Returns a pointer to the data stored in the byte array.
QFontEngine * fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle)
Returns the font engine that can be used to render the font described by the font definition...
Q_CORE_EXPORT void qFatal(const char *,...)
StyleHint
Style hints are used by the font matching algorithm to find an appropriate default family if a select...
static QSupportedWritingSystems determineWritingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2])
int size() const
Returns the number of bytes in this byte array.
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user's loca...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
FT_Library qt_getFreetype()
static bool scriptRequiresOpenType(int script)
#define qPrintable(string)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static QString fileName(const QString &fileUrl)
void releaseHandle(void *handle)
Releases the font handle and deletes any associated data loaded from a file.
HB_Face harfbuzzFace() const