32 #include <private/qcoregraphics_p.h>
33 #include <private/qcore_mac_p.h>
34 #include <Foundation/Foundation.h>
35 #include <private/qfont_p.h>
36 #include <private/qfontengine_p.h>
54 f.setPointSize(pointSize);
58 if (textColor.isValid()) {
64 if (bgColor.isValid()) {
106 p.setPen(metricsPen);
128 f.setResolveMask(-1);
137 QMacAutoReleasePool
pool;
149 auto nsColor = [NSColor colorWithSRGBRed:textColor.
redF()
155 CGContextSetShouldAntialias(ctx,
false);
158 CGContextScaleCTM(ctx, 1, -1);
159 CGContextTranslateCTM(ctx, 0, -
height());
164 auto *attributedString = [[NSAttributedString alloc] initWithString:
text().toNSString()
166 NSFontAttributeName : (NSFont *)fontEngine->handle(),
167 NSForegroundColorAttributeName : nsColor
171 QCFType<CTLineRef> line = CTLineCreateWithAttributedString(CFAttributedStringRef([attributedString autorelease]));
172 CTLineDraw(
line, ctx);
193 for (
int i = 0;
i < 6; ++
i) {
211 for (
int pointSize : {8, 12, 24, 36, 48})
224 renderer->updateGeometry();
232 colorDialog->setModal(
false);
239 colorDialog->setVisible(
true);
241 controls->addWidget(colorButton);
246 fontDialog->setModal(
false);
251 fontDialog->setVisible(
true);
253 controls->addWidget(fontButton);
255 auto *aaButton =
new QCheckBox(
"NoAntialias");
258 QFont font = renderer->font();
259 font.setStyleStrategy(QFont::StyleStrategy(font.styleStrategy() ^ QFont::NoAntialias));
260 renderer->setFont(font);
263 controls->addWidget(aaButton);
265 auto *subpixelAAButton =
new QCheckBox(
"NoSubpixelAntialias");
268 QFont font = renderer->font();
269 font.setStyleStrategy(QFont::StyleStrategy(font.styleStrategy() ^ QFont::NoSubpixelAntialias));
270 renderer->setFont(font);
273 controls->addWidget(subpixelAAButton);
274 controls->addStretch();
276 mainLayout->addLayout(controls);
309 int main(
int argc,
char **argv)
311 qputenv(
"QT_MAX_CACHED_GLYPH_SIZE",
"97");
small capitals from c petite p scientific i
[1]
The QApplication class manages the GUI application's control flow and main settings.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
const QColor & color() const
The QCheckBox widget provides a checkbox with a text label.
The QColorDialog class provides a dialog widget for specifying colors.
void currentColorChanged(const QColor &color)
The QColor class provides colors based on RGB, HSV or CMYK values.
float greenF() const noexcept
float redF() const noexcept
float alphaF() const noexcept
float blueF() const noexcept
The QDebug class provides an output stream for debugging information.
The QEvent class is the base class of all event classes. Event objects contain event parameters.
The QFontDialog class provides a dialog widget for selecting a font.
void currentFontChanged(const QFont &font)
The QFont class specifies a query for a font used for drawing text.
The QFontMetrics class provides font metrics information.
QRect boundingRect(QChar) const
static QFontPrivate * get(const QFont &font)
QFontEngine * engineForScript(int script) const
The QHBoxLayout class lines up widgets horizontally.
The QImage class provides a hardware-independent image representation that allows direct access to th...
@ Format_ARGB32_Premultiplied
The QKeyEvent class describes a key event.
The QLineEdit widget is a one-line text editor.
void textChanged(const QString &)
The QMouseEvent class contains parameters that describe a mouse event.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
QList< T > findChildren(const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
qreal devicePixelRatio() const
The QPaintEvent class contains event parameters for paint events. \inmodule QtGui.
The QPainter class performs low-level painting on widgets and other paint devices.
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
The QPalette class contains color groups for each widget state.
const QBrush & text() const
const QColor & color(ColorGroup cg, ColorRole cr) const
The QPen class defines how a QPainter should draw lines and outlines of shapes.
void setCosmetic(bool cosmetic)
The QPoint class defines a point in the plane using integer precision.
The QRect class defines a rectangle in the plane using integer precision.
The QSize class defines the size of a two-dimensional object using integer point precision.
The QString class provides a Unicode character string.
static QString fromUtf8(QByteArrayView utf8)
The QVBoxLayout class lines up widgets vertically.
void renderNativeText(QImage &image)
QSize sizeHint() const override
void paintEvent(QPaintEvent *) override
TextRenderer(qreal pointSize, const QString &text, const QColor &textColor=QColor(), const QColor &bgColor=QColor())
void renderQtText(QImage &image)
bool event(QEvent *event) override
int main(int argc, char **argv)
std::pair< T1, T2 > QPair
QT_END_INCLUDE_NAMESPACE typedef double qreal
GLfloat GLfloat GLfloat alpha
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
QApplication app(argc, argv)
[0]
backaction setToolTip(browser.historyTitle(-1))
[0]