Qt 4.8
qfontdatabase_qws.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qdir.h"
43 #if defined(Q_WS_QWS)
44 #include "qscreen_qws.h" //so we can check for rotation
45 #include "qwindowsystem_qws.h"
46 #endif
47 #include "qlibraryinfo.h"
48 #include "qabstractfileengine.h"
49 #include <QtCore/qsettings.h>
50 #if !defined(QT_NO_FREETYPE)
51 #include "qfontengine_ft_p.h"
52 
53 #include <ft2build.h>
54 #include FT_FREETYPE_H
55 
56 #endif
57 #include "qfontengine_qpf_p.h"
58 #include "private/qfactoryloader_p.h"
59 #include "private/qcore_unix_p.h" // overrides QT_OPEN
61 #include "qabstractfontengine_p.h"
62 #include <qdatetime.h>
63 #include "qplatformdefs.h"
64 
65 // for mmap
66 #include <stdlib.h>
67 #include <unistd.h>
68 #include <sys/types.h>
69 #include <sys/stat.h>
70 #include <sys/mman.h>
71 #include <fcntl.h>
72 #include <errno.h>
73 
74 #ifdef QT_FONTS_ARE_RESOURCES
75 #include <qresource.h>
76 #endif
77 
78 #ifdef Q_OS_QNX
79 // ### using QFontEngineQPF leads to artifacts on QNX
80 # define QT_NO_QWS_SHARE_FONTS
81 #endif
82 
84 
85 #ifndef QT_NO_LIBRARY
88 #endif
89 
90 const quint8 DatabaseVersion = 4;
91 
92 // QFontDatabasePrivate::addFont() went into qfontdatabase.cpp
93 
94 #ifndef QT_NO_QWS_QPF2
96 {
97 #ifndef QT_FONTS_ARE_RESOURCES
98  struct stat st;
99  if (stat(file.constData(), &st))
100  return;
101  int f = QT_OPEN(file, O_RDONLY, 0);
102  if (f < 0)
103  return;
104  const uchar *data = (const uchar *)mmap(0, st.st_size, PROT_READ, MAP_SHARED, f, 0);
105  const int dataSize = st.st_size;
106 #else
107  QResource res(QLatin1String(file.constData()));
108  const uchar *data = res.data();
109  const int dataSize = res.size();
110  //qDebug() << "addQPF2File" << file << data;
111 #endif
112  if (data && data != (const uchar *)MAP_FAILED) {
113  if (QFontEngineQPF::verifyHeader(data, dataSize)) {
119 
120  if (!fontName.isEmpty() && pixelSize) {
121  int fontWeight = 50;
122  if (weight.type() == QVariant::Int || weight.type() == QVariant::UInt)
123  fontWeight = weight.toInt();
124 
125  bool italic = static_cast<QFont::Style>(style.toInt()) & QFont::StyleItalic;
126 
128  for (int i = 0; i < writingSystemBits.count(); ++i) {
129  uchar currentByte = writingSystemBits.at(i);
130  for (int j = 0; j < 8; ++j) {
131  if (currentByte & 1)
132  writingSystems << QFontDatabase::WritingSystem(i * 8 + j);
133  currentByte >>= 1;
134  }
135  }
136 
137  addFont(fontName, /*foundry*/ "prerendered", fontWeight, italic,
138  pixelSize, file, /*fileIndex*/ 0,
139  /*antialiased*/ true, writingSystems);
140  }
141  } else {
142  qDebug() << "header verification of QPF2 font" << file << "failed. maybe it is corrupt?";
143  }
144 #ifndef QT_FONTS_ARE_RESOURCES
145  munmap((void *)data, st.st_size);
146 #endif
147  }
148 #ifndef QT_FONTS_ARE_RESOURCES
149  QT_CLOSE(f);
150 #endif
151 }
152 #endif // QT_NO_QWS_QPF2
153 
154 // QFontDatabasePrivate::addTTFile() went into qfontdatabase.cpp
155 
157 
158 extern QString qws_fontCacheDir();
159 
160 #ifndef QT_FONTS_ARE_RESOURCES
162 {
163 #ifdef Q_WS_QWS
164  const bool weAreTheServer = QWSServer::instance();
165 #else
166  const bool weAreTheServer = true; // assume single-process
167 #endif
168 
169  QString fontDirFile = fontPath + QLatin1String("/fontdir");
170 
171  QFile binaryDb(qws_fontCacheDir() + QLatin1String("/fontdb"));
172 
173  if (weAreTheServer) {
174  QDateTime dbTimeStamp = QFileInfo(binaryDb.fileName()).lastModified();
175 
176  QDateTime fontPathTimeStamp = QFileInfo(fontPath).lastModified();
177  if (dbTimeStamp < fontPathTimeStamp)
178  return false; // let the caller create the cache
179 
180  if (QFile::exists(fontDirFile)) {
181  QDateTime fontDirTimeStamp = QFileInfo(fontDirFile).lastModified();
182  if (dbTimeStamp < fontDirTimeStamp)
183  return false;
184  }
185  }
186 
187  if (!binaryDb.open(QIODevice::ReadOnly)) {
188  if (weAreTheServer)
189  return false; // let the caller create the cache
190  qFatal("QFontDatabase::loadFromCache: Could not open font database cache!");
191  }
192 
193  QDataStream stream(&binaryDb);
194  quint8 version = 0;
195  quint8 dataStreamVersion = 0;
196  stream >> version >> dataStreamVersion;
197  if (version != DatabaseVersion || dataStreamVersion != stream.version()) {
198  if (weAreTheServer)
199  return false; // let the caller create the cache
200  qFatal("QFontDatabase::loadFromCache: Wrong version of the font database cache detected. Found %d/%d expected %d/%d",
201  version, dataStreamVersion, DatabaseVersion, stream.version());
202  }
203 
204  QString originalFontPath;
205  stream >> originalFontPath;
206  if (originalFontPath != fontPath) {
207  if (weAreTheServer)
208  return false; // let the caller create the cache
209  qFatal("QFontDatabase::loadFromCache: Font path doesn't match. Found %s in database, expected %s", qPrintable(originalFontPath), qPrintable(fontPath));
210  }
211 
212  QString familyname;
213  stream >> familyname;
214  //qDebug() << "populating database from" << binaryDb.fileName();
215  while (!familyname.isEmpty() && !stream.atEnd()) {
216  QString foundryname;
217  int weight;
218  quint8 italic;
219  int pixelSize;
220  QByteArray file;
221  int fileIndex;
222  quint8 antialiased;
223  quint8 writingSystemCount;
224 
226 
227  stream >> foundryname >> weight >> italic >> pixelSize
228  >> file >> fileIndex >> antialiased >> writingSystemCount;
229 
230  for (quint8 i = 0; i < writingSystemCount; ++i) {
231  quint8 ws;
232  stream >> ws;
233  writingSystems.append(QFontDatabase::WritingSystem(ws));
234  }
235 
236  addFont(familyname, foundryname.toLatin1().constData(), weight, italic, pixelSize, file, fileIndex, antialiased,
237  writingSystems);
238 
239  stream >> familyname;
240  }
241 
242  stream >> fallbackFamilies;
243  //qDebug() << "fallback families from cache:" << fallbackFamilies;
244  return true;
245 }
246 #endif // QT_FONTS_ARE_RESOURCES
247 
253 {
254  QString fontpath = QString::fromLocal8Bit(qgetenv("QT_QWS_FONTDIR"));
255  if (fontpath.isEmpty()) {
256 #ifdef QT_FONTS_ARE_RESOURCES
257  fontpath = QLatin1String(":/qt/fonts");
258 #else
259 #ifndef QT_NO_SETTINGS
261  fontpath += QLatin1String("/fonts");
262 #else
263  fontpath = QLatin1String("/lib/fonts");
264 #endif
265 #endif //QT_FONTS_ARE_RESOURCES
266  }
267 
268  return fontpath;
269 }
270 
271 #if defined(QFONTDATABASE_DEBUG) && defined(QT_FONTS_ARE_RESOURCES)
272 class FriendlyResource : public QResource
273 {
274 public:
275  bool isDir () const { return QResource::isDir(); }
276  bool isFile () const { return QResource::isFile(); }
277  QStringList children () const { return QResource::children(); }
278 };
279 #endif
280 
283 static void initializeDb()
284 {
285  QFontDatabasePrivate *db = privateDb();
286  if (!db || db->count)
287  return;
288 
289  QString fontpath = qwsFontPath();
290 #ifndef QT_FONTS_ARE_RESOURCES
291  QString fontDirFile = fontpath + QLatin1String("/fontdir");
292 
293  if(!QFile::exists(fontpath)) {
294  qFatal("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?",
295  fontpath.toLocal8Bit().constData());
296  }
297 
298  const bool loaded = db->loadFromCache(fontpath);
299 
300  if (db->reregisterAppFonts) {
301  db->reregisterAppFonts = false;
302  for (int i = 0; i < db->applicationFonts.count(); ++i)
303  if (!db->applicationFonts.at(i).families.isEmpty()) {
305  }
306  }
307 
308  if (loaded)
309  return;
310 
311  QString dbFileName = qws_fontCacheDir() + QLatin1String("/fontdb");
312 
313  QFile binaryDb(dbFileName + QLatin1String(".tmp"));
315  db->stream = new QDataStream(&binaryDb);
316  *db->stream << DatabaseVersion << quint8(db->stream->version()) << fontpath;
317 // qDebug() << "creating binary database at" << binaryDb.fileName();
318 
319  // Load in font definition file
320  FILE* fontdef=fopen(fontDirFile.toLocal8Bit().constData(),"r");
321  if (fontdef) {
322  char buf[200]="";
323  char name[200]="";
324  char render[200]="";
325  char file[200]="";
326  char isitalic[10]="";
327  char flags[10]="";
328  do {
329  fgets(buf,200,fontdef);
330  if (buf[0] != '#') {
331  int weight=50;
332  int size=0;
333  sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags);
334  QString filename;
335  if (file[0] != '/')
336  filename.append(fontpath).append(QLatin1Char('/'));
337  filename += QLatin1String(file);
338  bool italic = isitalic[0] == 'y';
339  bool smooth = QByteArray(flags).contains('s');
340  if (file[0] && QFile::exists(filename))
341  db->addFont(QString::fromUtf8(name), /*foundry*/"", weight, italic, size/10, QFile::encodeName(filename), /*fileIndex*/ 0, smooth);
342  }
343  } while (!feof(fontdef));
344  fclose(fontdef);
345  }
346 
347 
348  QDir dir(fontpath, QLatin1String("*.qpf"));
349  for (int i=0; i<int(dir.count()); i++) {
350  int u0 = dir[i].indexOf(QLatin1Char('_'));
351  int u1 = dir[i].indexOf(QLatin1Char('_'), u0+1);
352  int u2 = dir[i].indexOf(QLatin1Char('_'), u1+1);
353  int u3 = dir[i].indexOf(QLatin1Char('.'), u1+1);
354  if (u2 < 0) u2 = u3;
355 
356  QString familyname = dir[i].left(u0);
357  int pixelSize = dir[i].mid(u0+1,u1-u0-1).toInt()/10;
358  bool italic = dir[i].mid(u2-1,1) == QLatin1String("i");
359  int weight = dir[i].mid(u1+1,u2-u1-1-(italic?1:0)).toInt();
360 
361  db->addFont(familyname, /*foundry*/ "qt", weight, italic, pixelSize, QFile::encodeName(dir.absoluteFilePath(dir[i])),
362  /*fileIndex*/ 0, /*antialiased*/ true);
363  }
364 
365 #ifndef QT_NO_FREETYPE
366  dir.setNameFilters(QStringList() << QLatin1String("*.ttf")
367  << QLatin1String("*.ttc") << QLatin1String("*.pfa")
368  << QLatin1String("*.pfb"));
369  dir.refresh();
370  for (int i = 0; i < int(dir.count()); ++i) {
371  const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
372 // qDebug() << "looking at" << file;
373  db->addTTFile(file);
374  }
375 #endif
376 
377 #ifndef QT_NO_QWS_QPF2
378  dir.setNameFilters(QStringList() << QLatin1String("*.qpf2"));
379  dir.refresh();
380  for (int i = 0; i < int(dir.count()); ++i) {
381  const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
382 // qDebug() << "looking at" << file;
383  db->addQPF2File(file);
384  }
385 #endif
386 
387 #else //QT_FONTS_ARE_RESOURCES
388 #ifdef QFONTDATABASE_DEBUG
389  {
390  QResource fontdir(fontpath);
391  FriendlyResource *fr = static_cast<FriendlyResource*>(&fontdir);
392  qDebug() << "fontdir" << fr->isValid() << fr->isDir() << fr->children();
393 
394  }
395 #endif
396 #ifndef QT_NO_QWS_QPF2
397  QDir dir(fontpath, QLatin1String("*.qpf2"));
398  for (int i = 0; i < int(dir.count()); ++i) {
399  const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
400  //qDebug() << "looking at" << file;
401  db->addQPF2File(file);
402  }
403 #endif
404 #endif //QT_FONTS_ARE_RESOURCES
405 
406 
407 #ifdef QFONTDATABASE_DEBUG
408  // print the database
409  for (int f = 0; f < db->count; f++) {
410  QtFontFamily *family = db->families[f];
411  FD_DEBUG("'%s' %s", qPrintable(family->name), (family->fixedPitch ? "fixed" : ""));
412 #if 0
413  for (int i = 0; i < QFont::LastPrivateScript; ++i) {
414  FD_DEBUG("\t%s: %s", qPrintable(QFontDatabase::scriptName((QFont::Script) i)),
415  ((family->scripts[i] & QtFontFamily::Supported) ? "Supported" :
416  (family->scripts[i] & QtFontFamily::UnSupported) == QtFontFamily::UnSupported ?
417  "UnSupported" : "Unknown"));
418  }
419 #endif
420 
421  for (int fd = 0; fd < family->count; fd++) {
422  QtFontFoundry *foundry = family->foundries[fd];
423  FD_DEBUG("\t\t'%s'", qPrintable(foundry->name));
424  for (int s = 0; s < foundry->count; s++) {
425  QtFontStyle *style = foundry->styles[s];
426  FD_DEBUG("\t\t\tstyle: style=%d weight=%d\n"
427  "\t\t\tstretch=%d",
428  style->key.style, style->key.weight,
429  style->key.stretch);
430  if (style->smoothScalable)
431  FD_DEBUG("\t\t\t\tsmooth scalable");
432  else if (style->bitmapScalable)
433  FD_DEBUG("\t\t\t\tbitmap scalable");
434  if (style->pixelSizes) {
435  FD_DEBUG("\t\t\t\t%d pixel sizes", style->count);
436  for (int z = 0; z < style->count; ++z) {
437  QtFontSize *size = style->pixelSizes + z;
438  FD_DEBUG("\t\t\t\t size %5d",
439  size->pixelSize);
440  }
441  }
442  }
443  }
444  }
445 #endif // QFONTDATABASE_DEBUG
446 
447 #ifndef QT_NO_LIBRARY
448  QStringList pluginFoundries = loader()->keys();
449 // qDebug() << "plugin foundries:" << pluginFoundries;
450  for (int i = 0; i < pluginFoundries.count(); ++i) {
451  const QString foundry(pluginFoundries.at(i));
452 
453  QFontEngineFactoryInterface *factory = qobject_cast<QFontEngineFactoryInterface *>(loader()->instance(foundry));
454  if (!factory) {
455  qDebug() << "Could not load plugin for foundry" << foundry;
456  continue;
457  }
458 
459  QList<QFontEngineInfo> fonts = factory->availableFontEngines();
460  for (int i = 0; i < fonts.count(); ++i) {
461  QFontEngineInfo info = fonts.at(i);
462 
463  int weight = info.weight();
464  if (weight <= 0)
465  weight = QFont::Normal;
466 
467  db->addFont(info.family(), foundry.toLatin1().constData(),
468  weight, info.style() != QFont::StyleNormal,
469  qRound(info.pixelSize()), /*file*/QByteArray(),
470  /*fileIndex*/0, /*antiAliased*/true,
471  info.writingSystems());
472  }
473  }
474 #endif
475 
476 #ifndef QT_FONTS_ARE_RESOURCES
477  // the empty string/familyname signifies the end of the font list.
478  *db->stream << QString();
479 #endif
480  {
481  bool coveredWritingSystems[QFontDatabase::WritingSystemsCount] = { 0 };
482 
483  db->fallbackFamilies.clear();
484 
485  for (int i = 0; i < db->count; ++i) {
486  QtFontFamily *family = db->families[i];
487  bool add = false;
488  if (family->count == 0)
489  continue;
490  if (family->bogusWritingSystems)
491  continue;
492  for (int ws = 1; ws < QFontDatabase::WritingSystemsCount; ++ws) {
493  if (coveredWritingSystems[ws])
494  continue;
495  if (family->writingSystems[ws] & QtFontFamily::Supported) {
496  coveredWritingSystems[ws] = true;
497  add = true;
498  }
499  }
500  if (add)
501  db->fallbackFamilies << family->name;
502  }
503  //qDebug() << "fallbacks on the server:" << db->fallbackFamilies;
504 #ifndef QT_FONTS_ARE_RESOURCES
505  *db->stream << db->fallbackFamilies;
506 #endif
507  }
508 #ifndef QT_FONTS_ARE_RESOURCES
509  delete db->stream;
510  db->stream = 0;
511  QFile::remove(dbFileName);
512  binaryDb.rename(dbFileName);
513 #endif
514 }
515 
516 // called from qwindowsystem_qws.cpp
518 {
519  initializeDb();
520 }
521 
522 #ifndef QT_NO_SETTINGS
523 // called from qapplication_qws.cpp
525 {
526  initializeDb();
527  QFontDatabasePrivate *db = privateDb();
528  for (int i = 0; i < db->count; ++i) {
529  QtFontFamily *family = db->families[i];
530  if (settings.contains(family->name))
531  family->fallbackFamilies = settings.value(family->name).toStringList();
532  }
533 
534  if (settings.contains(QLatin1String("Global Fallbacks")))
535  db->fallbackFamilies = settings.value(QLatin1String("Global Fallbacks")).toStringList();
536 }
537 #endif // QT_NO_SETTINGS
538 
539 static inline void load(const QString & = QString(), int = -1)
540 {
541  initializeDb();
542 }
543 
544 #ifndef QT_NO_FREETYPE
545 
546 #if (FREETYPE_MAJOR*10000+FREETYPE_MINOR*100+FREETYPE_PATCH) >= 20105
547 #define X_SIZE(face,i) ((face)->available_sizes[i].x_ppem)
548 #define Y_SIZE(face,i) ((face)->available_sizes[i].y_ppem)
549 #else
550 #define X_SIZE(face,i) ((face)->available_sizes[i].width << 6)
551 #define Y_SIZE(face,i) ((face)->available_sizes[i].height << 6)
552 #endif
553 
554 #endif // QT_NO_FREETYPE
555 
556 static
558  const QFontDef &request,
559  QtFontFamily *family, QtFontFoundry *foundry,
560  QtFontStyle *style, QtFontSize *size)
561 {
562  Q_UNUSED(script);
563  Q_UNUSED(fp);
564 #ifdef QT_NO_FREETYPE
565  Q_UNUSED(foundry);
566 #endif
567 #ifdef QT_NO_QWS_QPF
568  Q_UNUSED(family);
569 #endif
570  Q_ASSERT(size);
571 
572  int pixelSize = size->pixelSize;
573  if (!pixelSize || (style->smoothScalable && pixelSize == SMOOTH_SCALABLE))
574  pixelSize = request.pixelSize;
575 
576 #ifndef QT_NO_QWS_QPF2
577  if (foundry->name == QLatin1String("prerendered")) {
578 #ifdef QT_FONTS_ARE_RESOURCES
580  if (res.isValid()) {
581  QFontEngineQPF *fe = new QFontEngineQPF(request, res.data(), res.size());
582  if (fe->isValid())
583  return fe;
584  delete fe;
585  qDebug() << "fontengine is not valid! " << size->fileName;
586  } else {
587  qDebug() << "Resource not valid" << size->fileName;
588  }
589 #else
590  int f = ::open(size->fileName, O_RDONLY, 0);
591  if (f >= 0) {
592  QFontEngineQPF *fe = new QFontEngineQPF(request, f);
593  if (fe->isValid())
594  return fe;
595  delete fe; // will close f
596  qDebug() << "fontengine is not valid!";
597  }
598 #endif
599  } else
600 #endif
601  if ( foundry->name != QLatin1String("qt") ) {
602  QString file = QFile::decodeName(size->fileName);
603 
604  QFontDef def = request;
605  def.pixelSize = pixelSize;
606 
607 #ifdef QT_NO_QWS_SHARE_FONTS
608  bool shareFonts = false;
609 #else
610  static bool dontShareFonts = !qgetenv("QWS_NO_SHARE_FONTS").isEmpty();
611  bool shareFonts = !dontShareFonts;
612 #endif
613 
615 
616 #ifndef QT_NO_LIBRARY
617  QFontEngineFactoryInterface *factory = qobject_cast<QFontEngineFactoryInterface *>(loader()->instance(foundry->name));
618  if (factory) {
620  info.setFamily(request.family);
621  info.setPixelSize(request.pixelSize);
622  info.setStyle(QFont::Style(request.style));
623  info.setWeight(request.weight);
624  // #### antialiased
625 
626  QAbstractFontEngine *customEngine = factory->create(info);
627  if (customEngine) {
628  engine.reset(new QProxyFontEngine(customEngine, def));
629 
630  if (shareFonts) {
632  if (hint.isValid())
633  shareFonts = hint.toBool();
634  else
635  shareFonts = (pixelSize < 64);
636  }
637  }
638  }
639 #endif // QT_NO_LIBRARY
640  if ((engine.isNull() && !file.isEmpty() && QFile::exists(file)) || privateDb()->isApplicationFont(file)) {
641  QFontEngine::FaceId faceId;
642  faceId.filename = file.toLocal8Bit();
643  faceId.index = size->fileIndex;
644 
645 #ifndef QT_NO_FREETYPE
646 
648  bool antialias = style->antialiased && !(request.styleStrategy & QFont::NoAntialias);
649  if (fte->init(faceId, antialias,
651 #ifdef QT_NO_QWS_QPF2
652  return fte.take();
653 #else
654  // try to distinguish between bdf and ttf fonts we can pre-render
655  // and don't try to share outline fonts
656  shareFonts = shareFonts
657  && !fte->defaultGlyphs()->outline_drawing
658  && !fte->getSfntTable(MAKE_TAG('h', 'e', 'a', 'd')).isEmpty();
659  engine.reset(fte.take());
660 #endif
661  }
662 #endif // QT_NO_FREETYPE
663  }
664  if (!engine.isNull()) {
665 #if !defined(QT_NO_QWS_QPF2) && !defined(QT_FONTS_ARE_RESOURCES)
666  if (shareFonts) {
667  QScopedPointer<QFontEngineQPF> fe(new QFontEngineQPF(def, -1, engine.data()));
668  engine.take();
669  if (fe->isValid())
670  return fe.take();
671  qWarning("Initializing QFontEngineQPF failed for %s", qPrintable(file));
672  engine.reset(fe->takeRenderingEngine());
673  }
674 #endif
675  return engine.take();
676  }
677  } else
678  {
679 #ifndef QT_NO_QWS_QPF
680  QString fn = qwsFontPath();
681  fn += QLatin1Char('/');
682  fn += family->name.toLower()
683  + QLatin1Char('_') + QString::number(pixelSize*10)
684  + QLatin1Char('_') + QString::number(style->key.weight)
685  + (style->key.style == QFont::StyleItalic ?
686  QLatin1String("i.qpf") : QLatin1String(".qpf"));
687  //###rotation ###
688 
689  QFontEngine *fe = new QFontEngineQPF1(request, fn);
690  return fe;
691 #endif // QT_NO_QWS_QPF
692  }
693  return new QFontEngineBox(pixelSize);
694 }
695 
696 static
698  const QFontDef &request,
699  QtFontFamily *family, QtFontFoundry *foundry,
700  QtFontStyle *style, QtFontSize *size)
701 {
702  QScopedPointer<QFontEngine> engine(loadSingleEngine(script, fp, request, family, foundry,
703  style, size));
704 #ifndef QT_NO_QWS_QPF
705  if (!engine.isNull()
706  && script == QUnicodeTables::Common
707  && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
708 
709  QStringList fallbacks = privateDb()->fallbackFamilies;
710 
711  if (family && !family->fallbackFamilies.isEmpty())
712  fallbacks = family->fallbackFamilies;
713 
714  QFontEngine *fe = new QFontEngineMultiQWS(engine.data(), script, fallbacks);
715  engine.take();
716  engine.reset(fe);
717  }
718 #endif
719  return engine.take();
720 }
721 
723 {
724  QFontDatabasePrivate *db = privateDb();
725 #ifdef QT_NO_FREETYPE
726  Q_UNUSED(fnt);
727 #else
728  fnt->families = db->addTTFile(QFile::encodeName(fnt->fileName), fnt->data);
729  db->fallbackFamilies += fnt->families;
730 #endif
731  db->reregisterAppFonts = true;
732 }
733 
735 {
736  QMutexLocker locker(fontDatabaseMutex());
737 
738  QFontDatabasePrivate *db = privateDb();
739  if (handle < 0 || handle >= db->applicationFonts.count())
740  return false;
741 
743 
744  db->reregisterAppFonts = true;
745  db->invalidate();
746  return true;
747 }
748 
750 {
751  QMutexLocker locker(fontDatabaseMutex());
752 
753  QFontDatabasePrivate *db = privateDb();
754  if (db->applicationFonts.isEmpty())
755  return false;
756 
757  db->applicationFonts.clear();
758  db->invalidate();
759  return true;
760 }
761 
763 {
764  return true;
765 }
766 
767 QFontEngine *
769  const QFontDef &request)
770 {
771  QMutexLocker locker(fontDatabaseMutex());
772 
773  const int force_encoding_id = -1;
774 
775  if (!privateDb()->count)
776  initializeDb();
777 
779  if (fp) {
780  if (fp->rawMode) {
781  fe.reset(loadEngine(script, fp, request, 0, 0, 0, 0));
782 
783  // if we fail to load the rawmode font, use a 12pixel box engine instead
784  if (fe.isNull())
785  fe.reset(new QFontEngineBox(12));
786  return fe.take();
787  }
788 
789  QFontCache::Key key(request, script);
790  fe.reset(QFontCache::instance()->findEngine(key));
791  if (! fe.isNull())
792  return fe.take();
793  }
794 
795  QString family_name, foundry_name;
796  QtFontStyle::Key styleKey;
797  styleKey.style = request.style;
798  styleKey.weight = request.weight;
799  styleKey.stretch = request.stretch;
800  char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p';
801 
802  parseFontName(request.family, foundry_name, family_name);
803 
804  FM_DEBUG("QFontDatabase::findFont\n"
805  " request:\n"
806  " family: %s [%s], script: %d\n"
807  " weight: %d, style: %d\n"
808  " stretch: %d\n"
809  " pixelSize: %g\n"
810  " pitch: %c",
811  family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(),
812  foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(),
813  script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
814 
815  if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) {
816  fe.reset(new QTestFontEngine(request.pixelSize));
817  fe->fontDef = request;
818  }
819 
820  if (fe.isNull())
821  {
822  QtFontDesc desc;
823  match(script, request, family_name, foundry_name, force_encoding_id, &desc);
824 
825  if (desc.family != 0 && desc.foundry != 0 && desc.style != 0
826  ) {
827  FM_DEBUG(" BEST:\n"
828  " family: %s [%s]\n"
829  " weight: %d, style: %d\n"
830  " stretch: %d\n"
831  " pixelSize: %d\n"
832  " pitch: %c\n"
833  " encoding: %d\n",
834  desc.family->name.toLatin1().constData(),
835  desc.foundry->name.isEmpty() ? "-- none --" : desc.foundry->name.toLatin1().constData(),
836  desc.style->key.weight, desc.style->key.style,
837  desc.style->key.stretch, desc.size ? desc.size->pixelSize : 0xffff,
838  'p', 0
839  );
840 
841  fe.reset(loadEngine(script, fp, request, desc.family, desc.foundry, desc.style, desc.size
842  ));
843  } else {
844  FM_DEBUG(" NO MATCH FOUND\n");
845  }
846  if (! fe.isNull())
847  initFontDef(desc, request, &fe->fontDef);
848  }
849 
850 #ifndef QT_NO_FREETYPE
851  if (! fe.isNull()) {
852  if (scriptRequiresOpenType(script) && fe->type() == QFontEngine::Freetype) {
853  HB_Face hbFace = static_cast<QFontEngineFT *>(fe.data())->harfbuzzFace();
854  if (!hbFace || !hbFace->supported_scripts[script]) {
855  FM_DEBUG(" OpenType support missing for script\n");
856  fe.reset(0);
857  }
858  }
859  }
860 #endif
861 
862  if (! fe.isNull()) {
863  if (fp) {
864  QFontDef def = request;
865  if (def.family.isEmpty()) {
866  def.family = fp->request.family;
867  def.family = def.family.left(def.family.indexOf(QLatin1Char(',')));
868  }
869  QFontCache::Key key(def, script);
870  QFontCache::instance()->insertEngine(key, fe.data());
871  }
872  }
873 
874  if (fe.isNull()) {
875  if (!request.family.isEmpty())
876  return 0;
877 
878  FM_DEBUG("returning box engine");
879 
880  fe.reset(new QFontEngineBox(request.pixelSize));
881 
882  if (fp) {
883  QFontCache::Key key(request, script);
884  QFontCache::instance()->insertEngine(key, fe.data());
885  }
886  }
887 
888  if (fp && fp->dpi > 0) {
889  fe->fontDef.pointSize = qreal(double((fe->fontDef.pixelSize * 72) / fp->dpi));
890  } else {
891  fe->fontDef.pointSize = request.pointSize;
892  }
893 
894  return fe.take();
895 }
896 
897 void QFontDatabase::load(const QFontPrivate *d, int script)
898 {
899  QFontDef req = d->request;
900 
901  if (req.pixelSize == -1)
902  req.pixelSize = qRound(req.pointSize*d->dpi/72);
903  if (req.pointSize < 0)
904  req.pointSize = req.pixelSize*72.0/d->dpi;
905 
906  if (!d->engineData) {
907  QFontCache::Key key(req, script);
908 
909  // look for the requested font in the engine data cache
911 
912  if (!d->engineData) {
913  // create a new one
914  d->engineData = new QFontEngineData;
915  QT_TRY {
917  } QT_CATCH(...) {
918  delete d->engineData;
919  d->engineData = 0;
920  QT_RETHROW;
921  }
922  } else {
923  d->engineData->ref.ref();
924  }
925  }
926 
927  // the cached engineData could have already loaded the engine we want
928  if (d->engineData->engines[script]) return;
929 
930  // double scale = 1.0; // ### TODO: fix the scale calculations
931 
932  // list of families to try
933  QStringList family_list;
934 
935  if (!req.family.isEmpty()) {
936  family_list = req.family.split(QLatin1Char(','));
937 
938  // append the substitute list for each family in family_list
939  QStringList subs_list;
940  QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();
941  for (; it != end; ++it)
942  subs_list += QFont::substitutes(*it);
943  family_list += subs_list;
944 
945  // append the default fallback font for the specified script
946  // family_list << ... ; ###########
947 
948  // add the default family
949  QString defaultFamily = QApplication::font().family();
950  if (! family_list.contains(defaultFamily))
951  family_list << defaultFamily;
952 
953  // add QFont::defaultFamily() to the list, for compatibility with
954  // previous versions
955  family_list << QApplication::font().defaultFamily();
956  }
957 
958  // null family means find the first font matching the specified script
959  family_list << QString();
960 
961  // load the font
962  QFontEngine *engine = 0;
963  QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();
964  for (; !engine && it != end; ++it) {
965  req.family = *it;
966 
967  engine = QFontDatabase::findFont(script, d, req);
968  if (engine && (engine->type()==QFontEngine::Box) && !req.family.isEmpty())
969  engine = 0;
970  }
971 
972  engine->ref.ref();
973  d->engineData->engines[script] = engine;
974 }
975 
976 
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
bool isNull() const
Returns true if this object is holding a pointer that is null.
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QAtomicInt ref
T qobject_cast(QObject *object)
Definition: qobject.h:375
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,(QFontEngineFactoryInterface_iid, QLatin1String("/fontengines"), Qt::CaseInsensitive)) const quint8 DatabaseVersion
uint fixedPitch
Definition: qfont_p.h:96
#define QFontEngineFactoryInterface_iid
static bool removeAllApplicationFonts()
Removes all application-local fonts previously added using addApplicationFont() and addApplicationFon...
double d
Definition: qnumeric_p.h:62
QString fileName() const
Returns the name set by setFileName() or to the QFile constructors.
Definition: qfile.cpp:470
bool loadFromCache(const QString &fontPath)
bool rename(const QString &newName)
Renames the file currently specified by fileName() to newName.
Definition: qfile.cpp:766
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
unsigned short pixelSize
#define MAP_FAILED
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
Definition: qsettings.cpp:3460
double qreal
Definition: qglobal.h:1193
static mach_timebase_info_data_t info
QByteArray fileName
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
Q_CORE_EXPORT QTextStream & ws(QTextStream &s)
QFontEngine * takeRenderingEngine()
QString absoluteFilePath(const QString &fileName) const
Returns the absolute path name of a file in the directory.
Definition: qdir.cpp:701
static QWSServer * instance()
#define add(aName)
T * data() const
Returns the value of the pointer referenced by this object.
qreal pointSize
Definition: qfont_p.h:89
#define it(className, varName)
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition: qfile.cpp:1064
signed int count
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
QtFontStyle ** styles
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
QtFontSize * size
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QStringList fontPath()
T * take()
Returns the value of the pointer referenced by this object.
#define O_RDONLY
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
void insertEngine(const Key &key, QFontEngine *engine)
Definition: qfont.cpp:3073
static bool match(const uchar *found, const char *target, uint len)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
QtFontStyle * style
QString qws_fontCacheDir()
QStringList fallbackFamilies
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
unsigned char quint8
Definition: qglobal.h:934
bool ref()
Atomically increments the value of this QAtomicInt.
The QString class provides a Unicode character string.
Definition: qstring.h:83
qint64 size() const
Returns the size of the data backing the resource.
Definition: qresource.cpp:510
uint count() const
Returns the total number of directories and files in the directory.
Definition: qdir.cpp:1247
static void load(const QFontPrivate *d, int script)
Loads a QFontEngine for the specified script that matches the QFontDef request member variable...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
bool bogusWritingSystems
virtual Type type() const =0
virtual QAbstractFontEngine * create(const QFontEngineInfo &info)=0
static void parseFontName(const QString &name, QString &foundry, QString &family)
This makes sense of the font family name:
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
QStringList addTTFile(const QByteArray &file, const QByteArray &fontData=QByteArray())
void setNameFilters(const QStringList &nameFilters)
Sets the name filters used by entryList() and entryInfoList() to the list of filters specified by nam...
Definition: qdir.cpp:966
QString family() const
the family name of the font
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
static QFontCache * instance()
Definition: qfont.cpp:2919
void setStyle(QFont::Style style)
static QFont font()
Returns the default application font.
static QFontEngine * loadSingleEngine(int script, const QFontPrivate *fp, const QFontDef &request, QtFontFamily *family, QtFontFoundry *foundry, QtFontStyle *style, QtFontSize *size)
virtual QVariant fontProperty(FontProperty property) const =0
Implemented in subclasses to return the value of the font attribute property.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
bool init(FaceId faceId, bool antiaalias, GlyphFormat defaultFormat=Format_None, const QByteArray &fontData=QByteArray())
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
Definition: qfile.cpp:552
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
Definition: qfile.cpp:626
void refresh() const
Refreshes the directory information.
Definition: qdir.cpp:2218
uint rawMode
Definition: qfont_p.h:187
#define MAKE_TAG(ch1, ch2, ch3, ch4)
QtFontFoundry * foundry
Q_CORE_EXPORT void qDebug(const char *,...)
void setWeight(int weight)
#define QT_RETHROW
Definition: qglobal.h:1539
unsigned char uchar
Definition: qglobal.h:994
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define SMOOTH_SCALABLE
bool isValid() const
Returns true if the resource really exists in the resource hierarchy, false otherwise.
Definition: qresource.cpp:470
QStringList fallbackFamilies
bool isValid() const
The QResource class provides an interface for reading directly from resources.
Definition: qresource.h:58
static float pixelSize(const QFontDef &request, int dpi)
Definition: qfont_win.cpp:80
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
QList< QFontDatabase::WritingSystem > writingSystems() const
An empty list means that any writing system is supported.
The QFontEngineInfo class describes a specific font provided by a font engine plugin.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define FD_DEBUG
QtFontFamily ** families
QFontDef request
Definition: qfont_p.h:178
const char * name
void insertEngineData(const Key &key, QFontEngineData *engineData)
Definition: qfont.cpp:3046
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
const uchar * data() const
Returns direct access to a read only segment of data that this resource represents.
Definition: qresource.cpp:526
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
void qt_qws_init_fontdb()
Q_CORE_EXPORT void qWarning(const char *,...)
QGlyphSet * defaultGlyphs()
static QFontEngine * loadEngine(int script, const QFontPrivate *fp, const QFontDef &request, QtFontFamily *family, QtFontFoundry *foundry, QtFontStyle *style, QtFontSize *size)
static const char * data(const QByteArray &arr)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
static bool supportsThreadedFontRendering()
Returns true if font rendering is supported outside the GUI thread, false otherwise.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
uint weight
Definition: qfont_p.h:95
bool qt_enable_test_font
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
void setPixelSize(qreal size)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
void clear()
Removes all items from the list.
Definition: qlist.h:764
bool isDir() const
Returns true if the resource represents a directory and thus may have children() in it...
Definition: qresource.cpp:540
QAtomicInt ref
Definition: qfont_p.h:152
uint ignorePitch
Definition: qfont_p.h:100
void setFamily(const QString &name)
static void initializeDb()
QtFontFoundry ** foundries
#define QT_CATCH(A)
Definition: qglobal.h:1537
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
#define FM_DEBUG
Style
This enum describes the different styles of glyphs that are used to display text. ...
Definition: qfont.h:111
static bool removeApplicationFont(int id)
Removes the previously loaded application font identified by id.
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
qreal pixelSize
Definition: qfont_p.h:90
QtFontFamily * family(const QString &f, bool=false)
int version() const
Returns the version number of the data serialization format.
Definition: qdatastream.h:212
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
void addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize, const QByteArray &file, int fileIndex, bool antialiased, const QList< QFontDatabase::WritingSystem > &writingSystems=QList< QFontDatabase::WritingSystem >())
QFont::Style style() const
the style of the font
Q_CORE_EXPORT void qFatal(const char *,...)
static QString qwsFontPath()
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
#define QT_OPEN
Definition: qcore_unix_p.h:186
static QStringList substitutes(const QString &)
Returns a list of family names to be used whenever familyName is specified.
Definition: qfont.cpp:2139
QString & append(QChar c)
Definition: qstring.cpp:1777
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
int count(char c) const
Returns the number of occurrences of character ch in the byte array.
static bool scriptRequiresOpenType(int script)
unsigned char writingSystems[QFontDatabase::WritingSystemsCount]
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
uint style
Definition: qfont_p.h:97
static QString location(LibraryLocation)
Returns the location specified by loc.
#define st(var, type, card)
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Definition: qlist.h:279
int key
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
bool contains(const QString &key) const
Returns true if there exists a setting called key; returns false otherwise.
Definition: qsettings.cpp:3394
static bool verifyHeader(const uchar *data, int size)
uint stretch
Definition: qfont_p.h:98
void qt_applyFontDatabaseSettings(const QSettings &settings)
QtFontFamily * family
bool remove()
Removes the file specified by fileName().
Definition: qfile.cpp:715
QString defaultFamily() const
Returns the family name that corresponds to the current style hint.
Definition: qfont_mac.cpp:134
qreal pixelSize() const
A pixel size of 0 represents a freely scalable font.
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user&#39;s loca...
Definition: qfile.cpp:528
int weight() const
The value should be from the QFont::Weight enumeration.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
QFontEngineData * findEngineData(const Key &key) const
Definition: qfont.cpp:3036
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
QStringList children() const
Returns a list of all resources in this directory, if the resource represents a file the list will be...
Definition: qresource.cpp:554
QFontDef fontDef
QVector< ApplicationFont > applicationFonts
QString family
Definition: qfont_p.h:82
char at(int i) const
Returns the character at index position i in the byte array.
Definition: qbytearray.h:413
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
static const KeyPair *const end
QFontEngineData * engineData
Definition: qfont_p.h:179
#define qPrintable(string)
Definition: qglobal.h:1750
uint styleStrategy
Definition: qfont_p.h:92
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void addQPF2File(const QByteArray &file)
#define QT_TRY
Definition: qglobal.h:1536
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QtFontSize * pixelSizes
The QAbstractFontEngine class is the base class for font engine plugins in Qt for Embedded Linux...
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
int open(const char *, int,...)
static void load(const QString &=QString(), int=-1)
QBool contains(char c) const
Returns true if the byte array contains the character ch; otherwise returns false.
Definition: qbytearray.h:525
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
bool isFile() const
Returns true if the resource represents a file and thus has data backing it, false if it represents a...
Definition: qresource.h:90
QByteArray getSfntTable(uint) const
#define QT_CLOSE
Definition: qcore_unix_p.h:304
static QVariant extractHeaderField(const uchar *data, HeaderTag tag)
static QFontEngine * findFont(int script, const QFontPrivate *fp, const QFontDef &request)
QDateTime lastModified() const
Returns the date and time when the file was last modified.
Definition: qfileinfo.cpp:1296