Krita Source Code Documentation
Loading...
Searching...
No Matches
KoSvgText::ResolutionHandler Struct Reference

The ResolutionHandler class. More...

#include <KoSvgText.h>

Public Member Functions

QPointF adjust (const QPointF point) const
 Adjusts the point to rounded pixel values, based on whether roundToPixelHorizontal or roundToPixelVertical are true.
 
QRectF adjust (const QRectF rect) const
 Adjusts the rect to rounded pixel values, based on whether roundToPixelHorizontal or roundToPixelVertical are true.
 
QPointF adjustCeil (const QPointF point) const
 Adjusts the point to ceiled pixel values.
 
QPointF adjustFloor (const QPointF point) const
 Adjusts the point to floored pixel values.
 
QPointF adjustWithOffset (const QPointF point, const QPointF offset) const
 
qreal freeTypePixelToPointFactor (const bool x=true) const
 
QTransform freeTypeToPixelTransform () const
 
QTransform freeTypeToPointTransform () const
 
QTransform pixelToPoint () const
 
qreal pixelToPointFactor (const bool x=true) const
 
QTransform pointToPixel () const
 
qreal pointToPixelFactor (const bool x=true) const
 
 ResolutionHandler (qreal _xRes=72.0, qreal _yRes=72.0, bool _roundToPixelHorizontal=false, bool _roundToPixelVertical=false)
 

Public Attributes

const qreal freeTypePixel = 64.0
 
const qreal pointInInch = 72.0
 
bool roundToPixelHorizontal = false
 
bool roundToPixelVertical = false
 
qreal xRes = 72.0
 
qreal yRes = 72.0
 

Detailed Description

The ResolutionHandler class.

convenience struct to handle all the conversions between pixels and points and freetype pixels.

Definition at line 1084 of file KoSvgText.h.

Constructor & Destructor Documentation

◆ ResolutionHandler()

KoSvgText::ResolutionHandler::ResolutionHandler ( qreal _xRes = 72.0,
qreal _yRes = 72.0,
bool _roundToPixelHorizontal = false,
bool _roundToPixelVertical = false )
inline

Definition at line 1086 of file KoSvgText.h.

1087 : xRes(_xRes), yRes(_yRes), roundToPixelHorizontal(_roundToPixelHorizontal), roundToPixelVertical(_roundToPixelVertical) {}

Member Function Documentation

◆ adjust() [1/2]

QPointF KoSvgText::ResolutionHandler::adjust ( const QPointF point) const

Adjusts the point to rounded pixel values, based on whether roundToPixelHorizontal or roundToPixelVertical are true.

Definition at line 1704 of file KoSvgText.cpp.

1704 {
1705 if (!roundToPixelHorizontal && !roundToPixelVertical) return point;
1706 QPointF pix = pointToPixel().map(point);
1708 pix.setX(qRound(pix.x()));
1709 }
1711 pix.setY(qRound(pix.y()));
1712 }
1713 return pixelToPoint().map(pix);
1714}
QTransform pixelToPoint() const
QTransform pointToPixel() const

References pixelToPoint(), pointToPixel(), roundToPixelHorizontal, and roundToPixelVertical.

◆ adjust() [2/2]

QRectF KoSvgText::ResolutionHandler::adjust ( const QRectF rect) const

Adjusts the rect to rounded pixel values, based on whether roundToPixelHorizontal or roundToPixelVertical are true.

Definition at line 1748 of file KoSvgText.cpp.

1748 {
1749 return QRectF(adjust(rect.topLeft()), adjust(rect.bottomRight()));
1750}
QPointF adjust(const QPointF point) const
Adjusts the point to rounded pixel values, based on whether roundToPixelHorizontal or roundToPixelVer...

References adjust().

◆ adjustCeil()

QPointF KoSvgText::ResolutionHandler::adjustCeil ( const QPointF point) const

Adjusts the point to ceiled pixel values.

See also
adjust(QPointF);

Definition at line 1729 of file KoSvgText.cpp.

1730{
1731 if (!roundToPixelHorizontal && !roundToPixelVertical) return point;
1732 QPointF pix = pointToPixel().map(point);
1734 pix.setX(ceil(pix.x()));
1735 }
1737 pix.setY(ceil(pix.y()));
1738 }
1739 return pixelToPoint().map(pix);
1740}

References pixelToPoint(), pointToPixel(), roundToPixelHorizontal, and roundToPixelVertical.

◆ adjustFloor()

QPointF KoSvgText::ResolutionHandler::adjustFloor ( const QPointF point) const

Adjusts the point to floored pixel values.

See also
adjust(QPointF);

Definition at line 1716 of file KoSvgText.cpp.

1717{
1718 if (!roundToPixelHorizontal && !roundToPixelVertical) return point;
1719 QPointF pix = pointToPixel().map(point);
1721 pix.setX(floor(pix.x()));
1722 }
1724 pix.setY(floor(pix.y()));
1725 }
1726 return pixelToPoint().map(pix);
1727}

References pixelToPoint(), pointToPixel(), roundToPixelHorizontal, and roundToPixelVertical.

◆ adjustWithOffset()

QPointF KoSvgText::ResolutionHandler::adjustWithOffset ( const QPointF point,
const QPointF offset ) const

For text decoration, we need to ensure that the whole thing, including width and height is aligned to the pixel. So this adds the offset (half the total width) and uses that to round to.

Definition at line 1742 of file KoSvgText.cpp.

1743{
1744 if (!roundToPixelHorizontal && !roundToPixelVertical) return point;
1745 return adjust(point+offset)-offset;
1746}

References adjust(), roundToPixelHorizontal, and roundToPixelVertical.

◆ freeTypePixelToPointFactor()

qreal KoSvgText::ResolutionHandler::freeTypePixelToPointFactor ( const bool x = true) const

Definition at line 1687 of file KoSvgText.cpp.

1687 {
1688 return (1.0/freeTypePixel) * pixelToPointFactor(x);
1689}
qreal pixelToPointFactor(const bool x=true) const

References freeTypePixel, and pixelToPointFactor().

◆ freeTypeToPixelTransform()

QTransform KoSvgText::ResolutionHandler::freeTypeToPixelTransform ( ) const

Definition at line 1691 of file KoSvgText.cpp.

1691 {
1692 return QTransform::fromScale(1/freeTypePixel, -1/freeTypePixel);
1693}

References freeTypePixel.

◆ freeTypeToPointTransform()

QTransform KoSvgText::ResolutionHandler::freeTypeToPointTransform ( ) const

Definition at line 1695 of file KoSvgText.cpp.

1696{
1698}
QTransform freeTypeToPixelTransform() const

References freeTypeToPixelTransform(), and pixelToPoint().

◆ pixelToPoint()

QTransform KoSvgText::ResolutionHandler::pixelToPoint ( ) const

Definition at line 1700 of file KoSvgText.cpp.

1700 {
1701 return QTransform::fromScale(pointInInch / xRes, pointInInch / yRes);
1702}

References pointInInch, xRes, and yRes.

◆ pixelToPointFactor()

qreal KoSvgText::ResolutionHandler::pixelToPointFactor ( const bool x = true) const

Definition at line 1760 of file KoSvgText.cpp.

References pointInInch, xRes, and yRes.

◆ pointToPixel()

QTransform KoSvgText::ResolutionHandler::pointToPixel ( ) const

Definition at line 1756 of file KoSvgText.cpp.

1756 {
1757 return QTransform::fromScale(xRes/pointInInch, yRes/pointInInch);
1758}

References pointInInch, xRes, and yRes.

◆ pointToPixelFactor()

qreal KoSvgText::ResolutionHandler::pointToPixelFactor ( const bool x = true) const

Definition at line 1752 of file KoSvgText.cpp.

1752 {
1754}

References pointInInch, xRes, and yRes.

Member Data Documentation

◆ freeTypePixel

const qreal KoSvgText::ResolutionHandler::freeTypePixel = 64.0

Definition at line 1095 of file KoSvgText.h.

◆ pointInInch

const qreal KoSvgText::ResolutionHandler::pointInInch = 72.0

Definition at line 1096 of file KoSvgText.h.

◆ roundToPixelHorizontal

bool KoSvgText::ResolutionHandler::roundToPixelHorizontal = false

Definition at line 1092 of file KoSvgText.h.

◆ roundToPixelVertical

bool KoSvgText::ResolutionHandler::roundToPixelVertical = false

Definition at line 1093 of file KoSvgText.h.

◆ xRes

qreal KoSvgText::ResolutionHandler::xRes = 72.0

Definition at line 1090 of file KoSvgText.h.

◆ yRes

qreal KoSvgText::ResolutionHandler::yRes = 72.0

Definition at line 1091 of file KoSvgText.h.


The documentation for this struct was generated from the following files: