1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright 2010-2021 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#ifndef MUMBLE_MUMBLE_OVERLAYTEXT_H_
#define MUMBLE_MUMBLE_OVERLAYTEXT_H_
#include <QtGui/QFont>
#include <QtGui/QPainterPath>
#include <QtGui/QPixmap>
//! Annotated QPixmap supplying a basepoint.
class BasepointPixmap : public QPixmap {
public:
//! Local coordinates of the base point.
QPoint qpBasePoint;
//@{
/**
* Font ascent and descent.
* The pixmap may exceed those font metrics, so if you need to
* transform rendered text properly, use these attributes.
*/
int iAscent;
int iDescent;
//@}
BasepointPixmap();
//! Create from QPixmap, basepoint is bottom left.
BasepointPixmap(const QPixmap &);
//! Empty pixmap, basepoint is bottom left.
BasepointPixmap(int, int);
//! Empty pixmap with specified basepoint.
BasepointPixmap(int, int, const QPoint &);
};
class OverlayTextLine {
private:
const float fEdgeFactor;
QString qsText;
QFont qfFont;
QPainterPath qpp;
float fAscent, fDescent;
float fXCorrection, fYCorrection;
int iCurWidth, iCurHeight;
float fEdge;
float fBaseliningThreshold;
bool bElided;
BasepointPixmap render(int, int, const QColor &, const QPoint &) const;
public:
OverlayTextLine(const QString &, const QFont &);
void setFont(const QFont &);
void setEdge(float);
//! Render text with current font.
BasepointPixmap createPixmap(QColor col);
//! Render text to fit a bounding box.
BasepointPixmap createPixmap(unsigned int maxwidth, unsigned int height, QColor col);
};
#endif //_OVERLAYTEXT_H
|