Qt 4.8
qfontdatabase_mac.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 <private/qt_mac_p.h>
43 #include "qfontengine_p.h"
44 #include <qfile.h>
45 #include <qabstractfileengine.h>
46 #include <stdlib.h>
47 #include <qendian.h>
48 #include <private/qfontengine_coretext_p.h>
49 #include <private/qfontengine_mac_p.h>
50 
52 
53 int qt_mac_pixelsize(const QFontDef &def, int dpi); //qfont_mac.cpp
54 int qt_mac_pointsize(const QFontDef &def, int dpi); //qfont_mac.cpp
55 
56 #ifndef QT_MAC_USE_COCOA
57 static void initWritingSystems(QtFontFamily *family, ATSFontRef atsFont)
58 {
59  ByteCount length = 0;
60  if (ATSFontGetTable(atsFont, MAKE_TAG('O', 'S', '/', '2'), 0, 0, 0, &length) != noErr)
61  return;
62  QVarLengthArray<uchar> os2Table(length);
63  if (length < 86
64  || ATSFontGetTable(atsFont, MAKE_TAG('O', 'S', '/', '2'), 0, length, os2Table.data(), &length) != noErr)
65  return;
66 
67  // See also qfontdatabase_win.cpp, offsets taken from OS/2 table in the TrueType spec
68  quint32 unicodeRange[4] = {
69  qFromBigEndian<quint32>(os2Table.data() + 42),
70  qFromBigEndian<quint32>(os2Table.data() + 46),
71  qFromBigEndian<quint32>(os2Table.data() + 50),
72  qFromBigEndian<quint32>(os2Table.data() + 54)
73  };
74  quint32 codePageRange[2] = { qFromBigEndian<quint32>(os2Table.data() + 78), qFromBigEndian<quint32>(os2Table.data() + 82) };
76 #if 0
78  ATSFontGetName(atsFont, kATSOptionFlagsDefault, &name);
79  qDebug() << systems.count() << "writing systems for" << QString(name);
80 qDebug() << "first char" << hex << unicodeRange[0];
81  for (int i = 0; i < systems.count(); ++i)
82  qDebug() << QFontDatabase::writingSystemName(systems.at(i));
83 #endif
84  for (int i = 0; i < systems.count(); ++i)
85  family->writingSystems[systems.at(i)] = QtFontFamily::Supported;
86 }
87 #else
88 // this could become a list of all languages used for each writing
89 // system, instead of using the single most common language.
90 static const char *languageForWritingSystem[] = {
91  0, // Any
92  "en", // Latin
93  "el", // Greek
94  "ru", // Cyrillic
95  "hy", // Armenian
96  "he", // Hebrew
97  "ar", // Arabic
98  "syr", // Syriac
99  "div", // Thaana
100  "hi", // Devanagari
101  "bn", // Bengali
102  "pa", // Gurmukhi
103  "gu", // Gujarati
104  "or", // Oriya
105  "ta", // Tamil
106  "te", // Telugu
107  "kn", // Kannada
108  "ml", // Malayalam
109  "si", // Sinhala
110  "th", // Thai
111  "lo", // Lao
112  "bo", // Tibetan
113  "my", // Myanmar
114  "ka", // Georgian
115  "km", // Khmer
116  "zh-Hans", // SimplifiedChinese
117  "zh-Hant", // TraditionalChinese
118  "ja", // Japanese
119  "ko", // Korean
120  "vi", // Vietnamese
121  0, // Symbol
122  0, // Ogham
123  0, // Runic
124  0 // N'Ko
125 };
126 enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
127 #endif
128 
129 static void initializeDb()
130 {
131  QFontDatabasePrivate *db = privateDb();
132  if(!db || db->count)
133  return;
134 
135 #if defined(QT_MAC_USE_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
137  QCFType<CTFontCollectionRef> collection = CTFontCollectionCreateFromAvailableFonts(0);
138  if(!collection)
139  return;
140  QCFType<CFArrayRef> fonts = CTFontCollectionCreateMatchingFontDescriptors(collection);
141  if(!fonts)
142  return;
143  QString foundry_name = "CoreText";
144  const int numFonts = CFArrayGetCount(fonts);
145  for(int i = 0; i < numFonts; ++i) {
146  CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fonts, i);
147  QCFString family_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL);
148  QCFString style_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontStyleNameAttribute, NULL);
149  QtFontFamily *family = db->family(family_name, true);
150 
151  if (QCFType<CFArrayRef> languages = (CFArrayRef) CTFontDescriptorCopyAttribute(font, kCTFontLanguagesAttribute)) {
152  CFIndex length = CFArrayGetCount(languages);
153  for (int i = 1; i < LanguageCount; ++i) {
154  if (!languageForWritingSystem[i])
155  continue;
156  QCFString lang = CFStringCreateWithCString(NULL, languageForWritingSystem[i], kCFStringEncodingASCII);
157  if (CFArrayContainsValue(languages, CFRangeMake(0, length), lang))
159  }
160  }
161 
162  QtFontFoundry *foundry = family->foundry(foundry_name, true);
163 
164  QtFontStyle::Key styleKey;
165  QString styleName = style_name;
166  if(QCFType<CFDictionaryRef> styles = (CFDictionaryRef)CTFontDescriptorCopyAttribute(font, kCTFontTraitsAttribute)) {
167  if(CFNumberRef weight = (CFNumberRef)CFDictionaryGetValue(styles, kCTFontWeightTrait)) {
168  Q_ASSERT(CFNumberIsFloatType(weight));
169  double d;
170  if(CFNumberGetValue(weight, kCFNumberDoubleType, &d)) {
171  //qDebug() << "BOLD" << (QString)family_name << d;
172  styleKey.weight = (d > 0.0) ? QFont::Bold : QFont::Normal;
173  }
174  }
175  if(CFNumberRef italic = (CFNumberRef)CFDictionaryGetValue(styles, kCTFontSlantTrait)) {
176  Q_ASSERT(CFNumberIsFloatType(italic));
177  double d;
178  if(CFNumberGetValue(italic, kCFNumberDoubleType, &d)) {
179  //qDebug() << "ITALIC" << (QString)family_name << d;
180  if (d > 0.0)
181  styleKey.style = QFont::StyleItalic;
182  }
183  }
184  }
185 
186  QtFontStyle *style = foundry->style(styleKey, styleName, true);
187  style->smoothScalable = true;
188  if(QCFType<CFNumberRef> size = (CFNumberRef)CTFontDescriptorCopyAttribute(font, kCTFontSizeAttribute)) {
189  //qDebug() << "WHEE";
190  int pixel_size=0;
191  if(CFNumberIsFloatType(size)) {
192  double d;
193  CFNumberGetValue(size, kCFNumberDoubleType, &d);
194  pixel_size = d;
195  } else {
196  CFNumberGetValue(size, kCFNumberIntType, &pixel_size);
197  }
198  //qDebug() << "SIZE" << (QString)family_name << pixel_size;
199  if(pixel_size)
200  style->pixelSize(pixel_size, true);
201  } else {
202  //qDebug() << "WTF?";
203  }
204  }
205 } else
206 #endif
207  {
208 #ifndef QT_MAC_USE_COCOA
209  FMFontIterator it;
210  if (!FMCreateFontIterator(0, 0, kFMUseGlobalScopeOption, &it)) {
211  while (true) {
212  FMFont fmFont;
213  if (FMGetNextFont(&it, &fmFont) != noErr)
214  break;
215 
216  FMFontFamily fmFamily;
217  FMFontStyle fmStyle;
218  QString familyName;
219 
220  QtFontStyle::Key styleKey;
221 
222  ATSFontRef atsFont = FMGetATSFontRefFromFont(fmFont);
223 
224  if (!FMGetFontFamilyInstanceFromFont(fmFont, &fmFamily, &fmStyle)) {
225  { //sanity check the font, and see if we can use it at all! --Sam
226  ATSUFontID fontID;
227  if(ATSUFONDtoFontID(fmFamily, 0, &fontID) != noErr)
228  continue;
229  }
230 
231  if (fmStyle & ::italic)
232  styleKey.style = QFont::StyleItalic;
233  if (fmStyle & ::bold)
234  styleKey.weight = QFont::Bold;
235 
236  ATSFontFamilyRef familyRef = FMGetATSFontFamilyRefFromFontFamily(fmFamily);
237  QCFString cfFamilyName;;
238  ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &cfFamilyName);
239  familyName = cfFamilyName;
240  } else {
241  QCFString cfFontName;
242  ATSFontGetName(atsFont, kATSOptionFlagsDefault, &cfFontName);
243  familyName = cfFontName;
244  quint16 macStyle = 0;
245  {
246  uchar data[4];
247  ByteCount len = 4;
248  if (ATSFontGetTable(atsFont, MAKE_TAG('h', 'e', 'a', 'd'), 44, 4, &data, &len) == noErr)
249  macStyle = qFromBigEndian<quint16>(data);
250  }
251  if (macStyle & 1)
252  styleKey.weight = QFont::Bold;
253  if (macStyle & 2)
254  styleKey.style = QFont::StyleItalic;
255  }
256 
257  QtFontFamily *family = db->family(familyName, true);
258  QtFontFoundry *foundry = family->foundry(QString(), true);
259  QtFontStyle *style = foundry->style(styleKey, QString(), true);
260  style->pixelSize(0, true);
261  style->smoothScalable = true;
262 
263  initWritingSystems(family, atsFont);
264  }
265  FMDisposeFontIterator(&it);
266  }
267 #endif
268  }
269 
270 }
271 
272 static inline void load(const QString & = QString(), int = -1)
273 {
274  initializeDb();
275 }
276 
277 static const char *styleHint(const QFontDef &request)
278 {
279  const char *stylehint = 0;
280  switch (request.styleHint) {
281  case QFont::SansSerif:
282  stylehint = "Arial";
283  break;
284  case QFont::Serif:
285  stylehint = "Times New Roman";
286  break;
287  case QFont::TypeWriter:
288  stylehint = "Courier New";
289  break;
290  default:
291  if (request.fixedPitch)
292  stylehint = "Courier New";
293  break;
294  }
295  return stylehint;
296 }
297 
298 static inline float weightToFloat(unsigned int weight)
299 {
300  return (weight - 50) / 100.0;
301 }
302 
304 {
305 #if defined(QT_MAC_USE_COCOA)
306  QCFString fontName = NULL;
307 #else
308  ATSFontFamilyRef familyRef = 0;
309  ATSFontRef fontRef = 0;
310 #endif
311 
312  QStringList family_list = familyList(req);
313 
314  const char *stylehint = styleHint(req);
315  if (stylehint)
316  family_list << QLatin1String(stylehint);
317 
318  // add QFont::defaultFamily() to the list, for compatibility with previous versions
319  family_list << QApplication::font().defaultFamily();
320 
321  QMutexLocker locker(fontDatabaseMutex());
322  QFontDatabasePrivate *db = privateDb();
323  if (!db->count)
324  initializeDb();
325  for (int i = 0; i < family_list.size(); ++i) {
326  for (int k = 0; k < db->count; ++k) {
327  if (db->families[k]->name.compare(family_list.at(i), Qt::CaseInsensitive) == 0) {
328 #if defined(QT_MAC_USE_COCOA)
329  CFStringRef familyName = QCFString::toCFStringRef(db->families[k]->name);
330  QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithAttributes(
331  QCFType<CFDictionaryRef>(CFDictionaryCreate(kCFAllocatorDefault,
332  (const void**)&kCTFontFamilyNameAttribute,
333  (const void**)&familyName, 1,
334  &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)));
335  CFRelease(familyName);
336  QCFType<CTFontRef> ctFont = CTFontCreateWithFontDescriptor(descriptor, 0, NULL);
337  if (ctFont) {
338  fontName = CTFontCopyFullName(ctFont);
339  goto found;
340  }
341 #else
342  familyRef = ATSFontFamilyFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
343  if (familyRef) {
344  fontRef = ATSFontFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
345  goto found;
346  }
347 #endif
348  }
349  }
350  }
351 found:
352 #ifdef QT_MAC_USE_COCOA
353  if (fontName)
354  return new QCoreTextFontEngineMulti(fontName, req, d->kerning);
355 #else
356  if (familyRef) {
357  QCFString actualName;
358  if (ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &actualName) == noErr)
359  req.family = actualName;
360  return new QFontEngineMacMulti(familyRef, fontRef, req, d->kerning);
361  }
362 #endif
363  return NULL;
364 }
365 
367 {
368  // sanity checks
369  if(!qApp)
370  qWarning("QFont: Must construct a QApplication before a QFont");
371 
372  Q_ASSERT(script >= 0 && script < QUnicodeTables::ScriptCount);
373  Q_UNUSED(script);
374 
375  QFontDef req = d->request;
376  req.pixelSize = qt_mac_pixelsize(req, d->dpi);
377 
378  // set the point size to 0 to get better caching
379  req.pointSize = 0;
381 
382  if(!(d->engineData = QFontCache::instance()->findEngineData(key))) {
383  d->engineData = new QFontEngineData;
385  } else {
386  d->engineData->ref.ref();
387  }
388  if(d->engineData->engine) // already loaded
389  return;
390 
391  // set it to the actual pointsize, so QFontInfo will do the right thing
393 
395  if(!e && qt_enable_test_font && req.family == QLatin1String("__Qt__Box__Engine__")) {
396  e = new QTestFontEngine(req.pixelSize);
397  e->fontDef = req;
398  }
399 
400  if(e) {
401  e->ref.ref();
402  d->engineData->engine = e;
403  return; // the font info and fontdef should already be filled
404  }
405 
406  QFontEngine *engine = NULL;
407 #if defined(QT_MAC_USE_COCOA)
408  // Shortcut to get the font directly without going through the font database
409  if (!req.family.isEmpty() && !req.styleName.isEmpty()) {
410  QCFString expectedFamily = QCFString(req.family);
411  QCFString expectedStyle = QCFString(req.styleName);
412 
413  QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(NULL, 0,
414  &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
415  CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, expectedFamily);
416  CFDictionaryAddValue(attributes, kCTFontStyleNameAttribute, expectedStyle);
417 
418  QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithAttributes(attributes);
419  CGAffineTransform transform = qt_transform_from_fontdef(req);
420  QCFType<CTFontRef> ctFont = CTFontCreateWithFontDescriptor(descriptor, req.pixelSize, &transform);
421  if (ctFont) {
422  QCFString familyName = CTFontCopyFamilyName(ctFont);
423  // Only accept the font if the family name is exactly the same as we specified
424  if (CFEqual(expectedFamily, familyName)) {
425  engine = new QCoreTextFontEngineMulti(ctFont, req, d->kerning);
426  }
427  }
428  }
429 #endif
430  if (!engine)
431  engine = loadFromDatabase(req, d);
432 
433  if (engine) {
434  d->engineData->engine = engine;
435  engine->ref.ref();
436  QFontCache::instance()->insertEngine(key, engine);
437  }
438 }
439 
441 {
442  ATSFontContainerRef handle;
443  OSStatus e = noErr;
444 
445  if(fnt->data.isEmpty()) {
446 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
448  FSRef ref;
449  if(qt_mac_create_fsref(fnt->fileName, &ref) != noErr)
450  return;
451 
452  ATSFontActivateFromFileReference(&ref, kATSFontContextLocal, kATSFontFormatUnspecified, 0, kATSOptionFlagsDefault, &handle);
453  } else
454 #endif
455  {
456 #ifndef Q_WS_MAC64
457  FSSpec spec;
458  if(qt_mac_create_fsspec(fnt->fileName, &spec) != noErr)
459  return;
460 
461  e = ATSFontActivateFromFileSpecification(&spec, kATSFontContextLocal, kATSFontFormatUnspecified,
462  0, kATSOptionFlagsDefault, &handle);
463 #endif
464  }
465  } else {
466  e = ATSFontActivateFromMemory((void *)fnt->data.constData(), fnt->data.size(), kATSFontContextLocal,
467  kATSFontFormatUnspecified, 0, kATSOptionFlagsDefault, &handle);
468 
469  fnt->data = QByteArray();
470  }
471 
472  if(e != noErr)
473  return;
474 
475  ItemCount fontCount = 0;
476  e = ATSFontFindFromContainer(handle, kATSOptionFlagsDefault, 0, 0, &fontCount);
477  if(e != noErr)
478  return;
479 
480  QVarLengthArray<ATSFontRef> containedFonts(fontCount);
481  e = ATSFontFindFromContainer(handle, kATSOptionFlagsDefault, fontCount, containedFonts.data(), &fontCount);
482  if(e != noErr)
483  return;
484 
485  fnt->families.clear();
486 #if defined(QT_MAC_USE_COCOA)
487  // Make sure that the family name set on the font matches what
488  // kCTFontFamilyNameAttribute returns in initializeDb().
489  // So far the best solution seems find the installed font
490  // using CoreText and get the family name from it.
491  // (ATSFontFamilyGetName appears to be the correct API, but also
492  // returns the font display name.)
493  for(int i = 0; i < containedFonts.size(); ++i) {
494  QCFString fontPostScriptName;
495  ATSFontGetPostScriptName(containedFonts[i], kATSOptionFlagsDefault, &fontPostScriptName);
496  QCFType<CTFontDescriptorRef> font = CTFontDescriptorCreateWithNameAndSize(fontPostScriptName, 14);
497  QCFString familyName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
498  fnt->families.append(familyName);
499  }
500 #else
501  for(int i = 0; i < containedFonts.size(); ++i) {
502  QCFString family;
503  ATSFontGetName(containedFonts[i], kATSOptionFlagsDefault, &family);
504  fnt->families.append(family);
505  }
506 #endif
507 
508  fnt->handle = handle;
509 }
510 
512 {
513  QMutexLocker locker(fontDatabaseMutex());
514 
515  QFontDatabasePrivate *db = privateDb();
516  if(handle < 0 || handle >= db->applicationFonts.count())
517  return false;
518 
519  OSStatus e = ATSFontDeactivate(db->applicationFonts.at(handle).handle,
520  /*iRefCon=*/0, kATSOptionFlagsDefault);
521  if(e != noErr)
522  return false;
523 
525 
526  db->invalidate();
527  return true;
528 }
529 
531 {
532  QMutexLocker locker(fontDatabaseMutex());
533 
534  QFontDatabasePrivate *db = privateDb();
535  for(int i = 0; i < db->applicationFonts.count(); ++i) {
536  if(!removeApplicationFont(i))
537  return false;
538  }
539  return true;
540 }
541 
543 {
544  return true;
545 }
546 
548 {
549  QCFString expectedFamily = QCFString(family);
550 
551  QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(NULL, 0,
552  &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
553  CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, expectedFamily);
554  QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithAttributes(attributes);
555 
556  QCFType<CFMutableSetRef> mandatoryAttributes = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);
557  CFSetAddValue(mandatoryAttributes, kCTFontFamilyNameAttribute);
558 
559  QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(descriptor, 0.0, NULL);
560  QCFType<CTFontDescriptorRef> matched = CTFontDescriptorCreateMatchingFontDescriptor(descriptor, mandatoryAttributes);
561  if (!matched)
562  return family;
563 
564  QCFString familyName = (CFStringRef) CTFontDescriptorCopyLocalizedAttribute(matched, kCTFontFamilyNameAttribute, NULL);
565  return familyName;
566 }
567 
QAtomicInt ref
uint fixedPitch
Definition: qfont_p.h:96
static bool removeAllApplicationFonts()
Removes all application-local fonts previously added using addApplicationFont() and addApplicationFon...
double d
Definition: qnumeric_p.h:62
const struct __CFString * CFStringRef
OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec)
Definition: qcore_mac.cpp:131
QFont font(const QString &family, const QString &style, int pointSize) const
Returns a QFont object that has family family, style style and point size pointSize.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QtFontStyle * style(const QtFontStyle::Key &, const QString &=QString(), bool=false)
static const char * styleHint(const QFontDef &request)
qreal pointSize
Definition: qfont_p.h:89
#define it(className, varName)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static float weightToFloat(unsigned int weight)
static CFStringRef toCFStringRef(const QString &str)
Definition: qcore_mac.cpp:69
void insertEngine(const Key &key, QFontEngine *engine)
Definition: qfont.cpp:3073
int qt_mac_pixelsize(const QFontDef &def, int dpi)
Definition: qfont_mac.cpp:64
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool ref()
Atomically increments the value of this QAtomicInt.
quint32 qFromBigEndian< quint32 >(const uchar *src)
Definition: qendian.h:239
The QString class provides a Unicode character string.
Definition: qstring.h:83
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 const char * languageForWritingSystem[]
static QFontCache * instance()
Definition: qfont.cpp:2919
OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref)
Definition: qcore_mac.cpp:125
static QFont font()
Returns the default application font.
#define MAKE_TAG(ch1, ch2, ch3, ch4)
Q_CORE_EXPORT void qDebug(const char *,...)
unsigned char uchar
Definition: qglobal.h:994
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
static QStringList familyList(const QFontDef &req)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QFontEngine * loadFromDatabase(QFontDef &req, const QFontPrivate *d)
QtFontFamily ** families
#define qApp
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
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
static void initWritingSystems(QtFontFamily *family, ATSFontRef atsFont)
unsigned short quint16
Definition: qglobal.h:936
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
static bool supportsThreadedFontRendering()
Returns true if font rendering is supported outside the GUI thread, false otherwise.
static void initializeDb()
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
bool qt_enable_test_font
static QString resolveFontFamilyAlias(const QString &family)
void clear()
Removes all items from the list.
Definition: qlist.h:764
QAtomicInt ref
Definition: qfont_p.h:152
signed long OSStatus
static bool removeApplicationFont(int id)
Removes the previously loaded application font identified by id.
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
qreal pixelSize
Definition: qfont_p.h:90
QtFontFamily * family(const QString &f, bool=false)
quint16 qFromBigEndian< quint16 >(const uchar *src)
Definition: qendian.h:249
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
int compare(const QString &s) const
Definition: qstring.cpp:5037
unsigned char writingSystems[QFontDatabase::WritingSystemsCount]
QtFontSize * pixelSize(unsigned short size, bool=false)
int key
QString styleName
Definition: qfont_p.h:83
unsigned int quint32
Definition: qglobal.h:938
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
QString defaultFamily() const
Returns the family name that corresponds to the current style hint.
Definition: qfont_mac.cpp:134
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
int qt_mac_pointsize(const QFontDef &def, int dpi)
Definition: qfont_mac.cpp:73
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
int screen
Definition: qfont_p.h:181
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef)
QFontEngineData * findEngineData(const Key &key) const
Definition: qfont.cpp:3036
QFontEngine * findEngine(const Key &key)
Definition: qfont.cpp:3054
QFontDef fontDef
QFontEngine * engine
Definition: qfont_p.h:158
QVector< ApplicationFont > applicationFonts
uint kerning
Definition: qfont_p.h:191
QtFontFoundry * foundry(const QString &f, bool=false)
static QString writingSystemName(WritingSystem writingSystem)
Returns the names the writingSystem (e.g.
QString family
Definition: qfont_p.h:82
static void load(const QString &=QString(), int=-1)
const struct __CFArray * CFArrayRef
QFontEngineData * engineData
Definition: qfont_p.h:179
uint styleHint
Definition: qfont_p.h:93
#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
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
QFontEngine * engine(int at) const
int size() const
QList< QFontDatabase::WritingSystem > qt_determine_writing_systems_from_truetype_bits(quint32 unicodeRange[4], quint32 codePageRange[2])