qglyphrun.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qglyphrun.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6QGlyphRun::QGlyphRun() : d(new QGlyphRunPrivate)-
7{-
8}-
9-
10-
11-
12-
13QGlyphRun::QGlyphRun(const QGlyphRun &other)-
14{-
15 d = other.d;-
16}-
17-
18-
19-
20-
21QGlyphRun::~QGlyphRun()-
22{-
23-
24}-
25-
26-
27-
28-
29void QGlyphRun::detach()-
30{-
31 if (d->ref.load() != 1)-
32 d.detach();-
33}-
34-
35-
36-
37-
38QGlyphRun &QGlyphRun::operator=(const QGlyphRun &other)-
39{-
40 d = other.d;-
41 return *this;-
42}-
43bool QGlyphRun::operator==(const QGlyphRun &other) const-
44{-
45 if (d == other.d)-
46 return true;-
47-
48 if ((d->glyphIndexDataSize != other.d->glyphIndexDataSize)-
49 || (d->glyphPositionDataSize != other.d->glyphPositionDataSize)) {-
50 return false;-
51 }-
52-
53 if (d->glyphIndexData != other.d->glyphIndexData) {-
54 for (int i = 0; i < d->glyphIndexDataSize; ++i) {-
55 if (d->glyphIndexData[i] != other.d->glyphIndexData[i])-
56 return false;-
57 }-
58 }-
59 if (d->glyphPositionData != other.d->glyphPositionData) {-
60 for (int i = 0; i < d->glyphPositionDataSize; ++i) {-
61 if (d->glyphPositionData[i] != other.d->glyphPositionData[i])-
62 return false;-
63 }-
64 }-
65-
66 return (d->flags == other.d->flags && d->rawFont == other.d->rawFont);-
67}-
68QRawFont QGlyphRun::rawFont() const-
69{-
70 return d->rawFont;-
71}-
72-
73-
74-
75-
76-
77-
78-
79void QGlyphRun::setRawFont(const QRawFont &rawFont)-
80{-
81 detach();-
82 d->rawFont = rawFont;-
83}-
84-
85-
86-
87-
88-
89-
90QVector<quint32> QGlyphRun::glyphIndexes() const-
91{-
92 if (d->glyphIndexes.constData() == d->glyphIndexData) {-
93 return d->glyphIndexes;-
94 } else {-
95 QVector<quint32> indexes(d->glyphIndexDataSize);-
96 memcpy(indexes.data(), d->glyphIndexData, d->glyphIndexDataSize * sizeof(quint32));-
97 return indexes;-
98 }-
99}-
100-
101-
102-
103-
104-
105void QGlyphRun::setGlyphIndexes(const QVector<quint32> &glyphIndexes)-
106{-
107 detach();-
108 d->glyphIndexes = glyphIndexes;-
109 d->glyphIndexData = glyphIndexes.constData();-
110 d->glyphIndexDataSize = glyphIndexes.size();-
111}-
112-
113-
114-
115-
116QVector<QPointF> QGlyphRun::positions() const-
117{-
118 if (d->glyphPositions.constData() == d->glyphPositionData) {-
119 return d->glyphPositions;-
120 } else {-
121 QVector<QPointF> glyphPositions(d->glyphPositionDataSize);-
122 memcpy(glyphPositions.data(), d->glyphPositionData,-
123 d->glyphPositionDataSize * sizeof(QPointF));-
124 return glyphPositions;-
125 }-
126}-
127-
128-
129-
130-
131-
132void QGlyphRun::setPositions(const QVector<QPointF> &positions)-
133{-
134 detach();-
135 d->glyphPositions = positions;-
136 d->glyphPositionData = positions.constData();-
137 d->glyphPositionDataSize = positions.size();-
138}-
139-
140-
141-
142-
143void QGlyphRun::clear()-
144{-
145 detach();-
146 d->rawFont = QRawFont();-
147 d->flags = 0;-
148-
149 setPositions(QVector<QPointF>());-
150 setGlyphIndexes(QVector<quint32>());-
151}-
152void QGlyphRun::setRawData(const quint32 *glyphIndexArray, const QPointF *glyphPositionArray,-
153 int size)-
154{-
155 detach();-
156 d->glyphIndexes.clear();-
157 d->glyphPositions.clear();-
158-
159 d->glyphIndexData = glyphIndexArray;-
160 d->glyphPositionData = glyphPositionArray;-
161 d->glyphIndexDataSize = d->glyphPositionDataSize = size;-
162}-
163-
164-
165-
166-
167-
168-
169bool QGlyphRun::overline() const-
170{-
171 return d->flags & Overline;-
172}-
173-
174-
175-
176-
177-
178-
179-
180void QGlyphRun::setOverline(bool overline)-
181{-
182 setFlag(Overline, overline);-
183}-
184-
185-
186-
187-
188-
189-
190bool QGlyphRun::underline() const-
191{-
192 return d->flags & Underline;-
193}-
194-
195-
196-
197-
198-
199-
200-
201void QGlyphRun::setUnderline(bool underline)-
202{-
203 setFlag(Underline, underline);-
204}-
205-
206-
207-
208-
209-
210-
211bool QGlyphRun::strikeOut() const-
212{-
213 return d->flags & StrikeOut;-
214}-
215-
216-
217-
218-
219-
220-
221-
222void QGlyphRun::setStrikeOut(bool strikeOut)-
223{-
224 setFlag(StrikeOut, strikeOut);-
225}-
226-
227-
228-
229-
230-
231-
232-
233bool QGlyphRun::isRightToLeft() const-
234{-
235 return d->flags & RightToLeft;-
236}-
237void QGlyphRun::setRightToLeft(bool rightToLeft)-
238{-
239 setFlag(RightToLeft, rightToLeft);-
240}-
241-
242-
243-
244-
245-
246-
247-
248QGlyphRun::GlyphRunFlags QGlyphRun::flags() const-
249{-
250 return d->flags;-
251}-
252-
253-
254-
255-
256-
257-
258-
259void QGlyphRun::setFlag(GlyphRunFlag flag, bool enabled)-
260{-
261 if (d->flags.testFlag(flag) == enabled
d->flags.testF...ag) == enabledDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
262 return;
never executed: return;
0
263-
264 detach();-
265 if (enabled)-
d->flags |= flag;
elsed->flags&= ~.setFlag(flag;, enabled);
266}
never executed: end of block
0
267-
268-
269-
270-
271-
272-
273-
274void QGlyphRun::setFlags(GlyphRunFlags flags)-
275{-
276 if (d->flags == flags)-
277 return;-
278-
279 detach();-
280 d->flags = flags;-
281}-
282void QGlyphRun::setBoundingRect(const QRectF &boundingRect)-
283{-
284 detach();-
285 d->boundingRect = boundingRect;-
286}-
287QRectF QGlyphRun::boundingRect() const-
288{-
289 if (!d->boundingRect.isEmpty() || !d->rawFont.isValid())-
290 return d->boundingRect;-
291-
292 qreal minX, minY, maxX, maxY;-
293 minX = minY = maxX = maxY = 0;-
294-
295 for (int i = 0, n = qMin(d->glyphIndexDataSize, d->glyphPositionDataSize); i < n; ++i) {-
296 QRectF glyphRect = d->rawFont.boundingRect(d->glyphIndexData[i]);-
297 glyphRect.translate(d->glyphPositionData[i]);-
298-
299 if (i == 0) {-
300 minX = glyphRect.left();-
301 minY = glyphRect.top();-
302 maxX = glyphRect.right();-
303 maxY = glyphRect.bottom();-
304 } else {-
305 minX = qMin(glyphRect.left(), minX);-
306 minY = qMin(glyphRect.top(), minY);-
307 maxX = qMax(glyphRect.right(),maxX);-
308 maxY = qMax(glyphRect.bottom(), maxY);-
309 }-
310 }-
311-
312 return QRectF(QPointF(minX, minY), QPointF(maxX, maxY));-
313}-
314-
315-
316-
317-
318-
319-
320bool QGlyphRun::isEmpty() const-
321{-
322 return d->glyphIndexDataSize == 0;-
323}-
324-
325-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9