forked from qt-creator/qt-creator
Help: Fix font point sizes with litehtml
Change-Id: Ia2d7434ed965b00075747c0bdd43d90a236b99dd Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -505,7 +505,8 @@ void DocumentContainer::draw_text(litehtml::uint_ptr hdc,
|
||||
|
||||
int DocumentContainer::pt_to_px(int pt)
|
||||
{
|
||||
return pt;
|
||||
// magic factor of 11/12 to account for differences to webengine/webkit
|
||||
return m_paintDevice->physicalDpiY() * pt * 11 / m_paintDevice->logicalDpiY() / 12;
|
||||
}
|
||||
|
||||
int DocumentContainer::get_default_font_size() const
|
||||
@@ -847,6 +848,11 @@ void DocumentContainer::get_language(litehtml::tstring &language, litehtml::tstr
|
||||
Q_UNUSED(culture)
|
||||
}
|
||||
|
||||
void DocumentContainer::setPaintDevice(QPaintDevice *paintDevice)
|
||||
{
|
||||
m_paintDevice = paintDevice;
|
||||
}
|
||||
|
||||
void DocumentContainer::setScrollPosition(const QPoint &pos)
|
||||
{
|
||||
m_scrollPosition = pos;
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <QFont>
|
||||
#include <QHash>
|
||||
#include <QPaintDevice>
|
||||
#include <QPixmap>
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
@@ -120,6 +121,7 @@ public:
|
||||
void get_media_features(litehtml::media_features &media) const override;
|
||||
void get_language(litehtml::tstring &language, litehtml::tstring &culture) const override;
|
||||
|
||||
void setPaintDevice(QPaintDevice *paintDevice);
|
||||
void setDocument(const QByteArray &data, litehtml::context *context);
|
||||
litehtml::document::ptr document() const;
|
||||
void setScrollPosition(const QPoint &pos);
|
||||
@@ -166,6 +168,7 @@ private:
|
||||
QUrl resolveUrl(const QString &url, const QString &baseUrl) const;
|
||||
void drawSelection(QPainter *painter, const QRect &clip) const;
|
||||
|
||||
QPaintDevice *m_paintDevice = nullptr;
|
||||
litehtml::document::ptr m_document;
|
||||
QString m_baseUrl;
|
||||
QRect m_clientRect;
|
||||
|
@@ -422,6 +422,7 @@ QUrl QLiteHtmlWidget::url() const
|
||||
|
||||
void QLiteHtmlWidget::setHtml(const QString &content)
|
||||
{
|
||||
d->documentContainer.setPaintDevice(viewport());
|
||||
d->documentContainer.setDocument(content.toUtf8(), &d->context);
|
||||
verticalScrollBar()->setValue(0);
|
||||
horizontalScrollBar()->setValue(0);
|
||||
|
Reference in New Issue
Block a user