feat(渲染转换): 完善PDF转换及点线绘制
build.yaml / build (push) Successful in 43s

This commit is contained in:
xiaoqidun committed 2026-09-27 15:26:10 +08:00
1 parent e78ea6f919
commit 3b9f88cbba
16 files changed
+383 -43

No files matched your search

+9 -3
View File
@@ -17,6 +17,7 @@ package ofdgo
import (
"image/color"
"math"
"slices"
"github.com/tdewolff/canvas"
)
@@ -291,15 +292,20 @@ func (r *Renderer) renderPath(ctx *canvas.Context, obj PathObject, pageH float64
ctx.SetStrokeCapper(style.lineCap)
ctx.SetStrokeJoiner(style.lineJoin)
sp := p
if len(style.dashPattern) > 0 {
zeroDash := slices.Contains(style.dashPattern, 0)
if len(style.dashPattern) > 0 && !zeroDash {
sp = sp.Dash(style.dashOffset, style.dashPattern...)
ctx.SetDashes(0)
}
strokeClip := intersectClipPath(clipPath, shadingClip)
_, repeat := strokePaint.(*repeatAxialGradient)
if strokeClip != nil || strokeView != canvas.Identity || repeat || style.strokePattern != nil || !canvasNativeStroke(r.backends.Geometry) {
if strokeClip != nil || strokeView != canvas.Identity || repeat || style.strokePattern != nil || !canvasNativeStroke(r.backends.Geometry) || zeroDash {
sp = sp.Copy()
sp = r.strokeCanvasPath(sp, style.lineWidth, style.lineCap, style.lineJoin)
if zeroDash {
sp = r.strokeDashedCanvasPath(sp, style.lineWidth, style.lineCap, style.lineJoin, style.dashOffset, style.dashPattern)
} else {
sp = r.strokeCanvasPath(sp, style.lineWidth, style.lineCap, style.lineJoin)
}
sp = applyClipPath(sp, strokeClip)
if style.strokePattern != nil {
r.renderPattern(ctx, style.strokePattern, pageH, sp, objectCTM)