feat(渲染引擎): 修复文字渲染并优化图像处理
build.yaml / build (push) Successful in 45s

This commit is contained in:
xiaoqidun committed 2026-10-03 10:51:50 +08:00
1 parent 1945ea355a
commit f2dbf72885
15 files changed
+344 -21

No files matched your search

+14 -2
View File
@@ -115,7 +115,7 @@ func (r *Renderer) renderText(ctx *canvas.Context, obj TextObject, pageH float64
}
strokeStyle.applyLineJoin(obj.Join, obj.MiterLimit)
if strokeStyle.strokePaint == nil {
strokeStyle.strokePaint = colorWithAlpha(canvas.Black, obj.Alpha)
strokeStyle.strokePaint = canvas.Transparent
}
strokeStyle.scale(ctm)
if strokeStyle.lineWidth == 0 {
@@ -182,10 +182,22 @@ func (r *Renderer) renderText(ctx *canvas.Context, obj TextObject, pageH float64
return
}
face := ff.Face(sizePt, fillPaint, fontStyle, canvas.FontNormal)
recoverBaseline := len(obj.TextCode) > 0 && obj.TextCode[0].Y == ""
var metrics canvas.FontMetrics
if textRun != nil {
if textRun != nil || recoverBaseline {
metrics = face.Metrics()
}
ascent := metrics.Ascent
if scale := ctm.YScale(); scale > 0 && !useTextMatrix {
ascent /= scale
}
obj.TextCode = textCodeOrigins(obj.TextCode, ascent)
if textRun != nil && recoverBaseline {
if text := obj.Text(); text != textRun.Text {
textRun.Text = text
textRun.Boxes = make([]Box, len([]rune(text)))
}
}
glyphTransforms := r.textObjectGlyphTransforms(fontID, obj)
hasUnderline := strings.Contains(obj.Decoration, "Underline")
_, shadedFill := fillPaint.(canvas.Gradient)