void trace_copy_rop(const char *cname, gx_device * dev, const byte * sdata, int sourcex, uint sraster, gx_bitmap_id id, const gx_color_index * scolors, const gx_strip_bitmap * textures, const gx_color_index * tcolors, int x, int y, int width, int height, int phase_x, int phase_y, gs_logical_operation_t lop) { dlprintf4("%s: dev=0x%lx(%s) depth=%d\n", cname, (ulong) dev, dev->dname, dev->color_info.depth); dlprintf4(" source data=0x%lx x=%d raster=%u id=%lu colors=", (ulong) sdata, sourcex, sraster, (ulong) id); if (scolors) dprintf2("(%lu,%lu);\n", scolors[0], scolors[1]); else dputs("none;\n"); if (textures) dlprintf8(" textures=0x%lx size=%dx%d(%dx%d) raster=%u shift=%d(%d)", (ulong) textures, textures->size.x, textures->size.y, textures->rep_width, textures->rep_height, textures->raster, textures->shift, textures->rep_shift); else dlputs(" textures=none"); if (tcolors) dprintf2(" colors=(%lu,%lu)\n", tcolors[0], tcolors[1]); else dputs(" colors=none\n"); dlprintf7(" rect=(%d,%d),(%d,%d) phase=(%d,%d) op=0x%x\n", x, y, x + width, y + height, phase_x, phase_y, (uint) lop); if (gs_debug_c('B')) { if (sdata) debug_dump_bitmap(sdata, sraster, height, "source bits"); if (textures && textures->data) debug_dump_bitmap(textures->data, textures->raster, textures->size.y, "textures bits"); } }
int gslt_render_font_glyph(gs_state *pgs, gslt_font_t *xf, gs_matrix *tm, int gid, gslt_glyph_bitmap_t *slot) { gs_fixed_point subpixel = {0, 0}; /* we don't use subpixel accurate device metrics */ gs_log2_scale_point oversampling = {0, 0}; /* we don't use oversampling */ gs_text_params_t params; gs_text_enum_t *textenum; gs_matrix matrix; cached_fm_pair *ppair; cached_char *cc; int code; /* get the real font matrix (this is a little dance) */ gs_setfont(pgs, xf->font); /* set pgs->font and invalidate existing charmatrix */ gs_setcharmatrix(pgs, tm); /* set the charmatrix to ctm * tm */ gs_currentcharmatrix(pgs, &matrix, true); /* extract charmatrix (and multiply by FontMatrix) */ // dprintf4("tm = [%g %g %g %g]\n", matrix.xx, matrix.xy, matrix.yx, matrix.yy); /* find the font/matrix pair (or add it) */ code = gx_lookup_fm_pair(xf->font, &matrix, &oversampling, false, &ppair); if (code != 0) return gs_throw(-1, "cannot gx_lookup_fm_pair()"); cc = gx_lookup_cached_char(xf->font, ppair, gid, 0, 1, &subpixel); if (!cc) { /* No luck ... now we need to get it into the cache somehow. * * We do this by rendering one glyph (that's why we need a device and pgs). * The renderer always renders the bitmap into the cache, and draws * from out of the cache when blitting to the device. * * Things don't get evicted from the cache until there is a collision, * so we have a safe window to snarf it back out of the cache * after it's been drawn to the device. */ // dprintf1("cache miss for glyph %d\n", gid); params.operation = TEXT_FROM_SINGLE_GLYPH | TEXT_DO_DRAW | TEXT_RETURN_WIDTH; params.data.d_glyph = gid; params.size = 1; gs_moveto(pgs, 100.0, 100.0); // why? code = gs_text_begin(pgs, ¶ms, xf->font->memory, &textenum); if (code != 0) return gs_throw1(-1, "cannot gs_text_begin() (%d)", code); code = gs_text_process(textenum); if (code != 0) return gs_throw1(-1, "cannot gs_text_process() (%d)", code); gs_text_release(textenum, "gslt font render"); cc = gx_lookup_cached_char(xf->font, ppair, gid, 0, 1, &subpixel); if (!cc) { /* merde! it rendered but was not placed in the cache. */ return gs_throw(-2, "cannot render from cache"); } } /* copy values from the cache into the client struct */ slot->w = cc->width; slot->h = cc->height; slot->stride = cc_raster(cc); slot->lsb = fixed2int(cc->offset.x); slot->top = fixed2int(cc->offset.y); slot->cc = cc; slot->data = cc_bits(cc); gx_retain_cached_char(cc); #define XXX #ifndef XXX static int xxx = 0; /* declaration out in the wild not allowed in ansi c */ dprintf1("glyph %d\n", xxx); debug_dump_bitmap(cc_bits(cc), cc_raster(cc), cc->height, ""); { char fn[32]; sprintf(fn, "glyph%d.pbm", xxx); FILE *fo = fopen(fn, "wb"); if (!fo) return -1; fprintf(fo, "P4\n%d %d\n", cc->width, cc->height); int y; int s = (cc->width + 7) / 8; for (y = 0; y < cc->height; y++) fwrite(cc_bits(cc) + y * cc_raster(cc), 1, s, fo); fclose(fo); } xxx ++; #endif return 0; }