rename Typ1 font to StdFont

This commit is contained in:
Denys Smirnov 2018-12-15 18:40:48 +05:00
parent 19f95527b8
commit e3704defc7
7 changed files with 43 additions and 43 deletions

View File

@ -404,7 +404,7 @@ func (font PdfFont) actualFont() fonts.Font {
return t
case *pdfCIDFontType2:
return t
case fonts.Type1Font:
case fonts.StdFont:
return t
default:
common.Log.Debug("ERROR: actualFont. Unknown font type %t. font=%s", t, font)

View File

@ -451,7 +451,7 @@ const (
ZapfDingbats = Standard14Font(fonts.ZapfDingbatsName)
)
// TODO(dennwc): merge with font.Type1Font
// TODO(dennwc): merge with font.StdFont
var standard14Fonts = map[Standard14Font]pdfFontSimple{
Courier: {
fontCommon: fontCommon{

View File

@ -10,24 +10,24 @@ import (
"github.com/unidoc/unidoc/pdf/internal/textencoding"
)
var _ Font = Type1Font{}
var _ Font = StdFont{}
// Type1Font represents one of the built-in fonts and it is assumed that every reader has access to it.
type Type1Font struct {
// StdFont represents one of the built-in fonts and it is assumed that every reader has access to it.
type StdFont struct {
name string
metrics map[GlyphName]CharMetrics
encoder textencoding.TextEncoder
}
// NewType1Font returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewType1Font(name string, metrics map[GlyphName]CharMetrics) Type1Font {
// NewStdFont returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewStdFont(name string, metrics map[GlyphName]CharMetrics) StdFont {
enc := textencoding.NewWinAnsiTextEncoder() // Default
return NewType1FontWithEncoding(name, metrics, enc)
return NewStdFontWithEncoding(name, metrics, enc)
}
// NewType1FontWithEncoding returns a new instance of the font with a specified encoder.
func NewType1FontWithEncoding(name string, metrics map[GlyphName]CharMetrics, encoder textencoding.TextEncoder) Type1Font {
return Type1Font{
// NewStdFontWithEncoding returns a new instance of the font with a specified encoder.
func NewStdFontWithEncoding(name string, metrics map[GlyphName]CharMetrics, encoder textencoding.TextEncoder) StdFont {
return StdFont{
name: name,
metrics: metrics,
encoder: encoder,
@ -35,17 +35,17 @@ func NewType1FontWithEncoding(name string, metrics map[GlyphName]CharMetrics, en
}
// Name returns a PDF name of the font.
func (font Type1Font) Name() string {
func (font StdFont) Name() string {
return font.name
}
// Encoder returns the font's text encoder.
func (font Type1Font) Encoder() textencoding.TextEncoder {
func (font StdFont) Encoder() textencoding.TextEncoder {
return font.encoder
}
// GetGlyphCharMetrics returns character metrics for a given glyph.
func (font Type1Font) GetGlyphCharMetrics(glyph GlyphName) (CharMetrics, bool) {
func (font StdFont) GetGlyphCharMetrics(glyph GlyphName) (CharMetrics, bool) {
metrics, has := font.metrics[glyph]
if !has {
return metrics, false
@ -55,7 +55,7 @@ func (font Type1Font) GetGlyphCharMetrics(glyph GlyphName) (CharMetrics, bool) {
}
// ToPdfObject returns a primitive PDF object representation of the font.
func (font Type1Font) ToPdfObject() core.PdfObject {
func (font StdFont) ToPdfObject() core.PdfObject {
fontDict := core.MakeDict()
fontDict.Set("Type", core.MakeName("Font"))
fontDict.Set("Subtype", core.MakeName("Type1"))

View File

@ -21,24 +21,24 @@ const (
)
// NewFontCourier returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewFontCourier() Type1Font {
return NewType1Font(CourierName, CourierCharMetrics)
func NewFontCourier() StdFont {
return NewStdFont(CourierName, CourierCharMetrics)
}
// NewFontCourierBold returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewFontCourierBold() Type1Font {
return NewType1Font(CourierBoldName, CourierBoldCharMetrics)
func NewFontCourierBold() StdFont {
return NewStdFont(CourierBoldName, CourierBoldCharMetrics)
}
// NewFontCourierOblique returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewFontCourierOblique() Type1Font {
return NewType1Font(CourierObliqueName, CourierObliqueCharMetrics)
func NewFontCourierOblique() StdFont {
return NewStdFont(CourierObliqueName, CourierObliqueCharMetrics)
}
// NewFontCourierBoldOblique returns a new instance of the font with a default encoder set
// (WinAnsiEncoding).
func NewFontCourierBoldOblique() Type1Font {
return NewType1Font(CourierBoldObliqueName, CourierBoldObliqueCharMetrics)
func NewFontCourierBoldOblique() StdFont {
return NewStdFont(CourierBoldObliqueName, CourierBoldObliqueCharMetrics)
}
func init() {

View File

@ -21,24 +21,24 @@ const (
)
// NewFontHelvetica returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewFontHelvetica() Type1Font {
return NewType1Font(HelveticaName, HelveticaCharMetrics)
func NewFontHelvetica() StdFont {
return NewStdFont(HelveticaName, HelveticaCharMetrics)
}
// NewFontHelveticaBold returns a new instance of the font with a default encoder set
// (WinAnsiEncoding).
func NewFontHelveticaBold() Type1Font {
return NewType1Font(HelveticaBoldName, HelveticaBoldCharMetrics)
func NewFontHelveticaBold() StdFont {
return NewStdFont(HelveticaBoldName, HelveticaBoldCharMetrics)
}
// NewFontHelveticaOblique returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewFontHelveticaOblique() Type1Font {
return NewType1Font(HelveticaObliqueName, HelveticaObliqueCharMetrics)
func NewFontHelveticaOblique() StdFont {
return NewStdFont(HelveticaObliqueName, HelveticaObliqueCharMetrics)
}
// NewFontHelveticaBoldOblique returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewFontHelveticaBoldOblique() Type1Font {
return NewType1Font(HelveticaBoldObliqueName, HelveticaBoldObliqueCharMetrics)
func NewFontHelveticaBoldOblique() StdFont {
return NewStdFont(HelveticaBoldObliqueName, HelveticaBoldObliqueCharMetrics)
}
func init() {

View File

@ -21,15 +21,15 @@ const (
)
// NewFontSymbol returns a new instance of the font with a default encoder set (SymbolEncoder).
func NewFontSymbol() Type1Font {
func NewFontSymbol() StdFont {
enc := textencoding.NewSymbolEncoder()
return NewType1FontWithEncoding(SymbolName, SymbolCharMetrics, enc)
return NewStdFontWithEncoding(SymbolName, SymbolCharMetrics, enc)
}
// NewFontZapfDingbats returns a new instance of the font with a default encoder set (ZapfDingbatsEncoder).
func NewFontZapfDingbats() Type1Font {
func NewFontZapfDingbats() StdFont {
enc := textencoding.NewZapfDingbatsEncoder()
return NewType1FontWithEncoding(ZapfDingbatsName, ZapfDingbatsCharMetrics, enc)
return NewStdFontWithEncoding(ZapfDingbatsName, ZapfDingbatsCharMetrics, enc)
}
// SymbolCharMetrics are the font metrics loaded from afms/Symbol.afm.

View File

@ -21,23 +21,23 @@ const (
)
// NewFontTimesRoman returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewFontTimesRoman() Type1Font {
return NewType1Font(TimesRomanName, TimesRomanCharMetrics)
func NewFontTimesRoman() StdFont {
return NewStdFont(TimesRomanName, TimesRomanCharMetrics)
}
// NewFontTimesBold returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewFontTimesBold() Type1Font {
return NewType1Font(TimesBoldName, TimesBoldCharMetrics)
func NewFontTimesBold() StdFont {
return NewStdFont(TimesBoldName, TimesBoldCharMetrics)
}
// NewFontTimesItalic returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewFontTimesItalic() Type1Font {
return NewType1Font(TimesItalicName, TimesItalicCharMetrics)
func NewFontTimesItalic() StdFont {
return NewStdFont(TimesItalicName, TimesItalicCharMetrics)
}
// NewFontTimesBoldItalic returns a new instance of the font with a default encoder set (WinAnsiEncoding).
func NewFontTimesBoldItalic() Type1Font {
return NewType1Font(TimesBoldItalicName, TimesBoldItalicCharMetrics)
func NewFontTimesBoldItalic() StdFont {
return NewStdFont(TimesBoldItalicName, TimesBoldItalicCharMetrics)
}
func init() {