author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 10:37:55 +0300 | |
changeset 33 | 3e2da88830cd |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qfont.h" |
|
43 |
#include "qfont_p.h" |
|
44 |
#include "qfontengine_p.h" |
|
45 |
#include "qfontinfo.h" |
|
46 |
#include "qfontmetrics.h" |
|
47 |
#include "qpaintdevice.h" |
|
48 |
#include "qstring.h" |
|
49 |
#include <private/qt_mac_p.h> |
|
50 |
#include <private/qtextengine_p.h> |
|
51 |
#include <private/qunicodetables_p.h> |
|
52 |
#include <qapplication.h> |
|
53 |
#include "qfontdatabase.h" |
|
54 |
#include <qpainter.h> |
|
55 |
#include "qtextengine_p.h" |
|
56 |
#include <stdlib.h> |
|
57 |
||
58 |
QT_BEGIN_NAMESPACE |
|
59 |
||
60 |
extern float qt_mac_defaultDpi_x(); //qpaintdevice_mac.cpp |
|
61 |
||
62 |
int qt_mac_pixelsize(const QFontDef &def, int dpi) |
|
63 |
{ |
|
64 |
float ret; |
|
65 |
if(def.pixelSize == -1) |
|
66 |
ret = def.pointSize * dpi / qt_mac_defaultDpi_x(); |
|
67 |
else |
|
68 |
ret = def.pixelSize; |
|
69 |
return qRound(ret); |
|
70 |
} |
|
71 |
int qt_mac_pointsize(const QFontDef &def, int dpi) |
|
72 |
{ |
|
73 |
float ret; |
|
74 |
if(def.pointSize < 0) |
|
75 |
ret = def.pixelSize * qt_mac_defaultDpi_x() / float(dpi); |
|
76 |
else |
|
77 |
ret = def.pointSize; |
|
78 |
return qRound(ret); |
|
79 |
} |
|
80 |
||
81 |
QString QFont::rawName() const |
|
82 |
{ |
|
83 |
return family(); |
|
84 |
} |
|
85 |
||
86 |
void QFont::setRawName(const QString &name) |
|
87 |
{ |
|
88 |
setFamily(name); |
|
89 |
} |
|
90 |
||
91 |
void QFont::cleanup() |
|
92 |
{ |
|
93 |
QFontCache::cleanup(); |
|
94 |
} |
|
95 |
||
96 |
/*! |
|
97 |
Returns an ATSUFontID |
|
98 |
*/ |
|
99 |
quint32 QFont::macFontID() const // ### need 64-bit version |
|
100 |
{ |
|
101 |
#ifdef QT_MAC_USE_COCOA |
|
102 |
return 0; |
|
103 |
#elif 1 |
|
104 |
QFontEngine *fe = d->engineForScript(QUnicodeTables::Common); |
|
105 |
if (fe && fe->type() == QFontEngine::Multi) |
|
106 |
return static_cast<QFontEngineMacMulti*>(fe)->macFontID(); |
|
107 |
#else |
|
108 |
Str255 name; |
|
109 |
if(FMGetFontFamilyName((FMFontFamily)((UInt32)handle()), name) == noErr) { |
|
110 |
short fnum; |
|
111 |
GetFNum(name, &fnum); |
|
112 |
return fnum; |
|
113 |
} |
|
114 |
#endif |
|
115 |
return 0; |
|
116 |
} |
|
117 |
||
118 |
// Returns an ATSUFonFamilyRef |
|
119 |
Qt::HANDLE QFont::handle() const |
|
120 |
{ |
|
121 |
#if 0 |
|
122 |
QFontEngine *fe = d->engineForScript(QUnicodeTables::Common); |
|
123 |
if (fe && fe->type() == QFontEngine::Mac) |
|
124 |
return (Qt::HANDLE)static_cast<QFontEngineMacMulti*>(fe)->fontFamilyRef(); |
|
125 |
#endif |
|
126 |
return 0; |
|
127 |
} |
|
128 |
||
129 |
void QFont::initialize() |
|
130 |
{ } |
|
131 |
||
132 |
QString QFont::defaultFamily() const |
|
133 |
{ |
|
134 |
switch(d->request.styleHint) { |
|
135 |
case QFont::Times: |
|
136 |
return QString::fromLatin1("Times New Roman"); |
|
137 |
case QFont::Courier: |
|
138 |
return QString::fromLatin1("Courier New"); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
139 |
case QFont::Monospace: |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
140 |
return QString::fromLatin1("Courier"); |
0 | 141 |
case QFont::Decorative: |
142 |
return QString::fromLatin1("Bookman Old Style"); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
143 |
case QFont::Cursive: |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
144 |
return QString::fromLatin1("Apple Chancery"); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
145 |
case QFont::Fantasy: |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
146 |
return QString::fromLatin1("Papyrus"); |
0 | 147 |
case QFont::Helvetica: |
148 |
case QFont::System: |
|
149 |
default: |
|
150 |
return QString::fromLatin1("Helvetica"); |
|
151 |
} |
|
152 |
} |
|
153 |
||
154 |
QString QFont::lastResortFamily() const |
|
155 |
{ |
|
156 |
return QString::fromLatin1("Helvetica"); |
|
157 |
} |
|
158 |
||
159 |
QString QFont::lastResortFont() const |
|
160 |
{ |
|
161 |
return QString::fromLatin1("Geneva"); |
|
162 |
} |
|
163 |
||
164 |
QT_END_NAMESPACE |