mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-02 22:17:06 +08:00
golint and godoc fixes in textencoding
This commit is contained in:
parent
a487f6848a
commit
0b25fcc4e7
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/unidoc/unidoc/pdf/core"
|
"github.com/unidoc/unidoc/pdf/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TextEncoder defines the common methods that a text encoder implementation must have in UniDoc.
|
||||||
type TextEncoder interface {
|
type TextEncoder interface {
|
||||||
// String returns a string that describes the TextEncoder instance.
|
// String returns a string that describes the TextEncoder instance.
|
||||||
String() string
|
String() string
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* The embedded glyph to unicode mappings specified in this file are distributed under the terms
|
* The embedded glyph to unicode mappings specified in this file are distributed under the terms
|
||||||
* listed in ./glyphlist/glyphlist.txt, ./glyphlist/texglyphlist.txt and ./glyphlist/addtional.txt
|
* listed in ./testdata/glyphlist/glyphlist.txt, ./testdata/glyphlist/texglyphlist.txt
|
||||||
|
* and ./tesdtdata/glyphlist/addtional.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package textencoding
|
package textencoding
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* The embedded glyph to unicode mappings specified in this file are distributed under the terms listed in
|
* The embedded glyph to unicode mappings specified in this file are distributed under the terms listed in
|
||||||
* ./glyphlist/zapfdingbats.txt.
|
* ./testdata/glyphlist/zapfdingbats.txt.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package textencoding
|
package textencoding
|
||||||
|
@ -18,8 +18,8 @@ type IdentityEncoder struct {
|
|||||||
baseName string
|
baseName string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSimpleTextEncoder returns a IdentityEncoder based on predefined encoding `baseName` and
|
// NewIdentityTextEncoder returns a new IdentityEncoder based on predefined
|
||||||
// difference map `differences`.
|
// encoding `baseName` and difference map `differences`.
|
||||||
func NewIdentityTextEncoder(baseName string) IdentityEncoder {
|
func NewIdentityTextEncoder(baseName string) IdentityEncoder {
|
||||||
return IdentityEncoder{baseName}
|
return IdentityEncoder{baseName}
|
||||||
}
|
}
|
||||||
|
@ -38,14 +38,14 @@ func NewTrueTypeFontEncoder(runeToGlyphIndexMap map[uint16]uint16) TrueTypeFontE
|
|||||||
// ttEncoderNumEntries is the maximum number of encoding entries shown in SimpleEncoder.String()
|
// ttEncoderNumEntries is the maximum number of encoding entries shown in SimpleEncoder.String()
|
||||||
const ttEncoderNumEntries = 1000
|
const ttEncoderNumEntries = 1000
|
||||||
|
|
||||||
// String returns a string that describes `se`.
|
// String returns a string that describes `enc`.
|
||||||
func (se TrueTypeFontEncoder) String() string {
|
func (enc TrueTypeFontEncoder) String() string {
|
||||||
parts := []string{
|
parts := []string{
|
||||||
fmt.Sprintf("%d entries", len(se.runeToGlyphIndexMap)),
|
fmt.Sprintf("%d entries", len(enc.runeToGlyphIndexMap)),
|
||||||
}
|
}
|
||||||
|
|
||||||
codes := []int{}
|
codes := []int{}
|
||||||
for c := range se.runeToGlyphIndexMap {
|
for c := range enc.runeToGlyphIndexMap {
|
||||||
codes = append(codes, int(c))
|
codes = append(codes, int(c))
|
||||||
}
|
}
|
||||||
sort.Ints(codes)
|
sort.Ints(codes)
|
||||||
@ -57,7 +57,7 @@ func (se TrueTypeFontEncoder) String() string {
|
|||||||
for i := 0; i < numCodes; i++ {
|
for i := 0; i < numCodes; i++ {
|
||||||
c := codes[i]
|
c := codes[i]
|
||||||
parts = append(parts, fmt.Sprintf("%d=0x%02x: %q",
|
parts = append(parts, fmt.Sprintf("%d=0x%02x: %q",
|
||||||
c, c, se.runeToGlyphIndexMap[uint16(c)]))
|
c, c, enc.runeToGlyphIndexMap[uint16(c)]))
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("TRUETYPE_ENCODER{%s}", strings.Join(parts, ", "))
|
return fmt.Sprintf("TRUETYPE_ENCODER{%s}", strings.Join(parts, ", "))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user