mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-04-18 20:27:35 +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);
|
||||
pen.setStyle(Qt::CustomDashLine);
|
||||
pen.setDashPattern(QVector<qreal>(lineDashPattern.getDashArray().begin(), lineDashPattern.getDashArray().end()));
|
||||
pen.setDashPattern(lineDashPattern.createForQPen(pen.widthF()));
|
||||
pen.setDashOffset(lineDashPattern.getDashOffset());
|
||||
}
|
||||
|
||||
|
@ -911,8 +911,7 @@ void PDFPageContentProcessor::processPathPainting(const QPainterPath& path, bool
|
||||
const PDFLineDashPattern& lineDashPattern = m_graphicState.getLineDashPattern();
|
||||
if (!lineDashPattern.isSolid())
|
||||
{
|
||||
const auto& dashArray = lineDashPattern.getDashArray();
|
||||
stroker.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
|
||||
stroker.setDashPattern(lineDashPattern.createForQPen(m_graphicState.getLineWidth()));
|
||||
stroker.setDashOffset(lineDashPattern.getDashOffset());
|
||||
}
|
||||
QPainterPath strokedPath = stroker.createStroke(path);
|
||||
@ -959,8 +958,7 @@ void PDFPageContentProcessor::processPathPainting(const QPainterPath& path, bool
|
||||
const PDFLineDashPattern& lineDashPattern = m_graphicState.getLineDashPattern();
|
||||
if (!lineDashPattern.isSolid())
|
||||
{
|
||||
const auto& dashArray = lineDashPattern.getDashArray();
|
||||
stroker.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
|
||||
stroker.setDashPattern(lineDashPattern.createForQPen(m_graphicState.getLineWidth()));
|
||||
stroker.setDashOffset(lineDashPattern.getDashOffset());
|
||||
}
|
||||
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)
|
||||
{
|
||||
PDFSoftMaskDefinition result;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "pdftextlayout.h"
|
||||
#include "pdfoperationcontrol.h"
|
||||
|
||||
#include <QVector>
|
||||
#include <QTransform>
|
||||
#include <QPainterPath>
|
||||
#include <QSharedPointer>
|
||||
@ -68,6 +69,11 @@ public:
|
||||
/// Fix line dash pattern according to the specification
|
||||
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:
|
||||
std::vector<PDFReal> m_dashArray;
|
||||
PDFReal m_dashOffset = 0.0;
|
||||
|
@ -136,9 +136,7 @@ QPen PDFPainterBase::getCurrentPenImpl() const
|
||||
else
|
||||
{
|
||||
pen.setStyle(Qt::CustomDashLine);
|
||||
|
||||
const auto& dashArray = lineDashPattern.getDashArray();
|
||||
pen.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
|
||||
pen.setDashPattern(lineDashPattern.createForQPen(pen.widthF()));
|
||||
pen.setDashOffset(lineDashPattern.getDashOffset());
|
||||
}
|
||||
|
||||
|
@ -2187,8 +2187,7 @@ void PDFTransparencyRenderer::performPathPainting(const QPainterPath& path, bool
|
||||
const PDFLineDashPattern& lineDashPattern = getGraphicState()->getLineDashPattern();
|
||||
if (!lineDashPattern.isSolid())
|
||||
{
|
||||
const auto& dashArray = lineDashPattern.getDashArray();
|
||||
stroker.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
|
||||
stroker.setDashPattern(lineDashPattern.createForQPen(getGraphicState()->getLineWidth()));
|
||||
stroker.setDashOffset(lineDashPattern.getDashOffset());
|
||||
}
|
||||
QPainterPath strokedPath = stroker.createStroke(path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user