Issue #69: Dashed Line not rendered as expected

This commit is contained in:
Jakub Melka
2023-07-25 18:26:57 +02:00
parent 2daf1a6d53
commit 06e1ed1f47
5 changed files with 23 additions and 10 deletions

View File

@ -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;