Qt 4.8
Functions
qcoretextfontdatabase.mm File Reference
#include "qcoretextfontdatabase.h"
#include <CoreText/CoreText.h>
#include <Foundation/Foundation.h>
#include <private/qcore_mac_p.h>
#include <private/qfontengine_coretext_p.h>

Go to the source code of this file.

Functions

static QString familyNameFromPostScriptName (QHash< QString, QString > *psNameToFamily, NSString *psName)
 
static NSInteger languageMapSort (id obj1, id obj2, void *context)
 
static QFont::StyleHint styleHintFromNSString (NSString *style)
 

Function Documentation

◆ familyNameFromPostScriptName()

static QString familyNameFromPostScriptName ( QHash< QString, QString > *  psNameToFamily,
NSString *  psName 
)
static

Definition at line 94 of file qcoretextfontdatabase.mm.

Referenced by QCoreTextFontDatabase::populateFontDatabase().

96 {
98  if (psNameToFamily->contains(name)) {
99  return psNameToFamily->value(name);
100  } else {
101  QCFType<CTFontRef> font = CTFontCreateWithName((CFStringRef) psName, 12.0, NULL);
102  if (font) {
103  QCFString family = CTFontCopyFamilyName(font);
104  (*psNameToFamily)[name] = family;
105  return family;
106  }
107  }
108 
109  return name;
110 }
const struct __CFString * CFStringRef
static QString toQString(CFStringRef cfstr)
Definition: qcore_mac.cpp:47
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
const char * name

◆ languageMapSort()

static NSInteger languageMapSort ( id  obj1,
id  obj2,
void *  context 
)
static

Definition at line 82 of file qcoretextfontdatabase.mm.

Referenced by QCoreTextFontDatabase::populateFontDatabase().

83 {
84  NSArray *map1 = (NSArray *) obj1;
85  NSArray *map2 = (NSArray *) obj2;
86  NSArray *languages = (NSArray *) context;
87 
88  NSString *lang1 = [map1 objectAtIndex: 0];
89  NSString *lang2 = [map2 objectAtIndex: 0];
90 
91  return [languages indexOfObject: lang1] - [languages indexOfObject: lang2];
92 }

◆ styleHintFromNSString()

static QFont::StyleHint styleHintFromNSString ( NSString *  style)
static

Definition at line 66 of file qcoretextfontdatabase.mm.

Referenced by QCoreTextFontDatabase::populateFontDatabase().

67 {
68  if ([style isEqual: @"sans-serif"])
69  return QFont::SansSerif;
70  else if ([style isEqual: @"monospace"])
71  return QFont::Monospace;
72  else if ([style isEqual: @"cursive"])
73  return QFont::Cursive;
74  else if ([style isEqual: @"serif"])
75  return QFont::Serif;
76  else if ([style isEqual: @"fantasy"])
77  return QFont::Fantasy;
78  else
79  return QFont::AnyStyle;
80 }