Commit b1a9b1c3 authored by RazrFalcon's avatar RazrFalcon

(qt-api) Added ResvgRenderer::setDevicePixelRatio.

parent 3543fbc6
......@@ -15,6 +15,7 @@ This changelog also contains important changes in dependencies.
- (usvg) Default font family and size is configurable now.
- (c-api) `RESVG_ERROR_PARSING_FAILED`.
- (c-api) `font_family`, `font_size` and `languages` to `resvg_options`.
- (qt-api) `ResvgRenderer::setDevicePixelRatio`.
### Changed
- (rendersvg) Use `gumdrop` instead of `getopts`.
......
......@@ -59,6 +59,7 @@ public:
resvg_render_tree *tree = nullptr;
resvg_options opt;
qreal scaleFactor = 1.0;
QRectF viewBox;
QString errMsg;
......@@ -73,12 +74,7 @@ private:
opt.languages = toCStr(QLocale().bcp47Name());
// TODO: should be set manually
const auto screens = qApp->screens();
if (!screens.isEmpty()) {
const auto screen = screens.at(0);
opt.dpi = screen->logicalDotsPerInch() * screen->devicePixelRatio();
}
opt.dpi = 96 * scaleFactor;
}
void clear()
......@@ -227,6 +223,11 @@ public:
*/
QTransform transformForElement(const QString &id) const;
/**
* @brief Sets the device pixel ratio for the image.
*/
void setDevicePixelRatio(qreal scaleFactor);
/**
* @brief Renders the SVG data to canvas.
*/
......@@ -413,6 +414,11 @@ inline QTransform ResvgRenderer::transformForElement(const QString &id) const
return QTransform();
}
inline void ResvgRenderer::setDevicePixelRatio(qreal scaleFactor)
{
d->scaleFactor = scaleFactor;
}
inline void ResvgRenderer::render(QPainter *p)
{
render(p, QRectF());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment