//#define QT_PICTURE_DEBUG
#include <qdebug.h>
+// keep in sync with qpicture.cpp
+static const char *qt_mfhdr_tag = "QPIC"; // header tag
QT_BEGIN_NAMESPACE
Q_ASSERT(d->pic_d);
d->s.setDevice(&d->pic_d->pictb);
- d->s.setVersion(d->pic_d->formatMajor);
d->pic_d->pictb.open(QIODevice::WriteOnly | QIODevice::Truncate);
d->s.writeRawData(qt_mfhdr_tag, 4);
- d->s << (quint16) 0 << (quint16) d->pic_d->formatMajor << (quint16) d->pic_d->formatMinor;
d->s << (quint8) QPicturePrivate::PdcBegin << (quint8) sizeof(qint32);
d->pic_d->brect = QRect();
- if (d->pic_d->formatMajor >= 4) {
- QRect r = pic->boundingRect();
- d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width()
- << (qint32) r.height();
- }
+ QRect r = pic->boundingRect();
+ d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width()
+ << (qint32) r.height();
d->pic_d->trecs = 0;
d->s << (quint32)d->pic_d->trecs; // total number of records
d->pic_d->formatOk = false;
int brect_start = data_start + 2*sizeof(qint16) + 2*sizeof(quint8);
int pos = d->pic_d->pictb.pos();
d->pic_d->pictb.seek(brect_start);
- if (d->pic_d->formatMajor >= 4) { // bounding rectangle
- QRect r = static_cast<QPicture *>(d->pdev)->boundingRect();
- d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width()
- << (qint32) r.height();
- }
+ // bounding rectangle
+ QRect r = static_cast<QPicture *>(d->pdev)->boundingRect();
+ d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width()
+ << (qint32) r.height();
+ // end bounding rectangle
d->s << (quint32) d->pic_d->trecs; // write number of records
d->pic_d->pictb.seek(cs_start);
QByteArray buf = d->pic_d->pictb.buffer();
if (si.chars == 0)
QPaintEngine::drawTextItem(p, ti); // Draw as path
- if (d->pic_d->formatMajor >= 9) {
- int pos;
- SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem);
- QFont fnt = ti.font();
- fnt.setUnderline(false);
- fnt.setStrikeOut(false);
- fnt.setOverline(false);
-
- qreal justificationWidth = 0;
- if (si.justified)
- justificationWidth = si.width.toReal();
-
- d->s << p << ti.text() << fnt << ti.renderFlags() << double(fnt.d->dpi)/qt_defaultDpi() << justificationWidth;
- writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false);
- } else if (d->pic_d->formatMajor >= 8) {
- // old old (buggy) format
- int pos;
- SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem);
- d->s << QPointF(p.x(), p.y() - ti.ascent()) << ti.text() << ti.font() << ti.renderFlags();
- writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false);
- } else {
- // old (buggy) format
- int pos;
- SERIALIZE_CMD(QPicturePrivate::PdcDrawText2);
- d->s << p << ti.text();
- writeCmdLength(pos, QRectF(p, QSizeF(1,1)), true);
- }
+ int pos;
+ SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem);
+ QFont fnt = ti.font();
+ fnt.setUnderline(false);
+ fnt.setStrikeOut(false);
+ fnt.setOverline(false);
+
+ qreal justificationWidth = 0;
+ if (si.justified)
+ justificationWidth = si.width.toReal();
+
+ d->s << p << ti.text() << fnt << ti.renderFlags() << double(fnt.d->dpi)/qt_defaultDpi() << justificationWidth;
+ writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false);
}
void QPicturePaintEngine::updateState(const QPaintEngineState &state)
\sa QMovie
*/
-const char *qt_mfhdr_tag = "QPIC"; // header tag
-static const quint16 mfhdr_maj = 11; // major version #
+// keep in sync with qpaintengine_pic.cpp
+static const char *qt_mfhdr_tag = "QPIC"; // header tag
/*!
Constructs an empty picture.
QDataStream s;
s.setDevice(&d->pictb); // attach data stream to buffer
s.device()->seek(10); // go directly to the data
- s.setVersion(mfhdr_maj);
quint8 c, clen;
quint32 nrecords;
return false;
}
- quint16 major, minor;
- s >> major >> minor; // read version number
- if (major > mfhdr_maj) { // new, incompatible version
- qWarning("QPicturePaintEngine::checkFormat: Incompatible version %d.%d",
- major, minor);
- pictb.close();
- return false;
- }
- s.setVersion(major);
-
quint8 c, clen;
s >> c >> clen;
if (c == QPicturePrivate::PdcBegin) {
// "init"; this code is similar to the beginning of QPicture::cmd()
sr.setDevice(&r.d_func()->pictb);
- sr.setVersion(mfhdr_maj);
quint32 len;
s >> len;
QByteArray data;
class QPaintEngine;
-extern const char *qt_mfhdr_tag;
-
class QPicturePrivate
{
friend class QPicturePaintEngine;
QBuffer pictb;
int trecs;
bool formatOk;
- int formatMajor;
- int formatMinor;
QRect brect;
QRect override_rect;
QScopedPointer<QPaintEngine> paintEngine;
return foundries[count++];
}
-// ### copied to tools/makeqpf/qpf2.cpp
-
// see the Unicode subset bitfields in the MSDN docs
static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {
// Any,
Q_GADGET
Q_ENUMS(WritingSystem)
public:
- // do not re-order or delete entries from this enum without updating the
- // QPF2 format and makeqpf!!
enum WritingSystem {
Any,
friend class QFontDialog;
friend class QFontDialogPrivate;
friend class QFontEngineMultiXLFD;
- friend class QFontEngineMultiQWS;
- friend class QFontEngineMultiS60;
- friend class QFontEngineMultiQPA;
QFontDatabasePrivate *d;
};
line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale));
underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale));
} else {
- // copied from QFontEngineQPF
// ad hoc algorithm
int score = fontDef.weight * fontDef.pixelSize;
line_thickness = score / 700;
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfontengine_qpf_p.h"
-
-#include "qpaintengine_raster_p.h"
-#include <QtCore/qlibraryinfo.h>
-#include <QtCore/qfileinfo.h>
-
-#include <QtCore/qfile.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qbuffer.h>
-#if !defined(QT_NO_FREETYPE)
-#include "qfontengine_ft_p.h"
-#endif
-#include "qcore_unix_p.h" // overrides QT_OPEN
-
-// for mmap
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
-
-QString qws_fontCacheDir()
-{
- QString dir = QDir::tempPath();
- dir.append(QLatin1String("/fonts/"));
- QDir qd(dir);
- if (!qd.exists() && !qd.mkpath(dir))
- dir = QDir::tempPath();
- return dir;
-}
-
-
-/*
- Creates a new multi qws engine.
-
- This function takes ownership of the QFontEngine, increasing it's refcount.
-*/
-QFontEngineMultiQWS::QFontEngineMultiQWS(QFontEngine *fe, int _script, const QStringList &fallbacks)
- : QFontEngineMulti(fallbacks.size() + 1),
- fallbackFamilies(fallbacks), script(_script)
-{
- engines[0] = fe;
- fe->ref.ref();
- fontDef = engines[0]->fontDef;
-}
-
-void QFontEngineMultiQWS::loadEngine(int at)
-{
- Q_ASSERT(at < engines.size());
- Q_ASSERT(engines.at(at) == 0);
-
- QFontDef request = fontDef;
- request.styleStrategy |= QFont::NoFontMerging;
- request.family = fallbackFamilies.at(at-1);
- engines[at] = QFontDatabase::findFont(script,
- /*fontprivate*/0,
- request);
- Q_ASSERT(engines[at]);
- engines[at]->ref.ref();
- engines[at]->fontDef = request;
-}
-
-void QFontEngineMultiQWS::draw(QPaintEngine */*p*/, qreal /*x*/, qreal /*y*/, const QTextItemInt &/*si*/)
-{
- qFatal("QFontEngineMultiQWS::draw should never be called!");
-}
-
-QT_END_NAMESPACE
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFONTENGINE_QPF_P_H
-#define QFONTENGINE_QPF_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qfontengine_p.h"
-#include <qendian.h>
-#include <qbuffer.h>
-
-
-QT_BEGIN_NAMESPACE
-
-
-class QFontEngineMultiQWS : public QFontEngineMulti
-{
-public:
- QFontEngineMultiQWS(QFontEngine *fe, int script, const QStringList &fallbacks);
-
- void loadEngine(int at);
- void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si);
-
-private:
- QStringList fallbackFamilies;
- int script;
-};
-
-QT_END_NAMESPACE
-
-#endif // QFONTENGINE_QPF_P_H
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-static const QFontEngineQPF::TagType tagTypes[QFontEngineQPF::NumTags] = {
- QFontEngineQPF::StringType, // FontName
- QFontEngineQPF::StringType, // FileName
- QFontEngineQPF::UInt32Type, // FileIndex
- QFontEngineQPF::UInt32Type, // FontRevision
- QFontEngineQPF::StringType, // FreeText
- QFontEngineQPF::FixedType, // Ascent
- QFontEngineQPF::FixedType, // Descent
- QFontEngineQPF::FixedType, // Leading
- QFontEngineQPF::FixedType, // XHeight
- QFontEngineQPF::FixedType, // AverageCharWidth
- QFontEngineQPF::FixedType, // MaxCharWidth
- QFontEngineQPF::FixedType, // LineThickness
- QFontEngineQPF::FixedType, // MinLeftBearing
- QFontEngineQPF::FixedType, // MinRightBearing
- QFontEngineQPF::FixedType, // UnderlinePosition
- QFontEngineQPF::UInt8Type, // GlyphFormat
- QFontEngineQPF::UInt8Type, // PixelSize
- QFontEngineQPF::UInt8Type, // Weight
- QFontEngineQPF::UInt8Type, // Style
- QFontEngineQPF::StringType, // EndOfHeader
- QFontEngineQPF::BitFieldType// WritingSystems
-};
-
-