mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-01 22:17:29 +08:00
creator: remove SetEncoder from top
This commit is contained in:
parent
62420700db
commit
19f95527b8
@ -13,7 +13,6 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/unidoc/unidoc/common"
|
||||
"github.com/unidoc/unidoc/pdf/internal/textencoding"
|
||||
"github.com/unidoc/unidoc/pdf/model"
|
||||
)
|
||||
|
||||
@ -57,9 +56,6 @@ type Creator struct {
|
||||
// Default fonts used by all components instantiated through the creator.
|
||||
defaultFontRegular *model.PdfFont
|
||||
defaultFontBold *model.PdfFont
|
||||
|
||||
// Default encoder used by all components instantiated through the creator.
|
||||
defaultTextEncoder textencoding.TextEncoder
|
||||
}
|
||||
|
||||
// SetForms adds an Acroform to a PDF file. Sets the specified form for writing.
|
||||
@ -112,9 +108,6 @@ func New() *Creator {
|
||||
c.pageMargins.top = m
|
||||
c.pageMargins.bottom = m
|
||||
|
||||
// Initialize default text encoder.
|
||||
c.defaultTextEncoder = textencoding.NewWinAnsiTextEncoder()
|
||||
|
||||
// Initialize default fonts.
|
||||
var err error
|
||||
|
||||
@ -122,13 +115,11 @@ func New() *Creator {
|
||||
if err != nil {
|
||||
c.defaultFontRegular = model.DefaultFont()
|
||||
}
|
||||
c.defaultFontRegular.SetEncoder(c.defaultTextEncoder)
|
||||
|
||||
c.defaultFontBold, err = model.NewStandard14Font(model.HelveticaBold)
|
||||
if err != nil {
|
||||
c.defaultFontRegular = model.DefaultFont()
|
||||
}
|
||||
c.defaultFontBold.SetEncoder(c.defaultTextEncoder)
|
||||
|
||||
// Initialize creator table of contents.
|
||||
c.toc = c.NewTOC("Table of Contents")
|
||||
|
@ -74,14 +74,14 @@ func newParagraph(text string, style TextStyle) *Paragraph {
|
||||
p := &Paragraph{}
|
||||
p.text = text
|
||||
|
||||
font, encoder, err := model.NewStandard14FontWithEncoding("Helvetica", model.GetAlphabet(text))
|
||||
// TODO(dennwc): looks like it's tried to verify if the font has some runes missing
|
||||
// but do we really care? the user knows better what font to use, and he can change it with SetFont
|
||||
font, err := model.NewStandard14Font("Helvetica")
|
||||
if err != nil {
|
||||
common.Log.Debug("ERROR: NewStandard14FontWithEncoding failed err=%v. Falling back.", err)
|
||||
p.textFont = model.DefaultFont()
|
||||
}
|
||||
p.textFont = font
|
||||
// TODO(dennwc): can it use the default font encoder?
|
||||
p.SetEncoder(encoder)
|
||||
|
||||
p.fontSize = 10
|
||||
p.lineHeight = 1.0
|
||||
@ -116,11 +116,6 @@ func (p *Paragraph) SetTextAlignment(align TextAlignment) {
|
||||
p.alignment = align
|
||||
}
|
||||
|
||||
// SetEncoder sets the text encoding.
|
||||
func (p *Paragraph) SetEncoder(encoder textencoding.TextEncoder) {
|
||||
p.textFont.SetEncoder(encoder)
|
||||
}
|
||||
|
||||
// SetLineHeight sets the line height (1.0 default).
|
||||
func (p *Paragraph) SetLineHeight(lineheight float64) {
|
||||
p.lineHeight = lineheight
|
||||
|
@ -380,20 +380,6 @@ func (font PdfFont) Encoder() textencoding.TextEncoder {
|
||||
return t.Encoder()
|
||||
}
|
||||
|
||||
// SetEncoder sets the encoding for the underlying font.
|
||||
func (font PdfFont) SetEncoder(encoder textencoding.TextEncoder) {
|
||||
t := font.actualFont()
|
||||
if t == nil {
|
||||
common.Log.Debug("ERROR: SetEncoder. Not implemented for font type=%#T", font.context)
|
||||
return
|
||||
}
|
||||
if t, ok := t.(interface {
|
||||
SetEncoder(encoder textencoding.TextEncoder)
|
||||
}); ok {
|
||||
t.SetEncoder(encoder)
|
||||
}
|
||||
}
|
||||
|
||||
// GetGlyphCharMetrics returns the specified char metrics for a specified glyph name.
|
||||
func (font PdfFont) GetGlyphCharMetrics(glyph textencoding.GlyphName) (fonts.CharMetrics, bool) {
|
||||
t := font.actualFont()
|
||||
|
Loading…
x
Reference in New Issue
Block a user