mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-27 13:48:51 +08:00
Define font descriptor flags
This commit is contained in:
parent
990a56dc01
commit
5257855e29
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user