feat(转换能力): 修正颜色转换与路径填充
build.yaml / build (push) Successful in 43s

This commit is contained in:
xiaoqidun committed 2026-09-28 20:23:12 +08:00
1 parent 73105646aa
commit 30d9699385
6 files changed
+12 -18

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ require (
github.com/tdewolff/canvas v0.0.0-20260923214215-09804640d00c
github.com/tdewolff/font v0.0.0-20260913163313-54f98bb59ee6
github.com/xiaoqidun/jbig2 v1.1.1
github.com/xiaoqidun/pdfgo v0.0.0-20260928111239-49265df4c04c
github.com/xiaoqidun/pdfgo v0.0.0-20260928121523-d13a51030150
golang.org/x/crypto v0.57.0
golang.org/x/image v0.46.0
golang.org/x/text v0.42.0
+2 -2
View File
@@ -62,8 +62,8 @@ github.com/tdewolff/test v1.0.12 h1:7F21DqIajswxuche0geHdrUZRCWE4oko4b7bcmkkrxk=
github.com/tdewolff/test v1.0.12/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
github.com/xiaoqidun/jbig2 v1.1.1 h1:SjliS9ZO0e9HX5oYUfBuXrfFsXhWricrSz+XY4zORDI=
github.com/xiaoqidun/jbig2 v1.1.1/go.mod h1:8QonVWtENmh2kc6l+leqeGl7psb79DWlHDkCpdChjfQ=
github.com/xiaoqidun/pdfgo v0.0.0-20260928111239-49265df4c04c h1:AkN9yw2b5LXinOBkWy/Wppdu4AtqQ2j6M4AYxlThL/A=
github.com/xiaoqidun/pdfgo v0.0.0-20260928111239-49265df4c04c/go.mod h1:4Pf0JO0BEf1uzRY+uZjlMjN/OPn3PYa0YMi6cqPPTLQ=
github.com/xiaoqidun/pdfgo v0.0.0-20260928121523-d13a51030150 h1:N4JwW+p/KtgiNeNGVEdqswfLvefqZXGeS6tPpYKpIJQ=
github.com/xiaoqidun/pdfgo v0.0.0-20260928121523-d13a51030150/go.mod h1:4Pf0JO0BEf1uzRY+uZjlMjN/OPn3PYa0YMi6cqPPTLQ=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yuin/goldmark v1.8.5 h1:r6N5afV5qj/5S4UTch8agZHJ8UxNCMwX7WjkkJam2NA=
+1 -1
View File
@@ -315,7 +315,7 @@ func pdfBounds(points []pdfgo.Point) Box {
// 返回: *FillColor OFD颜色
func (p *pdfImporter) color(paint pdfgo.Paint) *FillColor {
alpha := int(math.Round(paint.Alpha * 255))
if paint.CMYK != nil {
if paint.CMYK != nil && (paint.Space == nil || !paint.Space.Calibrated()) {
if p.cmykSpace == "" {
p.cmykSpace = p.editor.nextID()
p.editor.resources = append(p.editor.resources, editorResource{space: &ColorSpace{ID: p.cmykSpace, Type: "CMYK", BitsPerComponent: 16}})
+3 -3
View File
@@ -52,7 +52,7 @@ func pdfGradientStopsError(stops []pdfgo.GradientStop, space *pdfgo.ColorSpace)
for i := 1; i < len(stops); i++ {
a, b := stops[i-1], stops[i]
if a.Position != b.Position && a.Values != b.Values {
return &pdfgo.UnsupportedError{Feature: "nonlinear ICC gradient conversion"}
return &pdfgo.UnsupportedError{Feature: "nonlinear calibrated gradient conversion"}
}
}
}
@@ -69,7 +69,7 @@ func pdfGradientError(paint pdfgo.Paint) error {
return &pdfgo.UnsupportedError{Feature: "nonlinear mesh conversion"}
}
if mesh.Space.Calibrated() && !mesh.Space.SRGBEquivalent() {
return &pdfgo.UnsupportedError{Feature: "nonlinear ICC mesh conversion"}
return &pdfgo.UnsupportedError{Feature: "nonlinear calibrated mesh conversion"}
}
}
if paint.Axial != nil {
@@ -99,7 +99,7 @@ func (p *pdfImporter) gradientPath(mark pdfgo.PathMark) error {
case paint.Mesh != nil:
space = paint.Mesh.Space
}
if paint.CMYK == nil && (space == nil || space.Model != "DeviceCMYK" || space.Calibrated()) {
if space != nil && space.Calibrated() || paint.CMYK == nil && (space == nil || space.Model != "DeviceCMYK") {
cmyk = false
break
}
+1 -3
View File
@@ -139,13 +139,11 @@ func (c *semanticCompiler) fill(path GeometryPath, paint Paint, evenOdd bool, cl
if len(path) == 0 || paint.Kind == PaintNone || paint.Kind == PaintSolid && paint.Color.A == 0 {
return nil
}
path = closedGeometry(path)
if !c.measure && paint.Kind != PaintPattern {
return c.command(path, paint, evenOdd, clip, shadingMatrix, nil)
}
var err error
if clip != nil || paint.Kind == PaintPattern || paint.Gradient != nil || paint.Mesh != nil {
path = closedGeometry(path)
}
if evenOdd && (clip != nil || paint.Kind == PaintPattern || paint.Gradient != nil || paint.Mesh != nil) {
path, err = c.geometry.Normalize(path, true)
if err != nil {
+4 -8
View File
@@ -245,15 +245,11 @@ func (r *Renderer) renderPath(ctx *canvas.Context, obj PathObject, pageH float64
if shouldFill {
fillPaint, shadingClip, fillView := resolveShdPaint(ctx, style.fillPaint)
fillClip := intersectClipPath(clipPath, shadingClip)
fp := p
_, repeat := fillPaint.(*repeatAxialGradient)
if fillClip != nil || repeat {
paths := canvas.Paths(p.Copy().Split())
for _, path := range paths {
path.Close()
}
fp = paths.Merge()
paths := canvas.Paths(p.Copy().Split())
for _, path := range paths {
path.Close()
}
fp := paths.Merge()
fillRule := canvas.NonZero
if obj.Rule == "Even-Odd" {
fillRule = canvas.EvenOdd