QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskTextRenderer.cpp
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#include "QskTextRenderer.h"
7#include "QskPlainTextRenderer.h"
8#include "QskRichTextRenderer.h"
9#include "QskTextOptions.h"
10
11#include <qrect.h>
12
13/*
14 Since Qt 5.7 QQuickTextNode is exported as Q_QUICK_PRIVATE_EXPORT
15 and could be used. TODO ...
16 */
17QSizeF QskTextRenderer::textSize(
18 const QString& text, const QFont& font, const QskTextOptions& options )
19{
20 if ( options.effectiveFormat( text ) == QskTextOptions::PlainText )
21 return QskPlainTextRenderer::textSize( text, font, options );
22 else
23 return QskRichTextRenderer::textSize( text, font, options );
24}
25
26QSizeF QskTextRenderer::textSize(
27 const QString& text, const QFont& font, const QskTextOptions& options,
28 const QSizeF& size )
29{
30 if ( options.effectiveFormat( text ) == QskTextOptions::PlainText )
31 return QskPlainTextRenderer::textRect( text, font, options, size ).size();
32 else
33 return QskRichTextRenderer::textRect( text, font, options, size ).size();
34}
35
36void QskTextRenderer::updateNode(
37 const QString& text, const QFont& font, const QskTextOptions& options,
38 Qsk::TextStyle style, const QskTextColors& colors, Qt::Alignment alignment,
39 const QRectF& rect, const QQuickItem* item, QSGTransformNode* node )
40{
41 if ( options.format() == QskTextOptions::PlainText )
42 {
43 QskPlainTextRenderer::updateNode(
44 text, font, options, style, colors, alignment, rect, item, node );
45 }
46 else
47 {
48 QskRichTextRenderer::updateNode(
49 text, font, options, style, colors, alignment, rect, item, node );
50 }
51}