func glyphDiffs(cp1, cp2 codepage.CodepageIndex, first, last int) (diffs array) { map1, map2 := cp1.Map(), cp2.Map() same := true for i := first; i <= last; i++ { if same { if map1[i] != map2[i] { same = false r := afm.RuneGlyphs[map2[i]] if r == "" { r = "question" } diffs = append(diffs, integer(i), name(r)) } } else { if map1[i] == map2[i] { same = true } else { r := afm.RuneGlyphs[map2[i]] if r == "" { r = "question" } diffs = append(diffs, name(r)) } } } return }
func (dw *DocWriter) widthsForFontCodepage(f *font.Font, cpi codepage.CodepageIndex) *indirectObject { var widths [256]int upm := f.UnitsPerEm() // Avoid divide by zero error for unusual fonts. if upm > 0 { for i, r := range cpi.Map() { designWidth, _ := f.AdvanceWidth(r) widths[i] = designWidth * 1000 / upm } } pdfWidths := arrayFromInts(widths[32:]) ioWidths := &indirectObject{dw.nextSeq(), 0, &pdfWidths} return ioWidths }