Qt 4.8
qrawfont_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 test suite 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 <QtCore/qglobal.h>
43 
44 #if !defined(QT_NO_RAWFONT)
45 
46 #include "qrawfont_p.h"
47 #include "qfontengine_coretext_p.h"
48 
50 
52 {
53 }
54 
55 static void releaseFontData(void* info, const void* data, size_t size)
56 {
57  Q_UNUSED(data);
58  Q_UNUSED(size);
59  delete (QByteArray*)info;
60 }
61 
62 extern int qt_defaultDpi();
63 
67 {
68  // Mac OS X ignores it
69  Q_UNUSED(hintingPreference);
70 
71  QByteArray* fontDataCopy = new QByteArray(fontData);
72  QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(fontDataCopy,
73  fontDataCopy->constData(), fontDataCopy->size(), releaseFontData);
74 
75  CGFontRef cgFont = CGFontCreateWithDataProvider(dataProvider);
76 
77  if (cgFont == NULL) {
78  qWarning("QRawFont::platformLoadFromData: CGFontCreateWithDataProvider failed");
79  } else {
80  QFontDef def;
81  def.pixelSize = pixelSize;
82  def.pointSize = pixelSize * 72.0 / qt_defaultDpi();
83  fontEngine = new QCoreTextFontEngine(cgFont, def);
84  CFRelease(cgFont);
85  fontEngine->ref.ref();
86  }
87 }
88 
90 
91 #endif // QT_NO_RAWFONT
QAtomicInt ref
HintingPreference
This enum describes the different levels of hinting that can be applied to glyphs to improve legibili...
Definition: qfont.h:96
double qreal
Definition: qglobal.h:1193
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
qreal pointSize
Definition: qfont_p.h:89
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool ref()
Atomically increments the value of this QAtomicInt.
static void releaseFontData(void *info, const void *data, size_t size)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static float pixelSize(const QFontDef &request, int dpi)
Definition: qfont_win.cpp:80
void platformLoadFromData(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference)
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
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
int qt_defaultDpi()
Definition: qfont.cpp:240
void platformCleanUp()
Definition: qrawfont_ft.cpp:98
QFont::HintingPreference hintingPreference
Definition: qrawfont_p.h:112
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
QFontEngine * fontEngine
Definition: qrawfont_p.h:111
#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