feat(后端架构): 优化多后端渲染,修复描边与字形校验
build.yaml / build (push) Successful in 40s

This commit is contained in:
xiaoqidun committed 2026-09-23 20:04:48 +08:00
1 parent f44d0d8a60
commit 580e7043c4
31 files changed
+1488 -204

No files matched your search

+17 -2
View File
@@ -35,6 +35,20 @@ type FontOutlines interface {
GlyphOutline(glyph uint16, size float64) (GeometryPath, error)
}
// FontShaper 提供可选的横向文字塑形,仅用于显式新建或重排
// 字形按逻辑簇顺序排列,Cluster使用原文的符文索引,坐标为毫米且纵轴向下
type FontShaper interface {
FontMetrics
ShapeText(value string, size float64) ([]ShapedGlyph, error)
}
// ShapedGlyph 保存塑形后的字形、原文簇和基线定位
type ShapedGlyph struct {
Glyph uint16
Cluster int
X, Y, Advance float64
}
// ResolvedFont 保存字体来源和只读字体数据,不将外部字体写入文档
type ResolvedFont struct {
Data []byte
@@ -78,8 +92,8 @@ func (r *Renderer) resetFontBackendCache() {
r.fontSourcesCache.fallback = ResolvedFont{}
r.fontSourcesCache.fallbackRead = false
}
r.fontMetrics = make(map[*PreparedFont]FontMetrics)
r.glyphOutlines = make(map[glyphOutlineKey]GeometryPath)
r.fontMetrics = renderCache[[32]byte, FontMetrics]{limit: 32 << 20}
r.glyphOutlines = renderCache[glyphOutlineKey, GeometryPath]{limit: 16 << 20}
for _, state := range r.backendStates {
if fonts, ok := state.(interface{ resetFonts() }); ok {
fonts.resetFonts()
@@ -110,6 +124,7 @@ type PreparedFont struct {
ResolvedFont
Glyphs map[uint16]rune
CIDs map[uint16]rune
digest [32]byte
}
// PrepareFont 统一处理内嵌字体包装和索引映射,供各编译器复用