mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-02 22:17:06 +08:00
Added more font description strings for pdf_fonts.go test program
This commit is contained in:
parent
539a3be976
commit
187c3e37dd
@ -41,7 +41,19 @@ func (font PdfFont) BaseFont() string {
|
||||
|
||||
// Subtype returns the font's "Subtype" field.
|
||||
func (font PdfFont) Subtype() string {
|
||||
return font.fontSkeleton.subtype
|
||||
subtype := font.fontSkeleton.subtype
|
||||
if t, ok := font.context.(*pdfFontType0); ok {
|
||||
subtype = fmt.Sprintf("%s:%s", subtype, t.DescendantFont.Subtype())
|
||||
}
|
||||
return subtype
|
||||
}
|
||||
|
||||
// ToUnicode returns the name of the font's "ToUnicode" field if there is one, or "" if there isn't.
|
||||
func (font PdfFont) ToUnicode() string {
|
||||
if font.ucMap == nil {
|
||||
return ""
|
||||
}
|
||||
return font.ucMap.Name()
|
||||
}
|
||||
|
||||
// NewPdfFontFromPdfObject loads a PdfFont from the dictionary `fontObj`. If there is a problem an
|
||||
|
@ -161,7 +161,8 @@ func newPdfFontType0FromPdfObject(obj PdfObject, skeleton *fontSkeleton) (*pdfFo
|
||||
}
|
||||
|
||||
encoderName, err := GetName(TraceToDirectObject(d.Get("Encoding")))
|
||||
if err == nil && encoderName == "Identity-H" {
|
||||
// XXX: FIXME This is not valid if encoder is not Identity-H !@#$
|
||||
if err == nil /*&& encoderName == "Identity-H"*/ {
|
||||
font.encoder = textencoding.NewIdentityTextEncoder(encoderName)
|
||||
}
|
||||
return font, nil
|
||||
|
@ -15,6 +15,7 @@ package textencoding
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/unidoc/unidoc/common"
|
||||
@ -52,11 +53,14 @@ func NewSimpleTextEncoder(baseName string, differences map[byte]string) (SimpleE
|
||||
}
|
||||
}
|
||||
}
|
||||
return makeEncoder(baseName, codeToRune), nil
|
||||
return makeEncoder(baseName, differences, codeToRune), nil
|
||||
}
|
||||
|
||||
// String returns a string that describes `se`.
|
||||
func (se SimpleEncoder) String() string {
|
||||
if len(se.differences) > 0 {
|
||||
return fmt.Sprintf("%s + differences", se.baseName)
|
||||
}
|
||||
return se.baseName
|
||||
}
|
||||
|
||||
@ -124,7 +128,7 @@ func (se SimpleEncoder) ToPdfObject() PdfObject {
|
||||
}
|
||||
|
||||
// makeEncoder returns a SimpleEncoder based on `codeToRune`.
|
||||
func makeEncoder(baseName string, codeToRune map[uint16]rune) SimpleEncoder {
|
||||
func makeEncoder(baseName string, differences map[byte]string, codeToRune map[uint16]rune) SimpleEncoder {
|
||||
codeToGlyph := map[uint16]string{}
|
||||
glyphToCode := map[string]uint16{}
|
||||
for code, r := range codeToRune {
|
||||
@ -134,6 +138,7 @@ func makeEncoder(baseName string, codeToRune map[uint16]rune) SimpleEncoder {
|
||||
}
|
||||
return SimpleEncoder{
|
||||
baseName: baseName,
|
||||
differences: differences,
|
||||
codeToGlyph: codeToGlyph,
|
||||
glyphToCode: glyphToCode,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user