mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-02 22:17:06 +08:00
Merge pull request #279 from dennwc/runes
Get metrics by rune instead of a glyph name
This commit is contained in:
commit
e1f2286f9c
@ -34,6 +34,7 @@ type AppearanceStyle struct {
|
||||
// How much of Rect height to fill when autosizing text.
|
||||
AutoFontSizeFraction float64
|
||||
// Glyph used for check mark in checkboxes (for ZapfDingbats font).
|
||||
// TODO(dennwc): can be a rune
|
||||
CheckmarkGlyph textencoding.GlyphName
|
||||
|
||||
BorderSize float64
|
||||
@ -302,18 +303,13 @@ func genFieldTextAppearance(wa *model.PdfAnnotationWidget, ftxt *model.PdfFieldT
|
||||
lastbreakindex := -1
|
||||
linewidth := 0.0
|
||||
for index, r := range lines[i] {
|
||||
glyph, has := encoder.RuneToGlyph(r)
|
||||
if !has {
|
||||
common.Log.Debug("Encoder w/o rune '%c' (%X) - skip", r, r)
|
||||
continue
|
||||
}
|
||||
if glyph == "space" {
|
||||
if r == ' ' {
|
||||
lastbreakindex = index
|
||||
lastwidth = linewidth
|
||||
}
|
||||
metrics, has := font.GetGlyphCharMetrics(glyph)
|
||||
metrics, has := font.GetRuneMetrics(r)
|
||||
if !has {
|
||||
common.Log.Debug("Font does not have glyph metrics for %s - skipping", glyph)
|
||||
common.Log.Debug("Font does not have rune metrics for %v - skipping", r)
|
||||
continue
|
||||
}
|
||||
linewidth += metrics.Wx
|
||||
@ -427,12 +423,7 @@ func genFieldTextAppearance(wa *model.PdfAnnotationWidget, ftxt *model.PdfFieldT
|
||||
for i, line := range lines {
|
||||
wLine := 0.0
|
||||
for _, r := range line {
|
||||
glyph, has := encoder.RuneToGlyph(r)
|
||||
if !has {
|
||||
common.Log.Debug("Encoder w/o rune '%c' (%X) - skip", r, r)
|
||||
continue
|
||||
}
|
||||
metrics, has := font.GetGlyphCharMetrics(glyph)
|
||||
metrics, has := font.GetRuneMetrics(r)
|
||||
if !has {
|
||||
continue
|
||||
}
|
||||
@ -611,24 +602,17 @@ func genFieldTextCombAppearance(wa *model.PdfAnnotationWidget, ftxt *model.PdfFi
|
||||
// Get max glyph height.
|
||||
var maxGlyphWy float64
|
||||
for _, r := range text {
|
||||
if encoder != nil {
|
||||
glyph, has := encoder.RuneToGlyph(r)
|
||||
if !has {
|
||||
common.Log.Debug("ERROR: Rune not found %#v - skipping over", r)
|
||||
continue
|
||||
}
|
||||
metrics, found := font.GetGlyphCharMetrics(glyph)
|
||||
if !found {
|
||||
common.Log.Debug("ERROR: Glyph not found in font: %v - skipping over", glyph)
|
||||
continue
|
||||
}
|
||||
wy := metrics.Wy
|
||||
if int(wy) <= 0 {
|
||||
wy = metrics.Wx
|
||||
}
|
||||
if wy > maxGlyphWy {
|
||||
maxGlyphWy = wy
|
||||
}
|
||||
metrics, found := font.GetRuneMetrics(r)
|
||||
if !found {
|
||||
common.Log.Debug("ERROR: Rune not found in font: %v - skipping over", r)
|
||||
continue
|
||||
}
|
||||
wy := metrics.Wy
|
||||
if int(wy) <= 0 {
|
||||
wy = metrics.Wx
|
||||
}
|
||||
if wy > maxGlyphWy {
|
||||
maxGlyphWy = wy
|
||||
}
|
||||
}
|
||||
if int(maxGlyphWy) == 0 {
|
||||
@ -686,14 +670,9 @@ func genFieldTextCombAppearance(wa *model.PdfAnnotationWidget, ftxt *model.PdfFi
|
||||
tx := 2.0
|
||||
encoded := string(r)
|
||||
if encoder != nil {
|
||||
glyph, has := encoder.RuneToGlyph(r)
|
||||
if !has {
|
||||
common.Log.Debug("ERROR: Rune not found %#v - skipping over", r)
|
||||
continue
|
||||
}
|
||||
metrics, found := font.GetGlyphCharMetrics(glyph)
|
||||
metrics, found := font.GetRuneMetrics(r)
|
||||
if !found {
|
||||
common.Log.Debug("ERROR: Glyph not found in font: %v - skipping over", glyph)
|
||||
common.Log.Debug("ERROR: Rune not found in font: %v - skipping over", r)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -780,14 +759,18 @@ func genFieldCheckboxAppearance(wa *model.PdfAnnotationWidget, fbtn *model.PdfFi
|
||||
|
||||
fontsize := style.AutoFontSizeFraction * height
|
||||
|
||||
checkmetrics, ok := zapfdb.GetGlyphCharMetrics(style.CheckmarkGlyph)
|
||||
if !ok {
|
||||
return nil, errors.New("glyph not found")
|
||||
}
|
||||
checkcode, ok := zapfdb.Encoder().GlyphToCharcode(style.CheckmarkGlyph)
|
||||
if !ok {
|
||||
return nil, errors.New("checkmark glyph - charcode mapping not found")
|
||||
}
|
||||
checkrune, ok := zapfdb.Encoder().CharcodeToRune(checkcode)
|
||||
if !ok {
|
||||
return nil, errors.New("checkmark glyph - rune mapping not found")
|
||||
}
|
||||
checkmetrics, ok := zapfdb.GetRuneMetrics(checkrune)
|
||||
if !ok {
|
||||
return nil, errors.New("glyph not found")
|
||||
}
|
||||
checkwidth := checkmetrics.Wx * fontsize / 1000.0
|
||||
// TODO: Get bbox of specific glyph that is chosen. Choice of specific value will cause slight
|
||||
// deviations for other glyphs, but should be fairly close.
|
||||
@ -995,14 +978,9 @@ func makeComboboxTextXObjForm(width, height float64, text string, style Appearan
|
||||
linewidth := 0.0
|
||||
if encoder != nil {
|
||||
for _, r := range text {
|
||||
glyph, has := encoder.RuneToGlyph(r)
|
||||
metrics, has := font.GetRuneMetrics(r)
|
||||
if !has {
|
||||
common.Log.Debug("Encoder w/o rune '%c' (%X) - skip", r, r)
|
||||
continue
|
||||
}
|
||||
metrics, has := font.GetGlyphCharMetrics(glyph)
|
||||
if !has {
|
||||
common.Log.Debug("Font does not have glyph metrics for %s - skipping", glyph)
|
||||
common.Log.Debug("Font does not have rune metrics for %v - skipping", r)
|
||||
continue
|
||||
}
|
||||
linewidth += metrics.Wx
|
||||
|
@ -7,12 +7,11 @@ package creator
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/unidoc/unidoc/common"
|
||||
"github.com/unidoc/unidoc/pdf/contentstream"
|
||||
"github.com/unidoc/unidoc/pdf/core"
|
||||
"github.com/unidoc/unidoc/pdf/internal/textencoding"
|
||||
"github.com/unidoc/unidoc/pdf/model"
|
||||
)
|
||||
|
||||
@ -210,20 +209,14 @@ func (p *Paragraph) getTextWidth() float64 {
|
||||
w := 0.0
|
||||
|
||||
for _, r := range p.text {
|
||||
glyph, found := p.textFont.Encoder().RuneToGlyph(r)
|
||||
if !found {
|
||||
common.Log.Debug("ERROR: Glyph not found for rune: 0x%04x=%c", r, r)
|
||||
return -1 // FIXME: return error.
|
||||
}
|
||||
|
||||
// Ignore newline for this.. Handles as if all in one line.
|
||||
if glyph == "controlLF" {
|
||||
if r == '\u000A' { // LF
|
||||
continue
|
||||
}
|
||||
|
||||
metrics, found := p.textFont.GetGlyphCharMetrics(glyph)
|
||||
metrics, found := p.textFont.GetRuneMetrics(r)
|
||||
if !found {
|
||||
common.Log.Debug("ERROR: Glyph char metrics not found! %q (rune 0x%04x=%c)", glyph, r, r)
|
||||
common.Log.Debug("ERROR: Rune char metrics not found! (rune 0x%04x=%c)", r, r)
|
||||
return -1 // FIXME: return error.
|
||||
}
|
||||
w += p.fontSize * metrics.Wx
|
||||
@ -236,20 +229,14 @@ func (p *Paragraph) getTextWidth() float64 {
|
||||
func (p *Paragraph) getTextLineWidth(line string) float64 {
|
||||
var width float64
|
||||
for _, r := range line {
|
||||
glyph, found := p.textFont.Encoder().RuneToGlyph(r)
|
||||
if !found {
|
||||
common.Log.Debug("ERROR: Glyph not found for rune: 0x%04x=%c", r, r)
|
||||
return -1 // FIXME: return error.
|
||||
}
|
||||
|
||||
// Ignore newline for this.. Handles as if all in one line.
|
||||
if glyph == "controlLF" {
|
||||
if r == '\u000A' { // LF
|
||||
continue
|
||||
}
|
||||
|
||||
metrics, found := p.textFont.GetGlyphCharMetrics(glyph)
|
||||
metrics, found := p.textFont.GetRuneMetrics(r)
|
||||
if !found {
|
||||
common.Log.Debug("ERROR: Glyph char metrics not found! %q (rune 0x%04x=%c)", glyph, r, r)
|
||||
common.Log.Debug("ERROR: Rune char metrics not found! (rune 0x%04x=%c)", r, r)
|
||||
return -1 // FIXME: return error.
|
||||
}
|
||||
|
||||
@ -289,33 +276,23 @@ func (p *Paragraph) wrapText() error {
|
||||
p.textLines = nil
|
||||
|
||||
runes := []rune(p.text)
|
||||
var (
|
||||
glyphs []textencoding.GlyphName
|
||||
widths []float64
|
||||
)
|
||||
|
||||
for _, val := range runes {
|
||||
glyph, found := p.textFont.Encoder().RuneToGlyph(val)
|
||||
if !found {
|
||||
common.Log.Debug("ERROR: Glyph not found for rune: %c", val)
|
||||
return errors.New("glyph not found for rune")
|
||||
}
|
||||
var widths []float64
|
||||
|
||||
for _, r := range runes {
|
||||
// Newline wrapping.
|
||||
if glyph == "controlLF" {
|
||||
if r == '\u000A' { // LF
|
||||
// Moves to next line.
|
||||
p.textLines = append(p.textLines, string(line))
|
||||
line = nil
|
||||
lineWidth = 0
|
||||
widths = nil
|
||||
glyphs = nil
|
||||
continue
|
||||
}
|
||||
|
||||
metrics, found := p.textFont.GetGlyphCharMetrics(glyph)
|
||||
metrics, found := p.textFont.GetRuneMetrics(r)
|
||||
if !found {
|
||||
common.Log.Debug("ERROR: Glyph char metrics not found! %q rune=0x%04x=%c font=%s %#q",
|
||||
glyph, val, val, p.textFont.BaseFont(), p.textFont.Subtype())
|
||||
common.Log.Debug("ERROR: Rune char metrics not found! rune=0x%04x=%c font=%s %#q",
|
||||
r, r, p.textFont.BaseFont(), p.textFont.Subtype())
|
||||
common.Log.Trace("Font: %#v", p.textFont)
|
||||
common.Log.Trace("Encoder: %#v", p.textFont.Encoder())
|
||||
return errors.New("glyph char metrics missing")
|
||||
@ -326,8 +303,8 @@ func (p *Paragraph) wrapText() error {
|
||||
// Goes out of bounds: Wrap.
|
||||
// Breaks on the character.
|
||||
idx := -1
|
||||
for i := len(glyphs) - 1; i >= 0; i-- {
|
||||
if glyphs[i] == "space" { // TODO: What about other space glyphs like controlHT?
|
||||
for i := len(line) - 1; i >= 0; i-- {
|
||||
if line[i] == ' ' { // TODO: What about other space glyphs like controlHT?
|
||||
idx = i
|
||||
break
|
||||
}
|
||||
@ -337,22 +314,19 @@ func (p *Paragraph) wrapText() error {
|
||||
p.textLines = append(p.textLines, string(line[0:idx+1]))
|
||||
|
||||
// Remainder of line.
|
||||
line = append(line[idx+1:], val)
|
||||
glyphs = append(glyphs[idx+1:], glyph)
|
||||
line = append(line[idx+1:], r)
|
||||
widths = append(widths[idx+1:], w)
|
||||
lineWidth = sum(widths)
|
||||
|
||||
} else {
|
||||
p.textLines = append(p.textLines, string(line))
|
||||
line = []rune{val}
|
||||
glyphs = []textencoding.GlyphName{glyph}
|
||||
line = []rune{r}
|
||||
widths = []float64{w}
|
||||
lineWidth = w
|
||||
}
|
||||
} else {
|
||||
line = append(line, val)
|
||||
line = append(line, r)
|
||||
lineWidth += w
|
||||
glyphs = append(glyphs, glyph)
|
||||
widths = append(widths, w)
|
||||
}
|
||||
}
|
||||
@ -439,10 +413,10 @@ func (p *Paragraph) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext,
|
||||
func drawParagraphOnBlock(blk *Block, p *Paragraph, ctx DrawContext) (DrawContext, error) {
|
||||
// Find a free name for the font.
|
||||
num := 1
|
||||
fontName := core.PdfObjectName(fmt.Sprintf("Font%d", num))
|
||||
fontName := core.PdfObjectName("Font" + strconv.Itoa(num))
|
||||
for blk.resources.HasFontByName(fontName) {
|
||||
num++
|
||||
fontName = core.PdfObjectName(fmt.Sprintf("Font%d", num))
|
||||
fontName = core.PdfObjectName("Font" + strconv.Itoa(num))
|
||||
}
|
||||
|
||||
// Add to the Page resources.
|
||||
@ -482,22 +456,17 @@ func drawParagraphOnBlock(blk *Block, p *Paragraph, ctx DrawContext) (DrawContex
|
||||
w := 0.0
|
||||
spaces := 0
|
||||
for i, r := range runes {
|
||||
glyph, found := p.textFont.Encoder().RuneToGlyph(r)
|
||||
if !found {
|
||||
common.Log.Debug("Rune 0x%x not supported by text encoder", r)
|
||||
return ctx, errors.New("unsupported rune in text encoding")
|
||||
}
|
||||
if glyph == "space" {
|
||||
if r == ' ' {
|
||||
spaces++
|
||||
continue
|
||||
}
|
||||
if glyph == "controlLF" {
|
||||
if r == '\u000A' { // LF
|
||||
continue
|
||||
}
|
||||
metrics, found := p.textFont.GetGlyphCharMetrics(glyph)
|
||||
metrics, found := p.textFont.GetRuneMetrics(r)
|
||||
if !found {
|
||||
common.Log.Debug("Unsupported glyph %q i=%d rune=0x%04x=%c in font %s %s",
|
||||
glyph, i, r, r,
|
||||
common.Log.Debug("Unsupported rune i=%d rune=0x%04x=%c in font %s %s",
|
||||
i, r, r,
|
||||
p.textFont.BaseFont(), p.textFont.Subtype())
|
||||
return ctx, errors.New("unsupported text glyph")
|
||||
}
|
||||
@ -507,7 +476,7 @@ func drawParagraphOnBlock(blk *Block, p *Paragraph, ctx DrawContext) (DrawContex
|
||||
|
||||
var objs []core.PdfObject
|
||||
|
||||
spaceMetrics, found := p.textFont.GetGlyphCharMetrics("space")
|
||||
spaceMetrics, found := p.textFont.GetRuneMetrics(' ')
|
||||
if !found {
|
||||
return ctx, errors.New("the font does not have a space glyph")
|
||||
}
|
||||
|
@ -11,8 +11,6 @@ import (
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/unidoc/unidoc/pdf/internal/textencoding"
|
||||
|
||||
"github.com/unidoc/unidoc/common"
|
||||
"github.com/unidoc/unidoc/pdf/contentstream"
|
||||
"github.com/unidoc/unidoc/pdf/core"
|
||||
@ -233,23 +231,15 @@ func (p *StyledParagraph) getTextWidth() float64 {
|
||||
for _, chunk := range p.chunks {
|
||||
style := &chunk.Style
|
||||
|
||||
for _, rune := range chunk.Text {
|
||||
glyph, found := style.Font.Encoder().RuneToGlyph(rune)
|
||||
if !found {
|
||||
common.Log.Debug("Error! Glyph not found for rune: %s\n", rune)
|
||||
|
||||
// FIXME: return error.
|
||||
return -1
|
||||
}
|
||||
|
||||
for _, r := range chunk.Text {
|
||||
// Ignore newline for this.. Handles as if all in one line.
|
||||
if glyph == "controlLF" {
|
||||
if r == '\u000A' { // LF
|
||||
continue
|
||||
}
|
||||
|
||||
metrics, found := style.Font.GetGlyphCharMetrics(glyph)
|
||||
metrics, found := style.Font.GetRuneMetrics(r)
|
||||
if !found {
|
||||
common.Log.Debug("Glyph char metrics not found! %s\n", glyph)
|
||||
common.Log.Debug("Rune char metrics not found! %v\n", r)
|
||||
|
||||
// FIXME: return error.
|
||||
return -1
|
||||
@ -269,22 +259,14 @@ func (p *StyledParagraph) getTextLineWidth(line []*TextChunk) float64 {
|
||||
style := &chunk.Style
|
||||
|
||||
for _, r := range chunk.Text {
|
||||
glyph, found := style.Font.Encoder().RuneToGlyph(r)
|
||||
if !found {
|
||||
common.Log.Debug("Error! Glyph not found for rune: %s\n", r)
|
||||
|
||||
// FIXME: return error.
|
||||
return -1
|
||||
}
|
||||
|
||||
// Ignore newline for this.. Handles as if all in one line.
|
||||
if glyph == "controlLF" {
|
||||
if r == '\u000A' { // LF
|
||||
continue
|
||||
}
|
||||
|
||||
metrics, found := style.Font.GetGlyphCharMetrics(glyph)
|
||||
metrics, found := style.Font.GetRuneMetrics(r)
|
||||
if !found {
|
||||
common.Log.Debug("Glyph char metrics not found! %s\n", glyph)
|
||||
common.Log.Debug("Rune char metrics not found! %v\n", r)
|
||||
|
||||
// FIXME: return error.
|
||||
return -1
|
||||
@ -353,21 +335,14 @@ func (p *StyledParagraph) wrapText() error {
|
||||
style := chunk.Style
|
||||
annotation := chunk.annotation
|
||||
|
||||
var part []rune
|
||||
var glyphs []textencoding.GlyphName
|
||||
var widths []float64
|
||||
var (
|
||||
part []rune
|
||||
widths []float64
|
||||
)
|
||||
|
||||
for _, r := range chunk.Text {
|
||||
glyph, found := style.Font.Encoder().RuneToGlyph(r)
|
||||
if !found {
|
||||
common.Log.Debug("Error! Glyph not found for rune: %v\n", r)
|
||||
|
||||
// FIXME: return error.
|
||||
return errors.New("glyph not found for rune")
|
||||
}
|
||||
|
||||
// newline wrapping.
|
||||
if glyph == "controlLF" {
|
||||
if r == '\u000A' { // LF
|
||||
// moves to next line.
|
||||
line = append(line, &TextChunk{
|
||||
Text: strings.TrimRightFunc(string(part), unicode.IsSpace),
|
||||
@ -380,13 +355,12 @@ func (p *StyledParagraph) wrapText() error {
|
||||
lineWidth = 0
|
||||
part = nil
|
||||
widths = nil
|
||||
glyphs = nil
|
||||
continue
|
||||
}
|
||||
|
||||
metrics, found := style.Font.GetGlyphCharMetrics(glyph)
|
||||
metrics, found := style.Font.GetRuneMetrics(r)
|
||||
if !found {
|
||||
common.Log.Debug("Glyph char metrics not found! %s\n", glyph)
|
||||
common.Log.Debug("Rune char metrics not found! %v\n", r)
|
||||
return errors.New("glyph char metrics missing")
|
||||
}
|
||||
|
||||
@ -397,8 +371,8 @@ func (p *StyledParagraph) wrapText() error {
|
||||
// TODO: when goes outside: back up to next space,
|
||||
// otherwise break on the character.
|
||||
idx := -1
|
||||
for j := len(glyphs) - 1; j >= 0; j-- {
|
||||
if glyphs[j] == "space" {
|
||||
for j := len(part) - 1; j >= 0; j-- {
|
||||
if part[j] == ' ' {
|
||||
idx = j
|
||||
break
|
||||
}
|
||||
@ -410,8 +384,6 @@ func (p *StyledParagraph) wrapText() error {
|
||||
|
||||
part = part[idx+1:]
|
||||
part = append(part, r)
|
||||
glyphs = glyphs[idx+1:]
|
||||
glyphs = append(glyphs, glyph)
|
||||
widths = widths[idx+1:]
|
||||
widths = append(widths, w)
|
||||
|
||||
@ -422,7 +394,6 @@ func (p *StyledParagraph) wrapText() error {
|
||||
} else {
|
||||
lineWidth = w
|
||||
part = []rune{r}
|
||||
glyphs = []textencoding.GlyphName{glyph}
|
||||
widths = []float64{w}
|
||||
}
|
||||
|
||||
@ -436,7 +407,6 @@ func (p *StyledParagraph) wrapText() error {
|
||||
} else {
|
||||
lineWidth += w
|
||||
part = append(part, r)
|
||||
glyphs = append(glyphs, glyph)
|
||||
widths = append(widths, w)
|
||||
}
|
||||
}
|
||||
@ -592,10 +562,12 @@ func drawStyledParagraphOnBlock(blk *Block, p *StyledParagraph, ctx DrawContext)
|
||||
isLastLine := idx == len(p.lines)-1
|
||||
|
||||
// Get width of the line (excluding spaces).
|
||||
var width float64
|
||||
var height float64
|
||||
var spaceWidth float64
|
||||
var spaces uint
|
||||
var (
|
||||
width float64
|
||||
height float64
|
||||
spaceWidth float64
|
||||
spaces uint
|
||||
)
|
||||
|
||||
var chunkWidths []float64
|
||||
for _, chunk := range line {
|
||||
@ -605,7 +577,7 @@ func drawStyledParagraphOnBlock(blk *Block, p *StyledParagraph, ctx DrawContext)
|
||||
height = style.FontSize
|
||||
}
|
||||
|
||||
spaceMetrics, found := style.Font.GetGlyphCharMetrics("space")
|
||||
spaceMetrics, found := style.Font.GetRuneMetrics(' ')
|
||||
if !found {
|
||||
return ctx, errors.New("the font does not have a space glyph")
|
||||
}
|
||||
@ -613,23 +585,17 @@ func drawStyledParagraphOnBlock(blk *Block, p *StyledParagraph, ctx DrawContext)
|
||||
var chunkSpaces uint
|
||||
var chunkWidth float64
|
||||
for _, r := range chunk.Text {
|
||||
glyph, found := style.Font.Encoder().RuneToGlyph(r)
|
||||
if !found {
|
||||
common.Log.Debug("Rune 0x%x not supported by text encoder", r)
|
||||
return ctx, errors.New("unsupported rune in text encoding")
|
||||
}
|
||||
|
||||
if glyph == "space" {
|
||||
if r == ' ' {
|
||||
chunkSpaces++
|
||||
continue
|
||||
}
|
||||
if glyph == "controlLF" {
|
||||
if r == '\u000A' { // LF
|
||||
continue
|
||||
}
|
||||
|
||||
metrics, found := style.Font.GetGlyphCharMetrics(glyph)
|
||||
metrics, found := style.Font.GetRuneMetrics(r)
|
||||
if !found {
|
||||
common.Log.Debug("Unsupported glyph %s in font\n", glyph)
|
||||
common.Log.Debug("Unsupported rune %v in font\n", r)
|
||||
return ctx, errors.New("unsupported text glyph")
|
||||
}
|
||||
|
||||
@ -684,7 +650,7 @@ func drawStyledParagraphOnBlock(blk *Block, p *StyledParagraph, ctx DrawContext)
|
||||
fontSize := defaultFontSize
|
||||
|
||||
if p.alignment != TextAlignmentJustify || isLastLine {
|
||||
spaceMetrics, found := style.Font.GetGlyphCharMetrics("space")
|
||||
spaceMetrics, found := style.Font.GetRuneMetrics(' ')
|
||||
if !found {
|
||||
return ctx, errors.New("the font does not have a space glyph")
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ func (tl *TOCLine) prepareParagraph(sp *StyledParagraph, ctx DrawContext) {
|
||||
// Push page numbers to the end of the line.
|
||||
availWidth = availWidth - float64(sepCount)*sepWidth
|
||||
if availWidth > 500 {
|
||||
spaceMetrics, found := sepStyle.Font.GetGlyphCharMetrics("space")
|
||||
spaceMetrics, found := sepStyle.Font.GetRuneMetrics(' ')
|
||||
if found && availWidth > spaceMetrics.Wx {
|
||||
spaces := int(availWidth / spaceMetrics.Wx)
|
||||
if spaces > 0 {
|
||||
|
@ -482,24 +482,24 @@ func (font *PdfFont) Encoder() textencoding.TextEncoder {
|
||||
return t.Encoder()
|
||||
}
|
||||
|
||||
// GetGlyphCharMetrics returns the char metrics for glyph name `glyph`.
|
||||
// GetRuneMetrics returns the char metrics for a rune.
|
||||
// TODO(peterwilliams97) There is nothing callers can do if no CharMetrics are found so we might as
|
||||
// well give them 0 width. There is no need for the bool return.
|
||||
func (font *PdfFont) GetGlyphCharMetrics(glyph textencoding.GlyphName) (fonts.CharMetrics, bool) {
|
||||
func (font *PdfFont) GetRuneMetrics(r rune) (fonts.CharMetrics, bool) {
|
||||
t := font.actualFont()
|
||||
if t == nil {
|
||||
common.Log.Debug("ERROR: GetGlyphCharMetrics Not implemented for font type=%#T", font.context)
|
||||
return fonts.CharMetrics{GlyphName: glyph}, false
|
||||
return fonts.CharMetrics{}, false
|
||||
}
|
||||
if m, ok := t.GetGlyphCharMetrics(glyph); ok {
|
||||
if m, ok := t.GetRuneMetrics(r); ok {
|
||||
return m, true
|
||||
}
|
||||
if descriptor, err := font.GetFontDescriptor(); err == nil && descriptor != nil {
|
||||
return fonts.CharMetrics{GlyphName: glyph, Wx: descriptor.missingWidth}, true
|
||||
if desc, err := font.GetFontDescriptor(); err == nil && desc != nil {
|
||||
return fonts.CharMetrics{Wx: desc.missingWidth}, true
|
||||
}
|
||||
|
||||
common.Log.Debug("GetGlyphCharMetrics: No metrics for font=%s", font)
|
||||
return fonts.CharMetrics{GlyphName: glyph}, false
|
||||
return fonts.CharMetrics{}, false
|
||||
}
|
||||
|
||||
// GetCharMetrics returns the char metrics for character code `code`.
|
||||
@ -558,17 +558,11 @@ func (font *PdfFont) GetRuneCharMetrics(r rune) (fonts.CharMetrics, bool) {
|
||||
|
||||
encoder := font.Encoder()
|
||||
if encoder != nil {
|
||||
|
||||
glyph, found := encoder.RuneToGlyph(r)
|
||||
if !found {
|
||||
common.Log.Debug("Error! Glyph not found for rune=%s %s", r, font.String())
|
||||
} else {
|
||||
m, ok := font.GetGlyphCharMetrics(glyph)
|
||||
if ok {
|
||||
return m, true
|
||||
}
|
||||
m, ok := font.context.GetRuneMetrics(r)
|
||||
if ok {
|
||||
return m, true
|
||||
}
|
||||
common.Log.Debug("ERROR: Metrics not found for rune=%+v glyph=%#q %s", r, glyph, font)
|
||||
common.Log.Debug("ERROR: Metrics not found for rune=%+v %s", r, font)
|
||||
}
|
||||
if descriptor, err := font.GetFontDescriptor(); err == nil && descriptor != nil {
|
||||
return fonts.CharMetrics{Wx: descriptor.missingWidth}, true
|
||||
|
@ -120,14 +120,14 @@ func (font *pdfFontType0) getFontDescriptor() *PdfFontDescriptor {
|
||||
return font.fontDescriptor
|
||||
}
|
||||
|
||||
// GetGlyphCharMetrics returns the character metrics for the specified glyph. A bool flag is
|
||||
// returned to indicate whether or not the entry was found in the glyph to charcode mapping.
|
||||
func (font pdfFontType0) GetGlyphCharMetrics(glyph textencoding.GlyphName) (fonts.CharMetrics, bool) {
|
||||
// GetRuneMetrics returns the character metrics for the specified rune.
|
||||
// A bool flag is returned to indicate whether or not the entry was found.
|
||||
func (font pdfFontType0) GetRuneMetrics(r rune) (fonts.CharMetrics, bool) {
|
||||
if font.DescendantFont == nil {
|
||||
common.Log.Debug("ERROR: No descendant. font=%s", font)
|
||||
return fonts.CharMetrics{}, false
|
||||
}
|
||||
return font.DescendantFont.GetGlyphCharMetrics(glyph)
|
||||
return font.DescendantFont.GetRuneMetrics(r)
|
||||
}
|
||||
|
||||
// GetCharMetrics returns the char metrics for character code `code`.
|
||||
@ -238,9 +238,9 @@ func (font pdfCIDFontType0) Encoder() textencoding.TextEncoder {
|
||||
return font.encoder
|
||||
}
|
||||
|
||||
// GetGlyphCharMetrics returns the character metrics for the specified glyph. A bool flag is
|
||||
// returned to indicate whether or not the entry was found in the glyph to charcode mapping.
|
||||
func (font pdfCIDFontType0) GetGlyphCharMetrics(glyph textencoding.GlyphName) (fonts.CharMetrics, bool) {
|
||||
// GetRuneMetrics returns the character metrics for the specified rune.
|
||||
// A bool flag is returned to indicate whether or not the entry was found.
|
||||
func (font pdfCIDFontType0) GetRuneMetrics(r rune) (fonts.CharMetrics, bool) {
|
||||
return fonts.CharMetrics{}, true
|
||||
}
|
||||
|
||||
@ -300,11 +300,6 @@ type pdfCIDFontType2 struct {
|
||||
// TODO(dennwc): both are used only in GetGlyphCharMetrics
|
||||
// we can precompute metrics and drop both
|
||||
runeToWidthMap map[rune]int
|
||||
|
||||
// Cache for glyph to metrics.
|
||||
glyphToMetricsCache map[textencoding.GlyphName]fonts.CharMetrics
|
||||
|
||||
ttfParser *fonts.TtfType
|
||||
}
|
||||
|
||||
// pdfCIDFontType2FromSkeleton returns a pdfCIDFontType2 with its common fields initalized.
|
||||
@ -328,45 +323,18 @@ func (font pdfCIDFontType2) Encoder() textencoding.TextEncoder {
|
||||
return font.encoder
|
||||
}
|
||||
|
||||
// GetGlyphCharMetrics returns the character metrics for the specified glyph. A bool flag is
|
||||
// returned to indicate whether or not the entry was found in the glyph to charcode mapping.
|
||||
func (font pdfCIDFontType2) GetGlyphCharMetrics(glyph textencoding.GlyphName) (fonts.CharMetrics, bool) {
|
||||
// Return cached value if cached.
|
||||
if font.glyphToMetricsCache == nil {
|
||||
font.glyphToMetricsCache = make(map[textencoding.GlyphName]fonts.CharMetrics)
|
||||
}
|
||||
if metrics, cached := font.glyphToMetricsCache[glyph]; cached {
|
||||
return metrics, true
|
||||
}
|
||||
metrics := fonts.CharMetrics{}
|
||||
|
||||
if font.ttfParser == nil {
|
||||
return metrics, false
|
||||
}
|
||||
// TODO(dennwc): why not use font.encoder? however it's not set in the constructor
|
||||
enc := font.ttfParser.NewEncoder()
|
||||
|
||||
// Convert the glyph to character code.
|
||||
r, found := enc.GlyphToRune(glyph)
|
||||
if !found {
|
||||
common.Log.Debug("Unable to convert glyph %q to charcode (identity)", glyph)
|
||||
return metrics, false
|
||||
}
|
||||
|
||||
// GetRuneMetrics returns the character metrics for the specified rune.
|
||||
// A bool flag is returned to indicate whether or not the entry was found.
|
||||
func (font pdfCIDFontType2) GetRuneMetrics(r rune) (fonts.CharMetrics, bool) {
|
||||
w, found := font.runeToWidthMap[r]
|
||||
if !found {
|
||||
dw, ok := core.GetInt(font.DW)
|
||||
if !ok {
|
||||
return metrics, false
|
||||
return fonts.CharMetrics{}, false
|
||||
}
|
||||
w = int(*dw)
|
||||
}
|
||||
metrics.GlyphName = glyph
|
||||
metrics.Wx = float64(w)
|
||||
|
||||
font.glyphToMetricsCache[glyph] = metrics
|
||||
|
||||
return metrics, true
|
||||
return fonts.CharMetrics{Wx: float64(w)}, true
|
||||
}
|
||||
|
||||
// GetCharMetrics returns the char metrics for character code `code`.
|
||||
@ -511,7 +479,6 @@ func NewCompositePdfFontFromTTFFile(filePath string) (*PdfFont, error) {
|
||||
fontCommon: fontCommon{
|
||||
subtype: "CIDFontType2",
|
||||
},
|
||||
ttfParser: &ttf,
|
||||
|
||||
// Use identity character id (CID) to glyph id (GID) mapping.
|
||||
// Code below relies on the fact that identity mapping is used.
|
||||
|
@ -112,35 +112,31 @@ func (font *pdfFontSimple) SetEncoder(encoder textencoding.TextEncoder) {
|
||||
font.encoder = simple
|
||||
}
|
||||
|
||||
// GetGlyphCharMetrics returns the character metrics for the specified glyph. A bool flag is
|
||||
// returned to indicate whether or not the entry was found in the glyph to charcode mapping.
|
||||
func (font pdfFontSimple) GetGlyphCharMetrics(glyph textencoding.GlyphName) (fonts.CharMetrics, bool) {
|
||||
if font.fontMetrics != nil {
|
||||
metrics, has := font.fontMetrics[glyph]
|
||||
if has {
|
||||
return metrics, true
|
||||
}
|
||||
}
|
||||
|
||||
metrics := fonts.CharMetrics{GlyphName: glyph}
|
||||
|
||||
// GetRuneMetrics returns the character metrics for the rune.
|
||||
// A bool flag is returned to indicate whether or not the entry was found.
|
||||
func (font pdfFontSimple) GetRuneMetrics(r rune) (fonts.CharMetrics, bool) {
|
||||
encoder := font.Encoder()
|
||||
|
||||
if encoder == nil {
|
||||
common.Log.Debug("No encoder for fonts=%s", font)
|
||||
return metrics, false
|
||||
return fonts.CharMetrics{}, false
|
||||
}
|
||||
code, found := encoder.GlyphToCharcode(glyph)
|
||||
|
||||
code, found := encoder.RuneToCharcode(r)
|
||||
if !found {
|
||||
if glyph != "space" {
|
||||
common.Log.Trace("No charcode for glyph=%q font=%s", glyph, font)
|
||||
if r != ' ' {
|
||||
common.Log.Trace("No charcode for rune=%v font=%s", r, font)
|
||||
}
|
||||
return fonts.CharMetrics{}, false
|
||||
}
|
||||
if font.fontMetrics != nil {
|
||||
if glyph, found := encoder.CharcodeToGlyph(code); found {
|
||||
metrics, has := font.fontMetrics[glyph]
|
||||
if has {
|
||||
return metrics, true
|
||||
}
|
||||
}
|
||||
return fonts.CharMetrics{GlyphName: glyph}, false
|
||||
}
|
||||
|
||||
metrics, ok := font.GetCharMetrics(code)
|
||||
metrics.GlyphName = glyph
|
||||
return metrics, ok
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ func TestNewStandard14Font(t *testing.T) {
|
||||
"Courier": {
|
||||
subtype: "Type1",
|
||||
basefont: "Courier",
|
||||
CharMetrics: fonts.CharMetrics{Wx: 600, Wy: 0}},
|
||||
CharMetrics: fonts.CharMetrics{Wx: 600}},
|
||||
}
|
||||
|
||||
for in, expect := range tests {
|
||||
@ -132,7 +132,7 @@ func TestNewStandard14Font(t *testing.T) {
|
||||
in, expect.basefont, expect.subtype, font.BaseFont(), font.Subtype())
|
||||
}
|
||||
|
||||
metrics, ok := font.GetGlyphCharMetrics("space")
|
||||
metrics, ok := font.GetRuneMetrics(' ')
|
||||
if !ok {
|
||||
t.Fatalf("%s: failed to get glyph metric", in)
|
||||
}
|
||||
@ -226,14 +226,9 @@ func TestLoadStandardFontEncodings(t *testing.T) {
|
||||
|
||||
str := "Aabcdefg0123456790*"
|
||||
for _, r := range str {
|
||||
glyph, has := font.Encoder().RuneToGlyph(r)
|
||||
_, has := font.GetRuneMetrics(r)
|
||||
if !has {
|
||||
t.Fatalf("Encoder does not have '%c'", r)
|
||||
}
|
||||
|
||||
_, has = font.GetGlyphCharMetrics(glyph)
|
||||
if !has {
|
||||
t.Fatalf("Loaded simple font not having glyph char metrics for %s", glyph)
|
||||
t.Fatalf("Loaded simple font not having glyph char metrics for %v", r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,17 +16,16 @@ import (
|
||||
// mapped to and from glyphs. Each glyph has metrics.
|
||||
type Font interface {
|
||||
Encoder() textencoding.TextEncoder
|
||||
GetGlyphCharMetrics(glyph textencoding.GlyphName) (CharMetrics, bool)
|
||||
GetRuneMetrics(r rune) (CharMetrics, bool)
|
||||
ToPdfObject() core.PdfObject
|
||||
}
|
||||
|
||||
// CharMetrics represents width and height metrics of a glyph.
|
||||
type CharMetrics struct {
|
||||
GlyphName textencoding.GlyphName
|
||||
Wx float64
|
||||
Wy float64
|
||||
Wx float64
|
||||
Wy float64 // TODO(dennwc): none of code paths sets this to anything except 0
|
||||
}
|
||||
|
||||
func (m CharMetrics) String() string {
|
||||
return fmt.Sprintf("<%q,%.1f,%.1f>", m.GlyphName, m.Wx, m.Wy)
|
||||
return fmt.Sprintf("<%.1f,%.1f>", m.Wx, m.Wy)
|
||||
}
|
||||
|
@ -106,13 +106,13 @@ func (font StdFont) SimpleEncoder() *textencoding.SimpleEncoder {
|
||||
return font.encoder
|
||||
}
|
||||
|
||||
// GetGlyphCharMetrics returns character metrics for a given glyph.
|
||||
func (font StdFont) GetGlyphCharMetrics(glyph GlyphName) (CharMetrics, bool) {
|
||||
metrics, has := font.metrics[glyph]
|
||||
// GetRuneMetrics returns character metrics for a given rune.
|
||||
func (font StdFont) GetRuneMetrics(r rune) (CharMetrics, bool) {
|
||||
glyph, has := font.encoder.RuneToGlyph(r)
|
||||
if !has {
|
||||
return metrics, false
|
||||
return CharMetrics{}, false
|
||||
}
|
||||
|
||||
metrics, has := font.metrics[glyph]
|
||||
return metrics, true
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ func initCourier() {
|
||||
const wx = 600
|
||||
courierCharMetrics = make(map[GlyphName]CharMetrics, len(type1CommonGlyphs))
|
||||
for _, glyph := range type1CommonGlyphs {
|
||||
courierCharMetrics[glyph] = CharMetrics{GlyphName: glyph, Wx: wx}
|
||||
courierCharMetrics[glyph] = CharMetrics{Wx: wx}
|
||||
}
|
||||
// other font variant still have the same metrics
|
||||
courierBoldCharMetrics = courierCharMetrics
|
||||
|
@ -120,8 +120,8 @@ func initHelvetica() {
|
||||
helveticaCharMetrics = make(map[GlyphName]CharMetrics, len(type1CommonGlyphs))
|
||||
helveticaBoldCharMetrics = make(map[GlyphName]CharMetrics, len(type1CommonGlyphs))
|
||||
for i, glyph := range type1CommonGlyphs {
|
||||
helveticaCharMetrics[glyph] = CharMetrics{GlyphName: glyph, Wx: float64(helveticaWx[i])}
|
||||
helveticaBoldCharMetrics[glyph] = CharMetrics{GlyphName: glyph, Wx: float64(helveticaBoldWx[i])}
|
||||
helveticaCharMetrics[glyph] = CharMetrics{Wx: float64(helveticaWx[i])}
|
||||
helveticaBoldCharMetrics[glyph] = CharMetrics{Wx: float64(helveticaBoldWx[i])}
|
||||
}
|
||||
helveticaObliqueCharMetrics = helveticaCharMetrics
|
||||
helveticaBoldObliqueCharMetrics = helveticaBoldCharMetrics
|
||||
|
@ -71,401 +71,401 @@ func NewFontZapfDingbats() StdFont {
|
||||
// symbolCharMetrics are the font metrics loaded from afms/Symbol.afm.
|
||||
// See afms/MustRead.html for license information.
|
||||
var symbolCharMetrics = map[GlyphName]CharMetrics{
|
||||
"Alpha": {GlyphName: "Alpha", Wx: 722.000000},
|
||||
"Beta": {GlyphName: "Beta", Wx: 667.000000},
|
||||
"Chi": {GlyphName: "Chi", Wx: 722.000000},
|
||||
"Delta": {GlyphName: "Delta", Wx: 612.000000},
|
||||
"Epsilon": {GlyphName: "Epsilon", Wx: 611.000000},
|
||||
"Eta": {GlyphName: "Eta", Wx: 722.000000},
|
||||
"Euro": {GlyphName: "Euro", Wx: 750.000000},
|
||||
"Gamma": {GlyphName: "Gamma", Wx: 603.000000},
|
||||
"Ifraktur": {GlyphName: "Ifraktur", Wx: 686.000000},
|
||||
"Iota": {GlyphName: "Iota", Wx: 333.000000},
|
||||
"Kappa": {GlyphName: "Kappa", Wx: 722.000000},
|
||||
"Lambda": {GlyphName: "Lambda", Wx: 686.000000},
|
||||
"Mu": {GlyphName: "Mu", Wx: 889.000000},
|
||||
"Nu": {GlyphName: "Nu", Wx: 722.000000},
|
||||
"Omega": {GlyphName: "Omega", Wx: 768.000000},
|
||||
"Omicron": {GlyphName: "Omicron", Wx: 722.000000},
|
||||
"Phi": {GlyphName: "Phi", Wx: 763.000000},
|
||||
"Pi": {GlyphName: "Pi", Wx: 768.000000},
|
||||
"Psi": {GlyphName: "Psi", Wx: 795.000000},
|
||||
"Rfraktur": {GlyphName: "Rfraktur", Wx: 795.000000},
|
||||
"Rho": {GlyphName: "Rho", Wx: 556.000000},
|
||||
"Sigma": {GlyphName: "Sigma", Wx: 592.000000},
|
||||
"Tau": {GlyphName: "Tau", Wx: 611.000000},
|
||||
"Theta": {GlyphName: "Theta", Wx: 741.000000},
|
||||
"Upsilon": {GlyphName: "Upsilon", Wx: 690.000000},
|
||||
"Upsilon1": {GlyphName: "Upsilon1", Wx: 620.000000},
|
||||
"Xi": {GlyphName: "Xi", Wx: 645.000000},
|
||||
"Zeta": {GlyphName: "Zeta", Wx: 611.000000},
|
||||
"aleph": {GlyphName: "aleph", Wx: 823.000000},
|
||||
"alpha": {GlyphName: "alpha", Wx: 631.000000},
|
||||
"ampersand": {GlyphName: "ampersand", Wx: 778.000000},
|
||||
"angle": {GlyphName: "angle", Wx: 768.000000},
|
||||
"angleleft": {GlyphName: "angleleft", Wx: 329.000000},
|
||||
"angleright": {GlyphName: "angleright", Wx: 329.000000},
|
||||
"apple": {GlyphName: "apple", Wx: 790.000000},
|
||||
"approxequal": {GlyphName: "approxequal", Wx: 549.000000},
|
||||
"arrowboth": {GlyphName: "arrowboth", Wx: 1042.000000},
|
||||
"arrowdblboth": {GlyphName: "arrowdblboth", Wx: 1042.000000},
|
||||
"arrowdbldown": {GlyphName: "arrowdbldown", Wx: 603.000000},
|
||||
"arrowdblleft": {GlyphName: "arrowdblleft", Wx: 987.000000},
|
||||
"arrowdblright": {GlyphName: "arrowdblright", Wx: 987.000000},
|
||||
"arrowdblup": {GlyphName: "arrowdblup", Wx: 603.000000},
|
||||
"arrowdown": {GlyphName: "arrowdown", Wx: 603.000000},
|
||||
"arrowhorizex": {GlyphName: "arrowhorizex", Wx: 1000.000000},
|
||||
"arrowleft": {GlyphName: "arrowleft", Wx: 987.000000},
|
||||
"arrowright": {GlyphName: "arrowright", Wx: 987.000000},
|
||||
"arrowup": {GlyphName: "arrowup", Wx: 603.000000},
|
||||
"arrowvertex": {GlyphName: "arrowvertex", Wx: 603.000000},
|
||||
"asteriskmath": {GlyphName: "asteriskmath", Wx: 500.000000},
|
||||
"bar": {GlyphName: "bar", Wx: 200.000000},
|
||||
"beta": {GlyphName: "beta", Wx: 549.000000},
|
||||
"braceex": {GlyphName: "braceex", Wx: 494.000000},
|
||||
"braceleft": {GlyphName: "braceleft", Wx: 480.000000},
|
||||
"braceleftbt": {GlyphName: "braceleftbt", Wx: 494.000000},
|
||||
"braceleftmid": {GlyphName: "braceleftmid", Wx: 494.000000},
|
||||
"bracelefttp": {GlyphName: "bracelefttp", Wx: 494.000000},
|
||||
"braceright": {GlyphName: "braceright", Wx: 480.000000},
|
||||
"bracerightbt": {GlyphName: "bracerightbt", Wx: 494.000000},
|
||||
"bracerightmid": {GlyphName: "bracerightmid", Wx: 494.000000},
|
||||
"bracerighttp": {GlyphName: "bracerighttp", Wx: 494.000000},
|
||||
"bracketleft": {GlyphName: "bracketleft", Wx: 333.000000},
|
||||
"bracketleftbt": {GlyphName: "bracketleftbt", Wx: 384.000000},
|
||||
"bracketleftex": {GlyphName: "bracketleftex", Wx: 384.000000},
|
||||
"bracketlefttp": {GlyphName: "bracketlefttp", Wx: 384.000000},
|
||||
"bracketright": {GlyphName: "bracketright", Wx: 333.000000},
|
||||
"bracketrightbt": {GlyphName: "bracketrightbt", Wx: 384.000000},
|
||||
"bracketrightex": {GlyphName: "bracketrightex", Wx: 384.000000},
|
||||
"bracketrighttp": {GlyphName: "bracketrighttp", Wx: 384.000000},
|
||||
"bullet": {GlyphName: "bullet", Wx: 460.000000},
|
||||
"carriagereturn": {GlyphName: "carriagereturn", Wx: 658.000000},
|
||||
"chi": {GlyphName: "chi", Wx: 549.000000},
|
||||
"circlemultiply": {GlyphName: "circlemultiply", Wx: 768.000000},
|
||||
"circleplus": {GlyphName: "circleplus", Wx: 768.000000},
|
||||
"club": {GlyphName: "club", Wx: 753.000000},
|
||||
"colon": {GlyphName: "colon", Wx: 278.000000},
|
||||
"comma": {GlyphName: "comma", Wx: 250.000000},
|
||||
"congruent": {GlyphName: "congruent", Wx: 549.000000},
|
||||
"copyrightsans": {GlyphName: "copyrightsans", Wx: 790.000000},
|
||||
"copyrightserif": {GlyphName: "copyrightserif", Wx: 790.000000},
|
||||
"degree": {GlyphName: "degree", Wx: 400.000000},
|
||||
"delta": {GlyphName: "delta", Wx: 494.000000},
|
||||
"diamond": {GlyphName: "diamond", Wx: 753.000000},
|
||||
"divide": {GlyphName: "divide", Wx: 549.000000},
|
||||
"dotmath": {GlyphName: "dotmath", Wx: 250.000000},
|
||||
"eight": {GlyphName: "eight", Wx: 500.000000},
|
||||
"element": {GlyphName: "element", Wx: 713.000000},
|
||||
"ellipsis": {GlyphName: "ellipsis", Wx: 1000.000000},
|
||||
"emptyset": {GlyphName: "emptyset", Wx: 823.000000},
|
||||
"epsilon": {GlyphName: "epsilon", Wx: 439.000000},
|
||||
"equal": {GlyphName: "equal", Wx: 549.000000},
|
||||
"equivalence": {GlyphName: "equivalence", Wx: 549.000000},
|
||||
"eta": {GlyphName: "eta", Wx: 603.000000},
|
||||
"exclam": {GlyphName: "exclam", Wx: 333.000000},
|
||||
"existential": {GlyphName: "existential", Wx: 549.000000},
|
||||
"five": {GlyphName: "five", Wx: 500.000000},
|
||||
"florin": {GlyphName: "florin", Wx: 500.000000},
|
||||
"four": {GlyphName: "four", Wx: 500.000000},
|
||||
"fraction": {GlyphName: "fraction", Wx: 167.000000},
|
||||
"gamma": {GlyphName: "gamma", Wx: 411.000000},
|
||||
"gradient": {GlyphName: "gradient", Wx: 713.000000},
|
||||
"greater": {GlyphName: "greater", Wx: 549.000000},
|
||||
"greaterequal": {GlyphName: "greaterequal", Wx: 549.000000},
|
||||
"heart": {GlyphName: "heart", Wx: 753.000000},
|
||||
"infinity": {GlyphName: "infinity", Wx: 713.000000},
|
||||
"integral": {GlyphName: "integral", Wx: 274.000000},
|
||||
"integralbt": {GlyphName: "integralbt", Wx: 686.000000},
|
||||
"integralex": {GlyphName: "integralex", Wx: 686.000000},
|
||||
"integraltp": {GlyphName: "integraltp", Wx: 686.000000},
|
||||
"intersection": {GlyphName: "intersection", Wx: 768.000000},
|
||||
"iota": {GlyphName: "iota", Wx: 329.000000},
|
||||
"kappa": {GlyphName: "kappa", Wx: 549.000000},
|
||||
"lambda": {GlyphName: "lambda", Wx: 549.000000},
|
||||
"less": {GlyphName: "less", Wx: 549.000000},
|
||||
"lessequal": {GlyphName: "lessequal", Wx: 549.000000},
|
||||
"logicaland": {GlyphName: "logicaland", Wx: 603.000000},
|
||||
"logicalnot": {GlyphName: "logicalnot", Wx: 713.000000},
|
||||
"logicalor": {GlyphName: "logicalor", Wx: 603.000000},
|
||||
"lozenge": {GlyphName: "lozenge", Wx: 494.000000},
|
||||
"minus": {GlyphName: "minus", Wx: 549.000000},
|
||||
"minute": {GlyphName: "minute", Wx: 247.000000},
|
||||
"mu": {GlyphName: "mu", Wx: 576.000000},
|
||||
"multiply": {GlyphName: "multiply", Wx: 549.000000},
|
||||
"nine": {GlyphName: "nine", Wx: 500.000000},
|
||||
"notelement": {GlyphName: "notelement", Wx: 713.000000},
|
||||
"notequal": {GlyphName: "notequal", Wx: 549.000000},
|
||||
"notsubset": {GlyphName: "notsubset", Wx: 713.000000},
|
||||
"nu": {GlyphName: "nu", Wx: 521.000000},
|
||||
"numbersign": {GlyphName: "numbersign", Wx: 500.000000},
|
||||
"omega": {GlyphName: "omega", Wx: 686.000000},
|
||||
"omega1": {GlyphName: "omega1", Wx: 713.000000},
|
||||
"omicron": {GlyphName: "omicron", Wx: 549.000000},
|
||||
"one": {GlyphName: "one", Wx: 500.000000},
|
||||
"parenleft": {GlyphName: "parenleft", Wx: 333.000000},
|
||||
"parenleftbt": {GlyphName: "parenleftbt", Wx: 384.000000},
|
||||
"parenleftex": {GlyphName: "parenleftex", Wx: 384.000000},
|
||||
"parenlefttp": {GlyphName: "parenlefttp", Wx: 384.000000},
|
||||
"parenright": {GlyphName: "parenright", Wx: 333.000000},
|
||||
"parenrightbt": {GlyphName: "parenrightbt", Wx: 384.000000},
|
||||
"parenrightex": {GlyphName: "parenrightex", Wx: 384.000000},
|
||||
"parenrighttp": {GlyphName: "parenrighttp", Wx: 384.000000},
|
||||
"partialdiff": {GlyphName: "partialdiff", Wx: 494.000000},
|
||||
"percent": {GlyphName: "percent", Wx: 833.000000},
|
||||
"period": {GlyphName: "period", Wx: 250.000000},
|
||||
"perpendicular": {GlyphName: "perpendicular", Wx: 658.000000},
|
||||
"phi": {GlyphName: "phi", Wx: 521.000000},
|
||||
"phi1": {GlyphName: "phi1", Wx: 603.000000},
|
||||
"pi": {GlyphName: "pi", Wx: 549.000000},
|
||||
"plus": {GlyphName: "plus", Wx: 549.000000},
|
||||
"plusminus": {GlyphName: "plusminus", Wx: 549.000000},
|
||||
"product": {GlyphName: "product", Wx: 823.000000},
|
||||
"propersubset": {GlyphName: "propersubset", Wx: 713.000000},
|
||||
"propersuperset": {GlyphName: "propersuperset", Wx: 713.000000},
|
||||
"proportional": {GlyphName: "proportional", Wx: 713.000000},
|
||||
"psi": {GlyphName: "psi", Wx: 686.000000},
|
||||
"question": {GlyphName: "question", Wx: 444.000000},
|
||||
"radical": {GlyphName: "radical", Wx: 549.000000},
|
||||
"radicalex": {GlyphName: "radicalex", Wx: 500.000000},
|
||||
"reflexsubset": {GlyphName: "reflexsubset", Wx: 713.000000},
|
||||
"reflexsuperset": {GlyphName: "reflexsuperset", Wx: 713.000000},
|
||||
"registersans": {GlyphName: "registersans", Wx: 790.000000},
|
||||
"registerserif": {GlyphName: "registerserif", Wx: 790.000000},
|
||||
"rho": {GlyphName: "rho", Wx: 549.000000},
|
||||
"second": {GlyphName: "second", Wx: 411.000000},
|
||||
"semicolon": {GlyphName: "semicolon", Wx: 278.000000},
|
||||
"seven": {GlyphName: "seven", Wx: 500.000000},
|
||||
"sigma": {GlyphName: "sigma", Wx: 603.000000},
|
||||
"sigma1": {GlyphName: "sigma1", Wx: 439.000000},
|
||||
"similar": {GlyphName: "similar", Wx: 549.000000},
|
||||
"six": {GlyphName: "six", Wx: 500.000000},
|
||||
"slash": {GlyphName: "slash", Wx: 278.000000},
|
||||
"space": {GlyphName: "space", Wx: 250.000000},
|
||||
"spade": {GlyphName: "spade", Wx: 753.000000},
|
||||
"suchthat": {GlyphName: "suchthat", Wx: 439.000000},
|
||||
"summation": {GlyphName: "summation", Wx: 713.000000},
|
||||
"tau": {GlyphName: "tau", Wx: 439.000000},
|
||||
"therefore": {GlyphName: "therefore", Wx: 863.000000},
|
||||
"theta": {GlyphName: "theta", Wx: 521.000000},
|
||||
"theta1": {GlyphName: "theta1", Wx: 631.000000},
|
||||
"three": {GlyphName: "three", Wx: 500.000000},
|
||||
"trademarksans": {GlyphName: "trademarksans", Wx: 786.000000},
|
||||
"trademarkserif": {GlyphName: "trademarkserif", Wx: 890.000000},
|
||||
"two": {GlyphName: "two", Wx: 500.000000},
|
||||
"underscore": {GlyphName: "underscore", Wx: 500.000000},
|
||||
"union": {GlyphName: "union", Wx: 768.000000},
|
||||
"universal": {GlyphName: "universal", Wx: 713.000000},
|
||||
"upsilon": {GlyphName: "upsilon", Wx: 576.000000},
|
||||
"weierstrass": {GlyphName: "weierstrass", Wx: 987.000000},
|
||||
"xi": {GlyphName: "xi", Wx: 493.000000},
|
||||
"zero": {GlyphName: "zero", Wx: 500.000000},
|
||||
"zeta": {GlyphName: "zeta", Wx: 494.000000},
|
||||
"Alpha": {Wx: 722.000000},
|
||||
"Beta": {Wx: 667.000000},
|
||||
"Chi": {Wx: 722.000000},
|
||||
"Delta": {Wx: 612.000000},
|
||||
"Epsilon": {Wx: 611.000000},
|
||||
"Eta": {Wx: 722.000000},
|
||||
"Euro": {Wx: 750.000000},
|
||||
"Gamma": {Wx: 603.000000},
|
||||
"Ifraktur": {Wx: 686.000000},
|
||||
"Iota": {Wx: 333.000000},
|
||||
"Kappa": {Wx: 722.000000},
|
||||
"Lambda": {Wx: 686.000000},
|
||||
"Mu": {Wx: 889.000000},
|
||||
"Nu": {Wx: 722.000000},
|
||||
"Omega": {Wx: 768.000000},
|
||||
"Omicron": {Wx: 722.000000},
|
||||
"Phi": {Wx: 763.000000},
|
||||
"Pi": {Wx: 768.000000},
|
||||
"Psi": {Wx: 795.000000},
|
||||
"Rfraktur": {Wx: 795.000000},
|
||||
"Rho": {Wx: 556.000000},
|
||||
"Sigma": {Wx: 592.000000},
|
||||
"Tau": {Wx: 611.000000},
|
||||
"Theta": {Wx: 741.000000},
|
||||
"Upsilon": {Wx: 690.000000},
|
||||
"Upsilon1": {Wx: 620.000000},
|
||||
"Xi": {Wx: 645.000000},
|
||||
"Zeta": {Wx: 611.000000},
|
||||
"aleph": {Wx: 823.000000},
|
||||
"alpha": {Wx: 631.000000},
|
||||
"ampersand": {Wx: 778.000000},
|
||||
"angle": {Wx: 768.000000},
|
||||
"angleleft": {Wx: 329.000000},
|
||||
"angleright": {Wx: 329.000000},
|
||||
"apple": {Wx: 790.000000},
|
||||
"approxequal": {Wx: 549.000000},
|
||||
"arrowboth": {Wx: 1042.000000},
|
||||
"arrowdblboth": {Wx: 1042.000000},
|
||||
"arrowdbldown": {Wx: 603.000000},
|
||||
"arrowdblleft": {Wx: 987.000000},
|
||||
"arrowdblright": {Wx: 987.000000},
|
||||
"arrowdblup": {Wx: 603.000000},
|
||||
"arrowdown": {Wx: 603.000000},
|
||||
"arrowhorizex": {Wx: 1000.000000},
|
||||
"arrowleft": {Wx: 987.000000},
|
||||
"arrowright": {Wx: 987.000000},
|
||||
"arrowup": {Wx: 603.000000},
|
||||
"arrowvertex": {Wx: 603.000000},
|
||||
"asteriskmath": {Wx: 500.000000},
|
||||
"bar": {Wx: 200.000000},
|
||||
"beta": {Wx: 549.000000},
|
||||
"braceex": {Wx: 494.000000},
|
||||
"braceleft": {Wx: 480.000000},
|
||||
"braceleftbt": {Wx: 494.000000},
|
||||
"braceleftmid": {Wx: 494.000000},
|
||||
"bracelefttp": {Wx: 494.000000},
|
||||
"braceright": {Wx: 480.000000},
|
||||
"bracerightbt": {Wx: 494.000000},
|
||||
"bracerightmid": {Wx: 494.000000},
|
||||
"bracerighttp": {Wx: 494.000000},
|
||||
"bracketleft": {Wx: 333.000000},
|
||||
"bracketleftbt": {Wx: 384.000000},
|
||||
"bracketleftex": {Wx: 384.000000},
|
||||
"bracketlefttp": {Wx: 384.000000},
|
||||
"bracketright": {Wx: 333.000000},
|
||||
"bracketrightbt": {Wx: 384.000000},
|
||||
"bracketrightex": {Wx: 384.000000},
|
||||
"bracketrighttp": {Wx: 384.000000},
|
||||
"bullet": {Wx: 460.000000},
|
||||
"carriagereturn": {Wx: 658.000000},
|
||||
"chi": {Wx: 549.000000},
|
||||
"circlemultiply": {Wx: 768.000000},
|
||||
"circleplus": {Wx: 768.000000},
|
||||
"club": {Wx: 753.000000},
|
||||
"colon": {Wx: 278.000000},
|
||||
"comma": {Wx: 250.000000},
|
||||
"congruent": {Wx: 549.000000},
|
||||
"copyrightsans": {Wx: 790.000000},
|
||||
"copyrightserif": {Wx: 790.000000},
|
||||
"degree": {Wx: 400.000000},
|
||||
"delta": {Wx: 494.000000},
|
||||
"diamond": {Wx: 753.000000},
|
||||
"divide": {Wx: 549.000000},
|
||||
"dotmath": {Wx: 250.000000},
|
||||
"eight": {Wx: 500.000000},
|
||||
"element": {Wx: 713.000000},
|
||||
"ellipsis": {Wx: 1000.000000},
|
||||
"emptyset": {Wx: 823.000000},
|
||||
"epsilon": {Wx: 439.000000},
|
||||
"equal": {Wx: 549.000000},
|
||||
"equivalence": {Wx: 549.000000},
|
||||
"eta": {Wx: 603.000000},
|
||||
"exclam": {Wx: 333.000000},
|
||||
"existential": {Wx: 549.000000},
|
||||
"five": {Wx: 500.000000},
|
||||
"florin": {Wx: 500.000000},
|
||||
"four": {Wx: 500.000000},
|
||||
"fraction": {Wx: 167.000000},
|
||||
"gamma": {Wx: 411.000000},
|
||||
"gradient": {Wx: 713.000000},
|
||||
"greater": {Wx: 549.000000},
|
||||
"greaterequal": {Wx: 549.000000},
|
||||
"heart": {Wx: 753.000000},
|
||||
"infinity": {Wx: 713.000000},
|
||||
"integral": {Wx: 274.000000},
|
||||
"integralbt": {Wx: 686.000000},
|
||||
"integralex": {Wx: 686.000000},
|
||||
"integraltp": {Wx: 686.000000},
|
||||
"intersection": {Wx: 768.000000},
|
||||
"iota": {Wx: 329.000000},
|
||||
"kappa": {Wx: 549.000000},
|
||||
"lambda": {Wx: 549.000000},
|
||||
"less": {Wx: 549.000000},
|
||||
"lessequal": {Wx: 549.000000},
|
||||
"logicaland": {Wx: 603.000000},
|
||||
"logicalnot": {Wx: 713.000000},
|
||||
"logicalor": {Wx: 603.000000},
|
||||
"lozenge": {Wx: 494.000000},
|
||||
"minus": {Wx: 549.000000},
|
||||
"minute": {Wx: 247.000000},
|
||||
"mu": {Wx: 576.000000},
|
||||
"multiply": {Wx: 549.000000},
|
||||
"nine": {Wx: 500.000000},
|
||||
"notelement": {Wx: 713.000000},
|
||||
"notequal": {Wx: 549.000000},
|
||||
"notsubset": {Wx: 713.000000},
|
||||
"nu": {Wx: 521.000000},
|
||||
"numbersign": {Wx: 500.000000},
|
||||
"omega": {Wx: 686.000000},
|
||||
"omega1": {Wx: 713.000000},
|
||||
"omicron": {Wx: 549.000000},
|
||||
"one": {Wx: 500.000000},
|
||||
"parenleft": {Wx: 333.000000},
|
||||
"parenleftbt": {Wx: 384.000000},
|
||||
"parenleftex": {Wx: 384.000000},
|
||||
"parenlefttp": {Wx: 384.000000},
|
||||
"parenright": {Wx: 333.000000},
|
||||
"parenrightbt": {Wx: 384.000000},
|
||||
"parenrightex": {Wx: 384.000000},
|
||||
"parenrighttp": {Wx: 384.000000},
|
||||
"partialdiff": {Wx: 494.000000},
|
||||
"percent": {Wx: 833.000000},
|
||||
"period": {Wx: 250.000000},
|
||||
"perpendicular": {Wx: 658.000000},
|
||||
"phi": {Wx: 521.000000},
|
||||
"phi1": {Wx: 603.000000},
|
||||
"pi": {Wx: 549.000000},
|
||||
"plus": {Wx: 549.000000},
|
||||
"plusminus": {Wx: 549.000000},
|
||||
"product": {Wx: 823.000000},
|
||||
"propersubset": {Wx: 713.000000},
|
||||
"propersuperset": {Wx: 713.000000},
|
||||
"proportional": {Wx: 713.000000},
|
||||
"psi": {Wx: 686.000000},
|
||||
"question": {Wx: 444.000000},
|
||||
"radical": {Wx: 549.000000},
|
||||
"radicalex": {Wx: 500.000000},
|
||||
"reflexsubset": {Wx: 713.000000},
|
||||
"reflexsuperset": {Wx: 713.000000},
|
||||
"registersans": {Wx: 790.000000},
|
||||
"registerserif": {Wx: 790.000000},
|
||||
"rho": {Wx: 549.000000},
|
||||
"second": {Wx: 411.000000},
|
||||
"semicolon": {Wx: 278.000000},
|
||||
"seven": {Wx: 500.000000},
|
||||
"sigma": {Wx: 603.000000},
|
||||
"sigma1": {Wx: 439.000000},
|
||||
"similar": {Wx: 549.000000},
|
||||
"six": {Wx: 500.000000},
|
||||
"slash": {Wx: 278.000000},
|
||||
"space": {Wx: 250.000000},
|
||||
"spade": {Wx: 753.000000},
|
||||
"suchthat": {Wx: 439.000000},
|
||||
"summation": {Wx: 713.000000},
|
||||
"tau": {Wx: 439.000000},
|
||||
"therefore": {Wx: 863.000000},
|
||||
"theta": {Wx: 521.000000},
|
||||
"theta1": {Wx: 631.000000},
|
||||
"three": {Wx: 500.000000},
|
||||
"trademarksans": {Wx: 786.000000},
|
||||
"trademarkserif": {Wx: 890.000000},
|
||||
"two": {Wx: 500.000000},
|
||||
"underscore": {Wx: 500.000000},
|
||||
"union": {Wx: 768.000000},
|
||||
"universal": {Wx: 713.000000},
|
||||
"upsilon": {Wx: 576.000000},
|
||||
"weierstrass": {Wx: 987.000000},
|
||||
"xi": {Wx: 493.000000},
|
||||
"zero": {Wx: 500.000000},
|
||||
"zeta": {Wx: 494.000000},
|
||||
}
|
||||
|
||||
// zapfDingbatsCharMetrics are the font metrics loaded from afms/ZapfDingbats.afm.
|
||||
// See afms/MustRead.html for license information.
|
||||
var zapfDingbatsCharMetrics = map[GlyphName]CharMetrics{
|
||||
"a1": {GlyphName: "a1", Wx: 974.000000},
|
||||
"a10": {GlyphName: "a10", Wx: 692.000000},
|
||||
"a100": {GlyphName: "a100", Wx: 668.000000},
|
||||
"a101": {GlyphName: "a101", Wx: 732.000000},
|
||||
"a102": {GlyphName: "a102", Wx: 544.000000},
|
||||
"a103": {GlyphName: "a103", Wx: 544.000000},
|
||||
"a104": {GlyphName: "a104", Wx: 910.000000},
|
||||
"a105": {GlyphName: "a105", Wx: 911.000000},
|
||||
"a106": {GlyphName: "a106", Wx: 667.000000},
|
||||
"a107": {GlyphName: "a107", Wx: 760.000000},
|
||||
"a108": {GlyphName: "a108", Wx: 760.000000},
|
||||
"a109": {GlyphName: "a109", Wx: 626.000000},
|
||||
"a11": {GlyphName: "a11", Wx: 960.000000},
|
||||
"a110": {GlyphName: "a110", Wx: 694.000000},
|
||||
"a111": {GlyphName: "a111", Wx: 595.000000},
|
||||
"a112": {GlyphName: "a112", Wx: 776.000000},
|
||||
"a117": {GlyphName: "a117", Wx: 690.000000},
|
||||
"a118": {GlyphName: "a118", Wx: 791.000000},
|
||||
"a119": {GlyphName: "a119", Wx: 790.000000},
|
||||
"a12": {GlyphName: "a12", Wx: 939.000000},
|
||||
"a120": {GlyphName: "a120", Wx: 788.000000},
|
||||
"a121": {GlyphName: "a121", Wx: 788.000000},
|
||||
"a122": {GlyphName: "a122", Wx: 788.000000},
|
||||
"a123": {GlyphName: "a123", Wx: 788.000000},
|
||||
"a124": {GlyphName: "a124", Wx: 788.000000},
|
||||
"a125": {GlyphName: "a125", Wx: 788.000000},
|
||||
"a126": {GlyphName: "a126", Wx: 788.000000},
|
||||
"a127": {GlyphName: "a127", Wx: 788.000000},
|
||||
"a128": {GlyphName: "a128", Wx: 788.000000},
|
||||
"a129": {GlyphName: "a129", Wx: 788.000000},
|
||||
"a13": {GlyphName: "a13", Wx: 549.000000},
|
||||
"a130": {GlyphName: "a130", Wx: 788.000000},
|
||||
"a131": {GlyphName: "a131", Wx: 788.000000},
|
||||
"a132": {GlyphName: "a132", Wx: 788.000000},
|
||||
"a133": {GlyphName: "a133", Wx: 788.000000},
|
||||
"a134": {GlyphName: "a134", Wx: 788.000000},
|
||||
"a135": {GlyphName: "a135", Wx: 788.000000},
|
||||
"a136": {GlyphName: "a136", Wx: 788.000000},
|
||||
"a137": {GlyphName: "a137", Wx: 788.000000},
|
||||
"a138": {GlyphName: "a138", Wx: 788.000000},
|
||||
"a139": {GlyphName: "a139", Wx: 788.000000},
|
||||
"a14": {GlyphName: "a14", Wx: 855.000000},
|
||||
"a140": {GlyphName: "a140", Wx: 788.000000},
|
||||
"a141": {GlyphName: "a141", Wx: 788.000000},
|
||||
"a142": {GlyphName: "a142", Wx: 788.000000},
|
||||
"a143": {GlyphName: "a143", Wx: 788.000000},
|
||||
"a144": {GlyphName: "a144", Wx: 788.000000},
|
||||
"a145": {GlyphName: "a145", Wx: 788.000000},
|
||||
"a146": {GlyphName: "a146", Wx: 788.000000},
|
||||
"a147": {GlyphName: "a147", Wx: 788.000000},
|
||||
"a148": {GlyphName: "a148", Wx: 788.000000},
|
||||
"a149": {GlyphName: "a149", Wx: 788.000000},
|
||||
"a15": {GlyphName: "a15", Wx: 911.000000},
|
||||
"a150": {GlyphName: "a150", Wx: 788.000000},
|
||||
"a151": {GlyphName: "a151", Wx: 788.000000},
|
||||
"a152": {GlyphName: "a152", Wx: 788.000000},
|
||||
"a153": {GlyphName: "a153", Wx: 788.000000},
|
||||
"a154": {GlyphName: "a154", Wx: 788.000000},
|
||||
"a155": {GlyphName: "a155", Wx: 788.000000},
|
||||
"a156": {GlyphName: "a156", Wx: 788.000000},
|
||||
"a157": {GlyphName: "a157", Wx: 788.000000},
|
||||
"a158": {GlyphName: "a158", Wx: 788.000000},
|
||||
"a159": {GlyphName: "a159", Wx: 788.000000},
|
||||
"a16": {GlyphName: "a16", Wx: 933.000000},
|
||||
"a160": {GlyphName: "a160", Wx: 894.000000},
|
||||
"a161": {GlyphName: "a161", Wx: 838.000000},
|
||||
"a162": {GlyphName: "a162", Wx: 924.000000},
|
||||
"a163": {GlyphName: "a163", Wx: 1016.000000},
|
||||
"a164": {GlyphName: "a164", Wx: 458.000000},
|
||||
"a165": {GlyphName: "a165", Wx: 924.000000},
|
||||
"a166": {GlyphName: "a166", Wx: 918.000000},
|
||||
"a167": {GlyphName: "a167", Wx: 927.000000},
|
||||
"a168": {GlyphName: "a168", Wx: 928.000000},
|
||||
"a169": {GlyphName: "a169", Wx: 928.000000},
|
||||
"a17": {GlyphName: "a17", Wx: 945.000000},
|
||||
"a170": {GlyphName: "a170", Wx: 834.000000},
|
||||
"a171": {GlyphName: "a171", Wx: 873.000000},
|
||||
"a172": {GlyphName: "a172", Wx: 828.000000},
|
||||
"a173": {GlyphName: "a173", Wx: 924.000000},
|
||||
"a174": {GlyphName: "a174", Wx: 917.000000},
|
||||
"a175": {GlyphName: "a175", Wx: 930.000000},
|
||||
"a176": {GlyphName: "a176", Wx: 931.000000},
|
||||
"a177": {GlyphName: "a177", Wx: 463.000000},
|
||||
"a178": {GlyphName: "a178", Wx: 883.000000},
|
||||
"a179": {GlyphName: "a179", Wx: 836.000000},
|
||||
"a18": {GlyphName: "a18", Wx: 974.000000},
|
||||
"a180": {GlyphName: "a180", Wx: 867.000000},
|
||||
"a181": {GlyphName: "a181", Wx: 696.000000},
|
||||
"a182": {GlyphName: "a182", Wx: 874.000000},
|
||||
"a183": {GlyphName: "a183", Wx: 760.000000},
|
||||
"a184": {GlyphName: "a184", Wx: 946.000000},
|
||||
"a185": {GlyphName: "a185", Wx: 865.000000},
|
||||
"a186": {GlyphName: "a186", Wx: 967.000000},
|
||||
"a187": {GlyphName: "a187", Wx: 831.000000},
|
||||
"a188": {GlyphName: "a188", Wx: 873.000000},
|
||||
"a189": {GlyphName: "a189", Wx: 927.000000},
|
||||
"a19": {GlyphName: "a19", Wx: 755.000000},
|
||||
"a190": {GlyphName: "a190", Wx: 970.000000},
|
||||
"a191": {GlyphName: "a191", Wx: 918.000000},
|
||||
"a192": {GlyphName: "a192", Wx: 748.000000},
|
||||
"a193": {GlyphName: "a193", Wx: 836.000000},
|
||||
"a194": {GlyphName: "a194", Wx: 771.000000},
|
||||
"a195": {GlyphName: "a195", Wx: 888.000000},
|
||||
"a196": {GlyphName: "a196", Wx: 748.000000},
|
||||
"a197": {GlyphName: "a197", Wx: 771.000000},
|
||||
"a198": {GlyphName: "a198", Wx: 888.000000},
|
||||
"a199": {GlyphName: "a199", Wx: 867.000000},
|
||||
"a2": {GlyphName: "a2", Wx: 961.000000},
|
||||
"a20": {GlyphName: "a20", Wx: 846.000000},
|
||||
"a200": {GlyphName: "a200", Wx: 696.000000},
|
||||
"a201": {GlyphName: "a201", Wx: 874.000000},
|
||||
"a202": {GlyphName: "a202", Wx: 974.000000},
|
||||
"a203": {GlyphName: "a203", Wx: 762.000000},
|
||||
"a204": {GlyphName: "a204", Wx: 759.000000},
|
||||
"a205": {GlyphName: "a205", Wx: 509.000000},
|
||||
"a206": {GlyphName: "a206", Wx: 410.000000},
|
||||
"a21": {GlyphName: "a21", Wx: 762.000000},
|
||||
"a22": {GlyphName: "a22", Wx: 761.000000},
|
||||
"a23": {GlyphName: "a23", Wx: 571.000000},
|
||||
"a24": {GlyphName: "a24", Wx: 677.000000},
|
||||
"a25": {GlyphName: "a25", Wx: 763.000000},
|
||||
"a26": {GlyphName: "a26", Wx: 760.000000},
|
||||
"a27": {GlyphName: "a27", Wx: 759.000000},
|
||||
"a28": {GlyphName: "a28", Wx: 754.000000},
|
||||
"a29": {GlyphName: "a29", Wx: 786.000000},
|
||||
"a3": {GlyphName: "a3", Wx: 980.000000},
|
||||
"a30": {GlyphName: "a30", Wx: 788.000000},
|
||||
"a31": {GlyphName: "a31", Wx: 788.000000},
|
||||
"a32": {GlyphName: "a32", Wx: 790.000000},
|
||||
"a33": {GlyphName: "a33", Wx: 793.000000},
|
||||
"a34": {GlyphName: "a34", Wx: 794.000000},
|
||||
"a35": {GlyphName: "a35", Wx: 816.000000},
|
||||
"a36": {GlyphName: "a36", Wx: 823.000000},
|
||||
"a37": {GlyphName: "a37", Wx: 789.000000},
|
||||
"a38": {GlyphName: "a38", Wx: 841.000000},
|
||||
"a39": {GlyphName: "a39", Wx: 823.000000},
|
||||
"a4": {GlyphName: "a4", Wx: 719.000000},
|
||||
"a40": {GlyphName: "a40", Wx: 833.000000},
|
||||
"a41": {GlyphName: "a41", Wx: 816.000000},
|
||||
"a42": {GlyphName: "a42", Wx: 831.000000},
|
||||
"a43": {GlyphName: "a43", Wx: 923.000000},
|
||||
"a44": {GlyphName: "a44", Wx: 744.000000},
|
||||
"a45": {GlyphName: "a45", Wx: 723.000000},
|
||||
"a46": {GlyphName: "a46", Wx: 749.000000},
|
||||
"a47": {GlyphName: "a47", Wx: 790.000000},
|
||||
"a48": {GlyphName: "a48", Wx: 792.000000},
|
||||
"a49": {GlyphName: "a49", Wx: 695.000000},
|
||||
"a5": {GlyphName: "a5", Wx: 789.000000},
|
||||
"a50": {GlyphName: "a50", Wx: 776.000000},
|
||||
"a51": {GlyphName: "a51", Wx: 768.000000},
|
||||
"a52": {GlyphName: "a52", Wx: 792.000000},
|
||||
"a53": {GlyphName: "a53", Wx: 759.000000},
|
||||
"a54": {GlyphName: "a54", Wx: 707.000000},
|
||||
"a55": {GlyphName: "a55", Wx: 708.000000},
|
||||
"a56": {GlyphName: "a56", Wx: 682.000000},
|
||||
"a57": {GlyphName: "a57", Wx: 701.000000},
|
||||
"a58": {GlyphName: "a58", Wx: 826.000000},
|
||||
"a59": {GlyphName: "a59", Wx: 815.000000},
|
||||
"a6": {GlyphName: "a6", Wx: 494.000000},
|
||||
"a60": {GlyphName: "a60", Wx: 789.000000},
|
||||
"a61": {GlyphName: "a61", Wx: 789.000000},
|
||||
"a62": {GlyphName: "a62", Wx: 707.000000},
|
||||
"a63": {GlyphName: "a63", Wx: 687.000000},
|
||||
"a64": {GlyphName: "a64", Wx: 696.000000},
|
||||
"a65": {GlyphName: "a65", Wx: 689.000000},
|
||||
"a66": {GlyphName: "a66", Wx: 786.000000},
|
||||
"a67": {GlyphName: "a67", Wx: 787.000000},
|
||||
"a68": {GlyphName: "a68", Wx: 713.000000},
|
||||
"a69": {GlyphName: "a69", Wx: 791.000000},
|
||||
"a7": {GlyphName: "a7", Wx: 552.000000},
|
||||
"a70": {GlyphName: "a70", Wx: 785.000000},
|
||||
"a71": {GlyphName: "a71", Wx: 791.000000},
|
||||
"a72": {GlyphName: "a72", Wx: 873.000000},
|
||||
"a73": {GlyphName: "a73", Wx: 761.000000},
|
||||
"a74": {GlyphName: "a74", Wx: 762.000000},
|
||||
"a75": {GlyphName: "a75", Wx: 759.000000},
|
||||
"a76": {GlyphName: "a76", Wx: 892.000000},
|
||||
"a77": {GlyphName: "a77", Wx: 892.000000},
|
||||
"a78": {GlyphName: "a78", Wx: 788.000000},
|
||||
"a79": {GlyphName: "a79", Wx: 784.000000},
|
||||
"a8": {GlyphName: "a8", Wx: 537.000000},
|
||||
"a81": {GlyphName: "a81", Wx: 438.000000},
|
||||
"a82": {GlyphName: "a82", Wx: 138.000000},
|
||||
"a83": {GlyphName: "a83", Wx: 277.000000},
|
||||
"a84": {GlyphName: "a84", Wx: 415.000000},
|
||||
"a85": {GlyphName: "a85", Wx: 509.000000},
|
||||
"a86": {GlyphName: "a86", Wx: 410.000000},
|
||||
"a87": {GlyphName: "a87", Wx: 234.000000},
|
||||
"a88": {GlyphName: "a88", Wx: 234.000000},
|
||||
"a89": {GlyphName: "a89", Wx: 390.000000},
|
||||
"a9": {GlyphName: "a9", Wx: 577.000000},
|
||||
"a90": {GlyphName: "a90", Wx: 390.000000},
|
||||
"a91": {GlyphName: "a91", Wx: 276.000000},
|
||||
"a92": {GlyphName: "a92", Wx: 276.000000},
|
||||
"a93": {GlyphName: "a93", Wx: 317.000000},
|
||||
"a94": {GlyphName: "a94", Wx: 317.000000},
|
||||
"a95": {GlyphName: "a95", Wx: 334.000000},
|
||||
"a96": {GlyphName: "a96", Wx: 334.000000},
|
||||
"a97": {GlyphName: "a97", Wx: 392.000000},
|
||||
"a98": {GlyphName: "a98", Wx: 392.000000},
|
||||
"a99": {GlyphName: "a99", Wx: 668.000000},
|
||||
"space": {GlyphName: "space", Wx: 278.000000},
|
||||
"a1": {Wx: 974.000000},
|
||||
"a10": {Wx: 692.000000},
|
||||
"a100": {Wx: 668.000000},
|
||||
"a101": {Wx: 732.000000},
|
||||
"a102": {Wx: 544.000000},
|
||||
"a103": {Wx: 544.000000},
|
||||
"a104": {Wx: 910.000000},
|
||||
"a105": {Wx: 911.000000},
|
||||
"a106": {Wx: 667.000000},
|
||||
"a107": {Wx: 760.000000},
|
||||
"a108": {Wx: 760.000000},
|
||||
"a109": {Wx: 626.000000},
|
||||
"a11": {Wx: 960.000000},
|
||||
"a110": {Wx: 694.000000},
|
||||
"a111": {Wx: 595.000000},
|
||||
"a112": {Wx: 776.000000},
|
||||
"a117": {Wx: 690.000000},
|
||||
"a118": {Wx: 791.000000},
|
||||
"a119": {Wx: 790.000000},
|
||||
"a12": {Wx: 939.000000},
|
||||
"a120": {Wx: 788.000000},
|
||||
"a121": {Wx: 788.000000},
|
||||
"a122": {Wx: 788.000000},
|
||||
"a123": {Wx: 788.000000},
|
||||
"a124": {Wx: 788.000000},
|
||||
"a125": {Wx: 788.000000},
|
||||
"a126": {Wx: 788.000000},
|
||||
"a127": {Wx: 788.000000},
|
||||
"a128": {Wx: 788.000000},
|
||||
"a129": {Wx: 788.000000},
|
||||
"a13": {Wx: 549.000000},
|
||||
"a130": {Wx: 788.000000},
|
||||
"a131": {Wx: 788.000000},
|
||||
"a132": {Wx: 788.000000},
|
||||
"a133": {Wx: 788.000000},
|
||||
"a134": {Wx: 788.000000},
|
||||
"a135": {Wx: 788.000000},
|
||||
"a136": {Wx: 788.000000},
|
||||
"a137": {Wx: 788.000000},
|
||||
"a138": {Wx: 788.000000},
|
||||
"a139": {Wx: 788.000000},
|
||||
"a14": {Wx: 855.000000},
|
||||
"a140": {Wx: 788.000000},
|
||||
"a141": {Wx: 788.000000},
|
||||
"a142": {Wx: 788.000000},
|
||||
"a143": {Wx: 788.000000},
|
||||
"a144": {Wx: 788.000000},
|
||||
"a145": {Wx: 788.000000},
|
||||
"a146": {Wx: 788.000000},
|
||||
"a147": {Wx: 788.000000},
|
||||
"a148": {Wx: 788.000000},
|
||||
"a149": {Wx: 788.000000},
|
||||
"a15": {Wx: 911.000000},
|
||||
"a150": {Wx: 788.000000},
|
||||
"a151": {Wx: 788.000000},
|
||||
"a152": {Wx: 788.000000},
|
||||
"a153": {Wx: 788.000000},
|
||||
"a154": {Wx: 788.000000},
|
||||
"a155": {Wx: 788.000000},
|
||||
"a156": {Wx: 788.000000},
|
||||
"a157": {Wx: 788.000000},
|
||||
"a158": {Wx: 788.000000},
|
||||
"a159": {Wx: 788.000000},
|
||||
"a16": {Wx: 933.000000},
|
||||
"a160": {Wx: 894.000000},
|
||||
"a161": {Wx: 838.000000},
|
||||
"a162": {Wx: 924.000000},
|
||||
"a163": {Wx: 1016.000000},
|
||||
"a164": {Wx: 458.000000},
|
||||
"a165": {Wx: 924.000000},
|
||||
"a166": {Wx: 918.000000},
|
||||
"a167": {Wx: 927.000000},
|
||||
"a168": {Wx: 928.000000},
|
||||
"a169": {Wx: 928.000000},
|
||||
"a17": {Wx: 945.000000},
|
||||
"a170": {Wx: 834.000000},
|
||||
"a171": {Wx: 873.000000},
|
||||
"a172": {Wx: 828.000000},
|
||||
"a173": {Wx: 924.000000},
|
||||
"a174": {Wx: 917.000000},
|
||||
"a175": {Wx: 930.000000},
|
||||
"a176": {Wx: 931.000000},
|
||||
"a177": {Wx: 463.000000},
|
||||
"a178": {Wx: 883.000000},
|
||||
"a179": {Wx: 836.000000},
|
||||
"a18": {Wx: 974.000000},
|
||||
"a180": {Wx: 867.000000},
|
||||
"a181": {Wx: 696.000000},
|
||||
"a182": {Wx: 874.000000},
|
||||
"a183": {Wx: 760.000000},
|
||||
"a184": {Wx: 946.000000},
|
||||
"a185": {Wx: 865.000000},
|
||||
"a186": {Wx: 967.000000},
|
||||
"a187": {Wx: 831.000000},
|
||||
"a188": {Wx: 873.000000},
|
||||
"a189": {Wx: 927.000000},
|
||||
"a19": {Wx: 755.000000},
|
||||
"a190": {Wx: 970.000000},
|
||||
"a191": {Wx: 918.000000},
|
||||
"a192": {Wx: 748.000000},
|
||||
"a193": {Wx: 836.000000},
|
||||
"a194": {Wx: 771.000000},
|
||||
"a195": {Wx: 888.000000},
|
||||
"a196": {Wx: 748.000000},
|
||||
"a197": {Wx: 771.000000},
|
||||
"a198": {Wx: 888.000000},
|
||||
"a199": {Wx: 867.000000},
|
||||
"a2": {Wx: 961.000000},
|
||||
"a20": {Wx: 846.000000},
|
||||
"a200": {Wx: 696.000000},
|
||||
"a201": {Wx: 874.000000},
|
||||
"a202": {Wx: 974.000000},
|
||||
"a203": {Wx: 762.000000},
|
||||
"a204": {Wx: 759.000000},
|
||||
"a205": {Wx: 509.000000},
|
||||
"a206": {Wx: 410.000000},
|
||||
"a21": {Wx: 762.000000},
|
||||
"a22": {Wx: 761.000000},
|
||||
"a23": {Wx: 571.000000},
|
||||
"a24": {Wx: 677.000000},
|
||||
"a25": {Wx: 763.000000},
|
||||
"a26": {Wx: 760.000000},
|
||||
"a27": {Wx: 759.000000},
|
||||
"a28": {Wx: 754.000000},
|
||||
"a29": {Wx: 786.000000},
|
||||
"a3": {Wx: 980.000000},
|
||||
"a30": {Wx: 788.000000},
|
||||
"a31": {Wx: 788.000000},
|
||||
"a32": {Wx: 790.000000},
|
||||
"a33": {Wx: 793.000000},
|
||||
"a34": {Wx: 794.000000},
|
||||
"a35": {Wx: 816.000000},
|
||||
"a36": {Wx: 823.000000},
|
||||
"a37": {Wx: 789.000000},
|
||||
"a38": {Wx: 841.000000},
|
||||
"a39": {Wx: 823.000000},
|
||||
"a4": {Wx: 719.000000},
|
||||
"a40": {Wx: 833.000000},
|
||||
"a41": {Wx: 816.000000},
|
||||
"a42": {Wx: 831.000000},
|
||||
"a43": {Wx: 923.000000},
|
||||
"a44": {Wx: 744.000000},
|
||||
"a45": {Wx: 723.000000},
|
||||
"a46": {Wx: 749.000000},
|
||||
"a47": {Wx: 790.000000},
|
||||
"a48": {Wx: 792.000000},
|
||||
"a49": {Wx: 695.000000},
|
||||
"a5": {Wx: 789.000000},
|
||||
"a50": {Wx: 776.000000},
|
||||
"a51": {Wx: 768.000000},
|
||||
"a52": {Wx: 792.000000},
|
||||
"a53": {Wx: 759.000000},
|
||||
"a54": {Wx: 707.000000},
|
||||
"a55": {Wx: 708.000000},
|
||||
"a56": {Wx: 682.000000},
|
||||
"a57": {Wx: 701.000000},
|
||||
"a58": {Wx: 826.000000},
|
||||
"a59": {Wx: 815.000000},
|
||||
"a6": {Wx: 494.000000},
|
||||
"a60": {Wx: 789.000000},
|
||||
"a61": {Wx: 789.000000},
|
||||
"a62": {Wx: 707.000000},
|
||||
"a63": {Wx: 687.000000},
|
||||
"a64": {Wx: 696.000000},
|
||||
"a65": {Wx: 689.000000},
|
||||
"a66": {Wx: 786.000000},
|
||||
"a67": {Wx: 787.000000},
|
||||
"a68": {Wx: 713.000000},
|
||||
"a69": {Wx: 791.000000},
|
||||
"a7": {Wx: 552.000000},
|
||||
"a70": {Wx: 785.000000},
|
||||
"a71": {Wx: 791.000000},
|
||||
"a72": {Wx: 873.000000},
|
||||
"a73": {Wx: 761.000000},
|
||||
"a74": {Wx: 762.000000},
|
||||
"a75": {Wx: 759.000000},
|
||||
"a76": {Wx: 892.000000},
|
||||
"a77": {Wx: 892.000000},
|
||||
"a78": {Wx: 788.000000},
|
||||
"a79": {Wx: 784.000000},
|
||||
"a8": {Wx: 537.000000},
|
||||
"a81": {Wx: 438.000000},
|
||||
"a82": {Wx: 138.000000},
|
||||
"a83": {Wx: 277.000000},
|
||||
"a84": {Wx: 415.000000},
|
||||
"a85": {Wx: 509.000000},
|
||||
"a86": {Wx: 410.000000},
|
||||
"a87": {Wx: 234.000000},
|
||||
"a88": {Wx: 234.000000},
|
||||
"a89": {Wx: 390.000000},
|
||||
"a9": {Wx: 577.000000},
|
||||
"a90": {Wx: 390.000000},
|
||||
"a91": {Wx: 276.000000},
|
||||
"a92": {Wx: 276.000000},
|
||||
"a93": {Wx: 317.000000},
|
||||
"a94": {Wx: 317.000000},
|
||||
"a95": {Wx: 334.000000},
|
||||
"a96": {Wx: 334.000000},
|
||||
"a97": {Wx: 392.000000},
|
||||
"a98": {Wx: 392.000000},
|
||||
"a99": {Wx: 668.000000},
|
||||
"space": {Wx: 278.000000},
|
||||
}
|
||||
|
@ -123,10 +123,10 @@ func initTimes() {
|
||||
timesBoldItalicCharMetrics = make(map[GlyphName]CharMetrics, len(type1CommonGlyphs))
|
||||
timesItalicCharMetrics = make(map[GlyphName]CharMetrics, len(type1CommonGlyphs))
|
||||
for i, glyph := range type1CommonGlyphs {
|
||||
timesRomanCharMetrics[glyph] = CharMetrics{GlyphName: glyph, Wx: float64(timesRomanWx[i])}
|
||||
timesBoldCharMetrics[glyph] = CharMetrics{GlyphName: glyph, Wx: float64(timesBoldWx[i])}
|
||||
timesBoldItalicCharMetrics[glyph] = CharMetrics{GlyphName: glyph, Wx: float64(timesBoldItalicWx[i])}
|
||||
timesItalicCharMetrics[glyph] = CharMetrics{GlyphName: glyph, Wx: float64(timesItalicWx[i])}
|
||||
timesRomanCharMetrics[glyph] = CharMetrics{Wx: float64(timesRomanWx[i])}
|
||||
timesBoldCharMetrics[glyph] = CharMetrics{Wx: float64(timesBoldWx[i])}
|
||||
timesBoldItalicCharMetrics[glyph] = CharMetrics{Wx: float64(timesBoldItalicWx[i])}
|
||||
timesItalicCharMetrics[glyph] = CharMetrics{Wx: float64(timesItalicWx[i])}
|
||||
}
|
||||
}
|
||||
|
||||
|
12
pdf/model/fonts/testdata/afms/export_metrics.go
vendored
12
pdf/model/fonts/testdata/afms/export_metrics.go
vendored
@ -69,7 +69,7 @@ func runCharmetricsOnFile(path string) error {
|
||||
fmt.Printf("var xxfontCharMetrics map[string]CharMetrics = map[string]CharMetrics{\n")
|
||||
for _, key := range keys {
|
||||
metric := metrics[key]
|
||||
fmt.Printf("\t\"%s\":\t{GlyphName:\"%s\", Wx:%f, Wy:%f},\n", key, metric.GlyphName, metric.Wx, metric.Wy)
|
||||
fmt.Printf("\t\"%s\":\t{Wx:%f, Wy:%f},\n", key, metric.Wx, metric.Wy)
|
||||
}
|
||||
fmt.Printf("}\n")
|
||||
return nil
|
||||
@ -151,8 +151,8 @@ func GetCharmetricsFromAfmFile(filename string) (map[string]fonts.CharMetrics, e
|
||||
}
|
||||
|
||||
parts = strings.Split(line, ";")
|
||||
metrics := fonts.CharMetrics{}
|
||||
metrics.GlyphName = ""
|
||||
var metrics fonts.CharMetrics
|
||||
glyphName := ""
|
||||
for _, part := range parts {
|
||||
cmd := strings.TrimSpace(part)
|
||||
if len(cmd) == 0 {
|
||||
@ -169,7 +169,7 @@ func GetCharmetricsFromAfmFile(filename string) (map[string]fonts.CharMetrics, e
|
||||
pdfcommon.Log.Debug("Failed C line: ", line)
|
||||
return nil, errors.New("invalid C line")
|
||||
}
|
||||
metrics.GlyphName = strings.TrimSpace(args[1])
|
||||
glyphName = strings.TrimSpace(args[1])
|
||||
case "WX":
|
||||
if len(args) != 2 {
|
||||
pdfcommon.Log.Debug("WX: Invalid number of args != 1 (%s)\n", line)
|
||||
@ -204,8 +204,8 @@ func GetCharmetricsFromAfmFile(filename string) (map[string]fonts.CharMetrics, e
|
||||
}
|
||||
}
|
||||
|
||||
if len(metrics.GlyphName) > 0 {
|
||||
glyphMetricsMap[metrics.GlyphName] = metrics
|
||||
if len(glyphName) > 0 {
|
||||
glyphMetricsMap[glyphName] = metrics
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user