feat(字体渲染): 优化字体渲染

This commit is contained in:
2026-07-01 15:01:32 +08:00
parent e5e8063c4e
commit 614483f205
2 changed files with 33 additions and 7 deletions
+7 -3
View File
@@ -835,9 +835,7 @@ func (r *Renderer) renderText(ctx *canvas.Context, obj TextObject, pageH float64
if weight == 0 && dp != nil && dp.Weight > 0 {
weight = dp.Weight
}
if weight >= 700 {
fontStyle |= canvas.FontBold
}
syntheticBold := weight >= 700
italic := obj.Italic
if !italic && dp != nil && dp.Italic {
italic = true
@@ -849,6 +847,9 @@ func (r *Renderer) renderText(ctx *canvas.Context, obj TextObject, pageH float64
embeddedFont := false
if of, ok := r.Reader.fontCache[fontID]; ok {
embeddedFont = of.FontFile != ""
if !embeddedFont && fontNoSyntheticBold(of.FontName, of.FamilyName) {
syntheticBold = false
}
if of.Bold {
fontStyle |= canvas.FontBold
}
@@ -856,6 +857,9 @@ func (r *Renderer) renderText(ctx *canvas.Context, obj TextObject, pageH float64
fontStyle |= canvas.FontItalic
}
}
if syntheticBold {
fontStyle |= canvas.FontBold
}
ff := r.loadFont(fontID)
if ff == nil {
return