Define font descriptor flags

This commit is contained in:
Hiroshi Muramatsu 2018-07-23 13:21:13 +10:00
parent 990a56dc01
commit 5257855e29
3 changed files with 21 additions and 10 deletions

View File

@ -468,6 +468,20 @@ func toUnicodeToCmap(toUnicode core.PdfObject, font *fontCommon) (*cmap.CMap, er
return cm, err
}
const (
fontFlagFixedPitch = 1 << iota
fontFlagSerif
fontFlagSymbolic
fontFlagScript
// Bit position 5 is not defined
fontFlagNonsymbolic = 1 << (iota + 1)
fontFlagItalic
// Bit position 8 - 16 are not defined
fontFlagAllCap = 1 << (iota + 10)
fontFlagSmallCap
fontFlagForceBold
)
// PdfFontDescriptor specifies metrics and other attributes of a font and can refer to a FontFile
// for embedded fonts.
// 9.8 Font Descriptors (page 281)

View File

@ -578,16 +578,14 @@ func NewCompositePdfFontFromTTFFile(filePath string) (*PdfFont, error) {
descriptor.StemV = core.MakeInteger(70)
}
// Flags.
//flags := 1 << 5 // Non-Symbolic.
flags := uint32(0)
// Flags
flags := fontFlagSymbolic // Symbolic.
if ttf.IsFixedPitch {
flags |= 1
flags |= fontFlagFixedPitch
}
if ttf.ItalicAngle != 0 {
flags |= 1 << 6
flags |= fontFlagItalic
}
flags |= 1 << 2 // Symbolic.
descriptor.Flags = core.MakeInteger(int64(flags))
base.fontDescriptor = descriptor

View File

@ -426,13 +426,12 @@ func NewPdfFontFromTTFFile(filePath string) (*PdfFont, error) {
descriptor.StemV = core.MakeInteger(70)
}
// Flags.
flags := 1 << 5
flags := fontFlagNonsymbolic
if ttf.IsFixedPitch {
flags |= 1
flags |= fontFlagFixedPitch
}
if ttf.ItalicAngle != 0 {
flags |= 1 << 6
flags |= fontFlagItalic
}
descriptor.Flags = core.MakeInteger(int64(flags))