Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
func (dw *DocWriter) widthsForFontCodepage(f *Font, cpi codepage.CodepageIndex) *indirectObject {
	var widths [256]int
	upm := f.metrics.UnitsPerEm()
	// Avoid divide by zero error for unusual fonts.
	if upm > 0 {
		for i, r := range cpi.Map() {
			designWidth, _ := f.metrics.AdvanceWidth(r)
			widths[i] = designWidth * 1000 / upm
		}
	}
	pdfWidths := arrayFromInts(widths[32:])
	ioWidths := &indirectObject{dw.nextSeq(), 0, &pdfWidths}
	return ioWidths
}