Ejemplo n.º 1
0
void pdfapp_close(pdfapp_t *app)
{
    if (app->cache)
        fz_freeglyphcache(app->cache);
    app->cache = nil;

    if (app->page)
        pdf_droppage(app->page);
    app->page = nil;

    if (app->image)
        fz_droppixmap(app->image);
    app->image = nil;

    if (app->text)
        fz_freetextspan(app->text);
    app->text = nil;

    if (app->outline)
        pdf_dropoutline(app->outline);
    app->outline = nil;

    if (app->xref->store)
        pdf_dropstore(app->xref->store);
    app->xref->store = nil;

    pdf_closexref(app->xref);
    app->xref = nil;
}
fz_pixmap *
fz_rendert3glyph(fz_font *font, int gid, fz_matrix trm)
{
	fz_error error;
	fz_matrix ctm;
	fz_buffer *contents;
	fz_bbox bbox;
	fz_device *dev;
	fz_glyphcache *cache;
	fz_pixmap *glyph;
	fz_pixmap *result;

	if (gid < 0 || gid > 255)
		return NULL;

	contents = font->t3procs[gid];
	if (!contents)
		return NULL;

	ctm = fz_concat(font->t3matrix, trm);
	dev = fz_newbboxdevice(&bbox);
	error = font->t3run(font->t3xref, font->t3resources, contents, dev, ctm);
	if (error)
		fz_catch(error, "cannot draw type3 glyph");
	fz_freedevice(dev);

	glyph = fz_newpixmap(fz_devicegray, bbox.x0-1, bbox.y0-1, bbox.x1 - bbox.x0 + 1, bbox.y1 - bbox.y0 + 1);
	fz_clearpixmap(glyph, 0);

	cache = fz_newglyphcache();
	dev = fz_newdrawdevice(cache, glyph);
	error = font->t3run(font->t3xref, font->t3resources, contents, dev, ctm);
	if (error)
		fz_catch(error, "cannot draw type3 glyph");
	fz_freedevice(dev);
	fz_freeglyphcache(cache);

	result = fz_alphafromgray(glyph, 0);
	fz_droppixmap(glyph);

	return result;
}