Documentation
¶
Overview ¶
Package canvas 提供 tdewolff/canvas 的 render 后端实现:DrawContext (canvasBackend)、矢量表面与 PDF 写入器(VectorSurface/PDFDocument)、 SVG 场景、离屏栅格表面、内置栅格后端(BackendCanvas),以及默认字体引擎 (Fonts)。
空白导入本包即可注册上述能力:
import _ "github.com/zc310/ofd/internal/render/backends/canvas"
Index ¶
- Constants
- type CTColor
- type FontFace
- type FontFamily
- type FontStyle
- type Fonts
- func (p *Fonts) FaceObject(family drawing.FontFamily, object models.TextObject, fill *drawing.CTColor) drawing.FontFace
- func (p *Fonts) FallbackFontFamily(id models.StRefID) string
- func (p *Fonts) HasLoadedEmbeddedFont(id models.StRefID) bool
- func (p *Fonts) LoadFont(id models.StRefID) (drawing.FontFamily, error)
- func (p *Fonts) RegisterGlyphs(id models.StRefID, pairs map[rune]uint16)
- func (p *Fonts) RegisterPageGlyphs(doc *parser.Document, page *parser.Page, content *models.PageContent)
- func (p *Fonts) RemoveFallbackFont(family string)
- func (p *Fonts) RenderLock(handle drawing.FontFamily) *sync.Mutex
- func (p *Fonts) UseFallbackFont(family string) error
- type TextRun
Constants ¶
const ( FontRegular = drawing.FontRegular FontThin = drawing.FontThin FontExtraLight = drawing.FontExtraLight FontLight = drawing.FontLight FontMedium = drawing.FontMedium FontSemiBold = drawing.FontSemiBold FontBold = drawing.FontBold FontExtraBold = drawing.FontExtraBold FontBlack = drawing.FontBlack FontItalic = drawing.FontItalic )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fonts ¶
type Fonts struct {
*parser.Document
Fonts map[models.StRefID]*canvas.FontFamily
// contains filtered or unexported fields
}
func (*Fonts) FaceObject ¶
func (p *Fonts) FaceObject(family drawing.FontFamily, object models.TextObject, fill *drawing.CTColor) drawing.FontFace
FaceObject 为字体族与文字对象创建一个中性字体面。fill 为文字填充色/渐变。
func (*Fonts) FallbackFontFamily ¶
FallbackFontFamily 返回为文档字体选择的外部字体族。 必须先调用 LoadFont;TextLayouts 和 Text 会自动完成这一步。
func (*Fonts) HasLoadedEmbeddedFont ¶
HasLoadedEmbeddedFont 判断文档字体是否解析为可用且已加载的字体族。 仅声明 FontFile 并不够,因为文件可能缺失、格式错误或被字体解析器拒绝。
func (*Fonts) RegisterGlyphs ¶
RegisterGlyphs 登记某个字体的 Unicode→字形映射。新增或变更映射时会作废该 字体已加载的族,使后续 LoadFont 用完整映射重建,保证渲染使用原始文本。
func (*Fonts) RegisterPageGlyphs ¶
func (p *Fonts) RegisterPageGlyphs(doc *parser.Document, page *parser.Page, content *models.PageContent)
registerPageGlyphs 扫描页面(含模板与注释)的文字对象并登记字形映射。
func (*Fonts) RemoveFallbackFont ¶
RemoveFallbackFont 移除本字体上下文先前通过 UseFallbackFont 登记的回退字体族, 使缺失字体不再回退到该族。全局注册表不回滚,但本上下文的回退集合与解析缓存会 重建,后续渲染即恢复为内嵌或默认字体。
func (*Fonts) RenderLock ¶
func (p *Fonts) RenderLock(handle drawing.FontFamily) *sync.Mutex
func (*Fonts) UseFallbackFont ¶
UseFallbackFont 使当前字体上下文在缺失字体时使用已全局注册的回退字体族。 该字体族必须先通过 RegisterFallbackFont 注册;其全部已注册样式都会生效。
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package canvasconv 提供 internal/render/geom 的中性几何类型与 tdewolff/canvas 类型之间的转换,供 canvas 后端(把 geom 绘制指令转成 canvas.Canvas 用于 Page()/PDF/SVG 矢量输出)以及迁移期的适配层使用。
|
Package canvasconv 提供 internal/render/geom 的中性几何类型与 tdewolff/canvas 类型之间的转换,供 canvas 后端(把 geom 绘制指令转成 canvas.Canvas 用于 Page()/PDF/SVG 矢量输出)以及迁移期的适配层使用。 |