mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-04-24 23:18:51 +02:00
Issue #69: Dashed Line not rendered as expected
This commit is contained in:
parent
2daf1a6d53
commit
06e1ed1f47
@ -1057,7 +1057,7 @@ QPen PDFAnnotation::getPen() const
|
|||||||
{
|
{
|
||||||
PDFLineDashPattern lineDashPattern(border.getDashPattern(), 0.0);
|
PDFLineDashPattern lineDashPattern(border.getDashPattern(), 0.0);
|
||||||
pen.setStyle(Qt::CustomDashLine);
|
pen.setStyle(Qt::CustomDashLine);
|
||||||
pen.setDashPattern(QVector<qreal>(lineDashPattern.getDashArray().begin(), lineDashPattern.getDashArray().end()));
|
pen.setDashPattern(lineDashPattern.createForQPen(pen.widthF()));
|
||||||
pen.setDashOffset(lineDashPattern.getDashOffset());
|
pen.setDashOffset(lineDashPattern.getDashOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -911,8 +911,7 @@ void PDFPageContentProcessor::processPathPainting(const QPainterPath& path, bool
|
|||||||
const PDFLineDashPattern& lineDashPattern = m_graphicState.getLineDashPattern();
|
const PDFLineDashPattern& lineDashPattern = m_graphicState.getLineDashPattern();
|
||||||
if (!lineDashPattern.isSolid())
|
if (!lineDashPattern.isSolid())
|
||||||
{
|
{
|
||||||
const auto& dashArray = lineDashPattern.getDashArray();
|
stroker.setDashPattern(lineDashPattern.createForQPen(m_graphicState.getLineWidth()));
|
||||||
stroker.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
|
|
||||||
stroker.setDashOffset(lineDashPattern.getDashOffset());
|
stroker.setDashOffset(lineDashPattern.getDashOffset());
|
||||||
}
|
}
|
||||||
QPainterPath strokedPath = stroker.createStroke(path);
|
QPainterPath strokedPath = stroker.createStroke(path);
|
||||||
@ -959,8 +958,7 @@ void PDFPageContentProcessor::processPathPainting(const QPainterPath& path, bool
|
|||||||
const PDFLineDashPattern& lineDashPattern = m_graphicState.getLineDashPattern();
|
const PDFLineDashPattern& lineDashPattern = m_graphicState.getLineDashPattern();
|
||||||
if (!lineDashPattern.isSolid())
|
if (!lineDashPattern.isSolid())
|
||||||
{
|
{
|
||||||
const auto& dashArray = lineDashPattern.getDashArray();
|
stroker.setDashPattern(lineDashPattern.createForQPen(m_graphicState.getLineWidth()));
|
||||||
stroker.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
|
|
||||||
stroker.setDashOffset(lineDashPattern.getDashOffset());
|
stroker.setDashOffset(lineDashPattern.getDashOffset());
|
||||||
}
|
}
|
||||||
QPainterPath strokedPath = stroker.createStroke(path);
|
QPainterPath strokedPath = stroker.createStroke(path);
|
||||||
@ -3978,6 +3976,18 @@ void PDFLineDashPattern::fix()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<qreal> PDFLineDashPattern::createForQPen(qreal penWidthF) const
|
||||||
|
{
|
||||||
|
QVector<qreal> lineDashPattern(m_dashArray.begin(), m_dashArray.end());
|
||||||
|
|
||||||
|
for (qreal& value : lineDashPattern)
|
||||||
|
{
|
||||||
|
value /= penWidthF;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lineDashPattern;
|
||||||
|
}
|
||||||
|
|
||||||
PDFPageContentProcessor::PDFSoftMaskDefinition PDFPageContentProcessor::PDFSoftMaskDefinition::parse(const PDFDictionary* softMask, PDFPageContentProcessor* processor)
|
PDFPageContentProcessor::PDFSoftMaskDefinition PDFPageContentProcessor::PDFSoftMaskDefinition::parse(const PDFDictionary* softMask, PDFPageContentProcessor* processor)
|
||||||
{
|
{
|
||||||
PDFSoftMaskDefinition result;
|
PDFSoftMaskDefinition result;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "pdftextlayout.h"
|
#include "pdftextlayout.h"
|
||||||
#include "pdfoperationcontrol.h"
|
#include "pdfoperationcontrol.h"
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
@ -68,6 +69,11 @@ public:
|
|||||||
/// Fix line dash pattern according to the specification
|
/// Fix line dash pattern according to the specification
|
||||||
void fix();
|
void fix();
|
||||||
|
|
||||||
|
/// Create dash pattern for QPen.
|
||||||
|
/// \param penWidthF Width of the pen.
|
||||||
|
/// \note Dash pattern in QPen is in pen width units
|
||||||
|
QVector<qreal> createForQPen(qreal penWidthF) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<PDFReal> m_dashArray;
|
std::vector<PDFReal> m_dashArray;
|
||||||
PDFReal m_dashOffset = 0.0;
|
PDFReal m_dashOffset = 0.0;
|
||||||
|
@ -136,9 +136,7 @@ QPen PDFPainterBase::getCurrentPenImpl() const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
pen.setStyle(Qt::CustomDashLine);
|
pen.setStyle(Qt::CustomDashLine);
|
||||||
|
pen.setDashPattern(lineDashPattern.createForQPen(pen.widthF()));
|
||||||
const auto& dashArray = lineDashPattern.getDashArray();
|
|
||||||
pen.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
|
|
||||||
pen.setDashOffset(lineDashPattern.getDashOffset());
|
pen.setDashOffset(lineDashPattern.getDashOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2187,8 +2187,7 @@ void PDFTransparencyRenderer::performPathPainting(const QPainterPath& path, bool
|
|||||||
const PDFLineDashPattern& lineDashPattern = getGraphicState()->getLineDashPattern();
|
const PDFLineDashPattern& lineDashPattern = getGraphicState()->getLineDashPattern();
|
||||||
if (!lineDashPattern.isSolid())
|
if (!lineDashPattern.isSolid())
|
||||||
{
|
{
|
||||||
const auto& dashArray = lineDashPattern.getDashArray();
|
stroker.setDashPattern(lineDashPattern.createForQPen(getGraphicState()->getLineWidth()));
|
||||||
stroker.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
|
|
||||||
stroker.setDashOffset(lineDashPattern.getDashOffset());
|
stroker.setDashOffset(lineDashPattern.getDashOffset());
|
||||||
}
|
}
|
||||||
QPainterPath strokedPath = stroker.createStroke(path);
|
QPainterPath strokedPath = stroker.createStroke(path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user