1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
44 #include "qfontengine_p.h"
45 #include "qfontengine_mac_p.h"
46 #include "qfontengine_coretext_p.h"
47 #include "qfontinfo.h"
48 #include "qfontmetrics.h"
49 #include "qpaintdevice.h"
51 #include <private/qt_mac_p.h>
52 #include <private/qtextengine_p.h>
53 #include <private/qunicodetables_p.h>
54 #include <qapplication.h>
55 #include "qfontdatabase.h"
57 #include "qtextengine_p.h"
62 extern float qt_mac_defaultDpi_x(); //qpaintdevice_mac.cpp
64 int qt_mac_pixelsize(const QFontDef &def, int dpi)
67 if(def.pixelSize == -1)
68 ret = def.pointSize * dpi / qt_mac_defaultDpi_x();
73 int qt_mac_pointsize(const QFontDef &def, int dpi)
77 ret = def.pixelSize * qt_mac_defaultDpi_x() / float(dpi);
83 QString QFont::rawName() const
88 void QFont::setRawName(const QString &name)
95 QFontCache::cleanup();
101 quint32 QFont::macFontID() const // ### need 64-bit version
103 #ifdef QT_MAC_USE_COCOA
106 QFontEngine *fe = d->engineForScript(QUnicodeTables::Common);
107 if (fe && fe->type() == QFontEngine::Multi)
108 return static_cast<QFontEngineMacMulti*>(fe)->macFontID();
111 if(FMGetFontFamilyName((FMFontFamily)((UInt32)handle()), name) == noErr) {
113 GetFNum(name, &fnum);
120 // Returns an ATSUFonFamilyRef
121 Qt::HANDLE QFont::handle() const
123 #ifdef QT_MAC_USE_COCOA
124 QFontEngine *fe = d->engineForScript(QUnicodeTables::Common);
125 if (fe && fe->type() == QFontEngine::Multi)
126 return (Qt::HANDLE)static_cast<QCoreTextFontEngineMulti*>(fe)->macFontID();
131 void QFont::initialize()
134 QString QFont::defaultFamily() const
136 switch(d->request.styleHint) {
138 return QString::fromLatin1("Times New Roman");
140 return QString::fromLatin1("Courier New");
141 case QFont::Monospace:
142 return QString::fromLatin1("Courier");
143 case QFont::Decorative:
144 return QString::fromLatin1("Bookman Old Style");
146 return QString::fromLatin1("Apple Chancery");
148 return QString::fromLatin1("Papyrus");
149 case QFont::Helvetica:
152 return QString::fromLatin1("Helvetica");
156 QString QFont::lastResortFamily() const
158 return QString::fromLatin1("Helvetica");
161 QString QFont::lastResortFont() const
163 return QString::fromLatin1("Geneva");