📄 qtextengine_p.h
字号:
/******************************************************************************** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.**** This file is part of the QtGui module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.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 GNU** General Public Licensing requirements will be met:** http://www.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#ifndef QTEXTENGINE_P_H#define QTEXTENGINE_P_H//// W A R N I N G// -------------//// This file is not part of the Qt API. It exists for the convenience// of other Qt classes. This header file may change from version to// version without notice, or even be removed.//// We mean it.//#include "QtCore/qglobal.h"#include "QtCore/qstring.h"#include "QtCore/qnamespace.h"#include "QtGui/qtextlayout.h"#include "private/qtextformat_p.h"#include "private/qfont_p.h"#include "QtCore/qvector.h"#include "QtGui/qpaintengine.h"#include "QtGui/qtextobject.h"#include "QtGui/qtextoption.h"#include "private/qtextdocument_p.h"#include "QtCore/qset.h"#include <stdlib.h>#ifndef Q_OS_TEMP#include <assert.h>#endif // Q_OS_TEMPclass QFontPrivate;class QFontEngine;class QString;class QOpenType;class QPainter;class QAbstractTextDocumentLayout;struct QFixed {public: QFixed() : val(0) {} QFixed(int i) : val(i<<6) {} QFixed(long i) : val(i<<6) {} QFixed &operator=(int i) { val = (i<<6); return *this; } QFixed &operator=(long i) { val = (i<<6); return *this; } static QFixed fromReal(qreal r) { QFixed f; f.val = (int)(r*qreal(64)); return f; } static QFixed fromFixed(int fixed) { QFixed f; f.val = fixed; return f; } inline int value() const { return val; } inline void setValue(int value) { val = value; } inline int toInt() const { return (((val)+32) & -64)>>6; } inline qreal toReal() const { return ((qreal)val)/(qreal)64; } inline int truncate() const { return val>>6; } inline QFixed round() const { QFixed f; f.val = ((val)+32) & -64; return f; } inline QFixed floor() const { QFixed f; f.val = (val) & -64; return f; } inline QFixed ceil() const { QFixed f; f.val = (val+63) & -64; return f; } inline QFixed operator+(int i) const { QFixed f; f.val = (val + (i<<6)); return f; } inline QFixed operator+(uint i) const { QFixed f; f.val = (val + (i<<6)); return f; } inline QFixed operator+(const QFixed &other) const { QFixed f; f.val = (val + other.val); return f; } inline QFixed &operator+=(int i) { val += (i<<6); return *this; } inline QFixed &operator+=(uint i) { val += (i<<6); return *this; } inline QFixed &operator+=(const QFixed &other) { val += other.val; return *this; } inline QFixed operator-(int i) const { QFixed f; f.val = (val - (i<<6)); return f; } inline QFixed operator-(uint i) const { QFixed f; f.val = (val - (i<<6)); return f; } inline QFixed operator-(const QFixed &other) const { QFixed f; f.val = (val - other.val); return f; } inline QFixed &operator-=(int i) { val -= (i<<6); return *this; } inline QFixed &operator-=(uint i) { val -= (i<<6); return *this; } inline QFixed &operator-=(const QFixed &other) { val -= other.val; return *this; } inline QFixed operator-() const { QFixed f; f.val = -val; return f; } inline bool operator==(const QFixed &other) const { return val == other.val; } inline bool operator!=(const QFixed &other) const { return val != other.val; } inline bool operator<(const QFixed &other) const { return val < other.val; } inline bool operator>(const QFixed &other) const { return val > other.val; } inline bool operator<=(const QFixed &other) const { return val <= other.val; } inline bool operator>=(const QFixed &other) const { return val >= other.val; } inline bool operator!() const { return !val; } inline QFixed &operator/=(int x) { val /= x; return *this; } inline QFixed &operator/=(const QFixed &o) { if (o.val == 0) { val = 0x7FFFFFFFL; } else { bool neg = false; qint64 a = val; qint64 b = o.val; if (a < 0) { a = -a; neg = true; } if (b < 0) { b = -b; neg = !neg; } int res = (int)(((a << 6) + (b >> 1)) / b); val = (neg ? -res : res); } return *this; } inline QFixed operator/(int d) const { QFixed f; f.val = val/d; return f; } inline QFixed operator/(QFixed b) const { QFixed f = *this; return (f /= b); } inline QFixed operator>>(int d) const { QFixed f = *this; f.val >>= d; return f; } inline QFixed &operator*=(int i) { val *= i; return *this; } inline QFixed &operator*=(uint i) { val *= i; return *this; } inline QFixed &operator*=(const QFixed &o) { bool neg = false; qint64 a = val; qint64 b = o.val; if (a < 0) { a = -a; neg = true; } if (b < 0) { b = -b; neg = !neg; } int res = (int)((a * b + 0x20L) >> 6); val = neg ? -res : res; return *this; } inline QFixed operator*(int i) const { QFixed f = *this; return (f *= i); } inline QFixed operator*(uint i) const { QFixed f = *this; return (f *= i); } inline QFixed operator*(const QFixed &o) const { QFixed f = *this; return (f *= o); }private: QFixed(qreal i) : val((int)(i*qreal(64))) {} QFixed &operator=(qreal i) { val = (int)(i*qreal(64)); return *this; } inline QFixed operator+(qreal i) const { QFixed f; f.val = (val + (int)(i*qreal(64))); return f; } inline QFixed &operator+=(qreal i) { val += (int)(i*64); return *this; } inline QFixed operator-(qreal i) const { QFixed f; f.val = (val - (int)(i*qreal(64))); return f; } inline QFixed &operator-=(qreal i) { val -= (int)(i*64); return *this; } inline QFixed &operator/=(qreal r) { val = (int)(val/r); return *this; } inline QFixed operator/(qreal d) const { QFixed f; f.val = (int)(val/d); return f; } inline QFixed &operator*=(qreal d) { val = (int) (val*d); return *this; } inline QFixed operator*(qreal d) const { QFixed f = *this; return (f *= d); } int val;};Q_DECLARE_TYPEINFO(QFixed, Q_PRIMITIVE_TYPE);inline int qRound(const QFixed &f) { return f.toInt(); }inline QFixed operator*(int i, const QFixed &d) { return d*i; }inline QFixed operator+(int i, const QFixed &d) { return d+i; }inline QFixed operator-(int i, const QFixed &d) { return -(d-i); } inline QFixed operator*(uint i, const QFixed &d) { return d*i; }inline QFixed operator+(uint i, const QFixed &d) { return d+i; }inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); }// inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; }inline bool operator==(const QFixed &f, int i) { return f.value() == (i<<6); }inline bool operator==(int i, const QFixed &f) { return f.value() == (i<<6); }inline bool operator!=(const QFixed &f, int i) { return f.value() != (i<<6); }inline bool operator!=(int i, const QFixed &f) { return f.value() != (i<<6); }inline bool operator<=(const QFixed &f, int i) { return f.value() <= (i<<6); }inline bool operator<=(int i, const QFixed &f) { return (i<<6) <= f.value(); }inline bool operator>=(const QFixed &f, int i) { return f.value() >= (i<<6); }inline bool operator>=(int i, const QFixed &f) { return (i<<6) >= f.value(); }inline bool operator<(const QFixed &f, int i) { return f.value() < (i<<6); }inline bool operator<(int i, const QFixed &f) { return (i<<6) < f.value(); }inline bool operator>(const QFixed &f, int i) { return f.value() > (i<<6); }inline bool operator>(int i, const QFixed &f) { return (i<<6) > f.value(); }struct QFixedPoint { QFixed x; QFixed y; QPointF toPointF() const { return QPointF(x.toReal(), y.toReal()); }};class QTextItemInt : public QTextItem{public: inline QTextItemInt() : flags(0) {} QFixed descent; QFixed ascent; QFixed width; RenderFlags flags; int num_chars; const QChar *chars; const unsigned short *logClusters; const QFont *f; QColor underlineColor; QGlyphLayout *glyphs; int num_glyphs; QFontEngine *fontEngine;};// this uses the same coordinate system as Qt, but a different one to freetype.// * y is usually negative, and is equal to the ascent.// * negative yoff means the following stuff is drawn higher up.// the characters bounding rect is given by QRect(x,y,width,height), it's advance by// xoo and yoffstruct glyph_metrics_t{ inline glyph_metrics_t() : x(100000), y(100000) {} inline glyph_metrics_t(QFixed _x, QFixed _y, QFixed _width, QFixed _height, QFixed _xoff, QFixed _yoff) : x(_x), y(_y), width(_width), height(_height), xoff(_xoff), yoff(_yoff) {} QFixed x; QFixed y; QFixed width; QFixed height; QFixed xoff; QFixed yoff;};Q_DECLARE_TYPEINFO(glyph_metrics_t, Q_PRIMITIVE_TYPE);typedef unsigned int glyph_t;#if defined(Q_WS_X11) || defined (Q_WS_QWS) || defined (Q_WS_MAC)struct QScriptAnalysis{ unsigned short script : 7; unsigned short override : 1; // Set when in LRO/RLO embedding unsigned short bidiLevel : 6; // Unicode Bidi algorithm embedding level (0-61) unsigned short reserved : 2; bool operator == (const QScriptAnalysis &other) { return script == other.script && bidiLevel == other.bidiLevel; // ###// && override == other.override; }};Q_DECLARE_TYPEINFO(QScriptAnalysis, Q_PRIMITIVE_TYPE);#elif defined(Q_WS_WIN)struct QScriptAnalysis { unsigned short script :10; unsigned short rtl :1; unsigned short layoutRTL :1; unsigned short linkBefore :1; unsigned short linkAfter :1; unsigned short logicalOrder :1; unsigned short noGlyphIndex :1; unsigned short bidiLevel :5; unsigned short override :1; unsigned short inhibitSymSwap :1; unsigned short charShape :1; unsigned short digitSubstitute :1; unsigned short inhibitLigate :1; unsigned short fDisplayZWG :1; unsigned short arabicNumContext :1; unsigned short gcpClusters :1; unsigned short reserved :1; unsigned short engineReserved :2;};Q_DECLARE_TYPEINFO(QScriptAnalysis, Q_PRIMITIVE_TYPE);inline bool operator == (const QScriptAnalysis &sa1, const QScriptAnalysis &sa2){ return sa1.script == sa2.script &&
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -