Qt 4.8
Macros | Functions
qfontdatabase_qws.cpp File Reference
#include "qdir.h"
#include "qscreen_qws.h"
#include "qwindowsystem_qws.h"
#include "qlibraryinfo.h"
#include "qabstractfileengine.h"
#include <QtCore/qsettings.h>
#include "qfontengine_ft_p.h"
#include <ft2build.h>
#include <FT_FREETYPE_H>
#include "qfontengine_qpf_p.h"
#include "private/qfactoryloader_p.h"
#include "private/qcore_unix_p.h"
#include "qabstractfontengine_qws.h"
#include "qabstractfontengine_p.h"
#include <qdatetime.h>
#include "qplatformdefs.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <errno.h>

Go to the source code of this file.

Macros

#define X_SIZE(face, i)   ((face)->available_sizes[i].width << 6)
 
#define Y_SIZE(face, i)   ((face)->available_sizes[i].height << 6)
 

Functions

static void initializeDb ()
 
static void load (const QString &=QString(), int=-1)
 
static QFontEngineloadEngine (int script, const QFontPrivate *fp, const QFontDef &request, QtFontFamily *family, QtFontFoundry *foundry, QtFontStyle *style, QtFontSize *size)
 
static QFontEngineloadSingleEngine (int script, const QFontPrivate *fp, const QFontDef &request, QtFontFamily *family, QtFontFoundry *foundry, QtFontStyle *style, QtFontSize *size)
 
 Q_GLOBAL_STATIC_WITH_ARGS (QFactoryLoader, loader,(QFontEngineFactoryInterface_iid, QLatin1String("/fontengines"), Qt::CaseInsensitive)) const quint8 DatabaseVersion
 
void qt_applyFontDatabaseSettings (const QSettings &settings)
 
void qt_qws_init_fontdb ()
 
QString qws_fontCacheDir ()
 
static QString qwsFontPath ()
 
static void registerFont (QFontDatabasePrivate::ApplicationFont *fnt)
 

Macro Definition Documentation

◆ X_SIZE

#define X_SIZE (   face,
 
)    ((face)->available_sizes[i].width << 6)

Definition at line 550 of file qfontdatabase_qws.cpp.

◆ Y_SIZE

#define Y_SIZE (   face,
 
)    ((face)->available_sizes[i].height << 6)

Definition at line 551 of file qfontdatabase_qws.cpp.

Function Documentation

◆ initializeDb()

static void initializeDb ( )
static
Warning
This function is not part of the public interface.

Definition at line 283 of file qfontdatabase_qws.cpp.

Referenced by load(), qt_applyFontDatabaseSettings(), qt_qws_init_fontdb(), and registerFont().

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"));
314  binaryDb.open(QIODevice::WriteOnly | QIODevice::Truncate);
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 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
bool loadFromCache(const QString &fontPath)
unsigned short pixelSize
static mach_timebase_info_data_t info
#define add(aName)
signed int count
QtFontStyle ** styles
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString qws_fontCacheDir()
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
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
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
bool bogusWritingSystems
QStringList addTTFile(const QByteArray &file, const QByteArray &fontData=QByteArray())
QString family() const
the family name of the font
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
Definition: qfile.cpp:626
Q_CORE_EXPORT void qDebug(const char *,...)
QStringList fallbackFamilies
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.
#define FD_DEBUG
QtFontFamily ** families
const char * name
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
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 clear()
Removes all items from the list.
Definition: qlist.h:764
QtFontFoundry ** foundries
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
QTextStream & ws(QTextStream &stream)
Calls skipWhiteSpace() on stream and returns stream.
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()
QString & append(QChar c)
Definition: qstring.cpp:1777
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
unsigned char writingSystems[QFontDatabase::WritingSystemsCount]
bool remove()
Removes the file specified by fileName().
Definition: qfile.cpp:715
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.
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
QVector< ApplicationFont > applicationFonts
#define qPrintable(string)
Definition: qglobal.h:1750
void addQPF2File(const QByteArray &file)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QtFontSize * pixelSizes
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
QBool contains(char c) const
Returns true if the byte array contains the character ch; otherwise returns false.
Definition: qbytearray.h:525
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ load()

static void load ( const QString = QString(),
int  = -1 
)
inlinestatic

Definition at line 539 of file qfontdatabase_qws.cpp.

540 {
541  initializeDb();
542 }
static void initializeDb()

◆ loadEngine()

static QFontEngine* loadEngine ( int  script,
const QFontPrivate fp,
const QFontDef request,
QtFontFamily family,
QtFontFoundry foundry,
QtFontStyle style,
QtFontSize size 
)
static

Definition at line 697 of file qfontdatabase_qws.cpp.

Referenced by registerFont().

701 {
702  QScopedPointer<QFontEngine> engine(loadSingleEngine(script, fp, request, family, foundry,
703  style, size));
704 #ifndef QT_NO_QWS_QPF
705  if (!engine.isNull()
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 }
QStringList fallbackFamilies
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 QFontEngine * loadSingleEngine(int script, const QFontPrivate *fp, const QFontDef &request, QtFontFamily *family, QtFontFoundry *foundry, QtFontStyle *style, QtFontSize *size)
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
uint styleStrategy
Definition: qfont_p.h:92

◆ loadSingleEngine()

static QFontEngine* loadSingleEngine ( int  script,
const QFontPrivate fp,
const QFontDef request,
QtFontFamily family,
QtFontFoundry foundry,
QtFontStyle style,
QtFontSize size 
)
static

is this the best way????

Definition at line 557 of file qfontdatabase_qws.cpp.

Referenced by loadEngine().

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 }
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.
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
unsigned short pixelSize
static mach_timebase_info_data_t info
QByteArray fileName
QFontEngine * takeRenderingEngine()
T * data() const
Returns the value of the pointer referenced by this object.
T * take()
Returns the value of the pointer referenced by this object.
#define O_RDONLY
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
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual QAbstractFontEngine * create(const QFontEngineInfo &info)=0
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
void setStyle(QFont::Style style)
virtual QVariant fontProperty(FontProperty property) const =0
Implemented in subclasses to return the value of the font attribute property.
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
#define MAKE_TAG(ch1, ch2, ch3, ch4)
Q_CORE_EXPORT void qDebug(const char *,...)
void setWeight(int weight)
#define SMOOTH_SCALABLE
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
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
Q_CORE_EXPORT void qWarning(const char *,...)
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
void setPixelSize(qreal size)
void setFamily(const QString &name)
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
Style
This enum describes the different styles of glyphs that are used to display text. ...
Definition: qfont.h:111
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
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static QString qwsFontPath()
uint style
Definition: qfont_p.h:97
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
QString family
Definition: qfont_p.h:82
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
#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
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QAbstractFontEngine class is the base class for font engine plugins in Qt for Embedded Linux...
int open(const char *, int,...)

◆ Q_GLOBAL_STATIC_WITH_ARGS()

Q_GLOBAL_STATIC_WITH_ARGS ( QFactoryLoader  ,
loader  ,
(QFontEngineFactoryInterface_iid, QLatin1String("/fontengines"), Qt::CaseInsensitive)   
) const

◆ qt_applyFontDatabaseSettings()

void qt_applyFontDatabaseSettings ( const QSettings settings)

Definition at line 524 of file qfontdatabase_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 }
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
Definition: qsettings.cpp:3460
QStringList fallbackFamilies
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
QStringList fallbackFamilies
QtFontFamily ** families
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static void initializeDb()
bool contains(const QString &key) const
Returns true if there exists a setting called key; returns false otherwise.
Definition: qsettings.cpp:3394

◆ qt_qws_init_fontdb()

void qt_qws_init_fontdb ( )

Definition at line 517 of file qfontdatabase_qws.cpp.

Referenced by QWSServerPrivate::initServer().

518 {
519  initializeDb();
520 }
static void initializeDb()

◆ qws_fontCacheDir()

QString qws_fontCacheDir ( )

Definition at line 231 of file qfontengine_qpf.cpp.

Referenced by QFontDatabasePrivate::addQPF2File(), QFontEngineQPF::cleanUpAfterClientCrash(), cleanupFontsDir(), initializeDb(), QFontDatabasePrivate::loadFromCache(), and QFontEngineQPF::QFontEngineQPF().

232 {
233  QString dir;
234 #if defined(Q_WS_QWS)
235  extern QString qws_dataDir();
236  dir = qws_dataDir();
237 #else
238  dir = QDir::tempPath();
239 #endif
240  dir.append(QLatin1String("/fonts/"));
241  QDir qd(dir);
242  if (!qd.exists() && !qd.mkpath(dir))
243  dir = QDir::tempPath();
244  return dir;
245 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString tempPath()
Returns the absolute path of the system&#39;s temporary directory.
Definition: qdir.cpp:1987
QString & append(QChar c)
Definition: qstring.cpp:1777
QString qws_dataDir()

◆ qwsFontPath()

static QString qwsFontPath ( )
static
Warning
This function is not part of the public interface.

Definition at line 252 of file qfontdatabase_qws.cpp.

Referenced by initializeDb(), and loadSingleEngine().

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 }
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
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QString location(LibraryLocation)
Returns the location specified by loc.

◆ registerFont()

static void registerFont ( QFontDatabasePrivate::ApplicationFont fnt)
static

Definition at line 722 of file qfontdatabase_qws.cpp.

Referenced by QFontDatabasePrivate::addQPF2File(), and initializeDb().

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 }
QStringList addTTFile(const QByteArray &file, const QByteArray &fontData=QByteArray())
QStringList fallbackFamilies
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
#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