Пример #1
0
func (t *SvgTextT) cmap(font string) (r *cmapi.CharMapperT) {
	var ok bool
	if r, ok = t.cmaps[font]; ok {
		return
	}
	r = cm_identity // setup default
	if t.fonts == nil {
		t.fonts = t.Pdf.PageFonts(t.Pdf.Pages()[t.Page])
		if t.fonts == nil {
			return
		}
	}
	if dr, ok := t.fonts[font]; ok {
		d := t.Pdf.Dic(dr)
		if tu, ok := d["/ToUnicode"]; ok {
			_, cm := t.Pdf.DecodedStream(tu)
			r = cmapi.Read(fancy.SliceReader(cm))
			t.cmaps[font] = r
		}
	}
	return
}
Пример #2
0
		}
		wd, ok := d["/Widths"]
		if !ok {
			return
		}
		p := strm.Int(string(fc), 1)
		q := strm.Int(string(lc), 1)
		a := t.Pdf.Arr(wd)
		for k := p; k < q; k++ {
			r.Add(k, strm.Int(string(a[k-p]), WIDTH_DENSITY/1000))
		}
	}
	return
}

var cm_identity = cmapi.Read(nil)

func (t *SvgTextT) cmap(font string) (r *cmapi.CharMapperT) {
	var ok bool
	if r, ok = t.cmaps[font]; ok {
		return
	}
	r = cm_identity // setup default
	if t.fonts == nil {
		t.fonts = t.Pdf.PageFonts(t.Pdf.Pages()[t.Page])
		if t.fonts == nil {
			return
		}
	}
	if dr, ok := t.fonts[font]; ok {
		d := t.Pdf.Dic(dr)