/* The caller must supply a string to the first call of gs_type1_interpret. */ int gs_type1_interp_init(register gs_type1_state * pcis, gs_imager_state * pis, gx_path * ppath, const gs_log2_scale_point * pscale, const gs_log2_scale_point * psubpixels, bool no_grid_fitting, int paint_type, gs_font_type1 * pfont) { static const gs_log2_scale_point no_scale = {0, 0}; const gs_log2_scale_point *plog2_scale = (FORCE_HINTS_TO_BIG_PIXELS && pscale != NULL ? pscale : &no_scale); const gs_log2_scale_point *plog2_subpixels = (FORCE_HINTS_TO_BIG_PIXELS ? (psubpixels != NULL ? psubpixels : plog2_scale) : &no_scale); if_debug0('1', "[1]gs_type1_interp_init\n"); pcis->pfont = pfont; pcis->pis = pis; pcis->path = ppath; pcis->callback_data = pfont; /* default callback data */ pcis->no_grid_fitting = no_grid_fitting; pcis->paint_type = paint_type; pcis->os_count = 0; pcis->ips_count = 1; pcis->ipstack[0].ip = 0; gs_glyph_data_from_null(&pcis->ipstack[0].cs_data); pcis->ignore_pops = 0; pcis->init_done = -1; pcis->sb_set = false; pcis->width_set = false; pcis->seac_flag = false; pcis->num_hints = 0; pcis->seac_accent = -1; pcis->log2_subpixels = *plog2_subpixels; pcis->origin_offset.x = pcis->origin_offset.y = 0; /* Set the sampling scale. */ set_pixel_scale(&pcis->scale.x, plog2_scale->x); set_pixel_scale(&pcis->scale.y, plog2_scale->y); return 0; }
/* Note that pgd may be NULL. */ static int z9_glyph_data(gs_font_base *pbfont, gs_glyph glyph, gs_glyph_data_t *pgd, int *pfidx) { gs_font_cid0 *pfont = (gs_font_cid0 *)pbfont; const font_data *pfdata = pfont_data(pfont); long glyph_index = (long)(glyph - gs_min_cid_glyph); gs_glyph_data_t gdata; ulong fidx; int code; gdata.memory = pfont->memory; if (!r_has_type(&pfdata->u.cid0.GlyphDirectory, t_null)) { code = font_gdir_get_outline(pfont->memory, &pfdata->u.cid0.GlyphDirectory, glyph_index, &gdata); if (code < 0) return code; /* Get the definition from GlyphDirectory. */ if (!gdata.bits.data) return_error(e_rangecheck); code = get_index(&gdata, pfont->cidata.FDBytes, &fidx); if (code < 0) return code; if (fidx >= pfont->cidata.FDArray_size) return_error(e_rangecheck); if (pgd) *pgd = gdata; *pfidx = (int)fidx; return code; } /* Get the definition from the binary data (GlyphData or DataSource). */ if (glyph_index < 0 || glyph_index >= pfont->cidata.common.CIDCount) { *pfidx = 0; if (pgd) gs_glyph_data_from_null(pgd); return_error(e_rangecheck); } { byte fd_gd[(MAX_FDBytes + MAX_GDBytes) * 2]; uint num_bytes = pfont->cidata.FDBytes + pfont->cidata.common.GDBytes; ulong base = pfont->cidata.CIDMapOffset + glyph_index * num_bytes; ulong gidx, fidx_next, gidx_next; int rcode = cid0_read_bytes(pfont, base, (ulong)(num_bytes * 2), fd_gd, &gdata); gs_glyph_data_t orig_data; if (rcode < 0) return rcode; orig_data = gdata; if ((code = get_index(&gdata, pfont->cidata.FDBytes, &fidx)) < 0 || (code = get_index(&gdata, pfont->cidata.common.GDBytes, &gidx)) < 0 || (code = get_index(&gdata, pfont->cidata.FDBytes, &fidx_next)) < 0 || (code = get_index(&gdata, pfont->cidata.common.GDBytes, &gidx_next)) < 0 ) DO_NOTHING; gs_glyph_data_free(&orig_data, "z9_glyph_data"); if (code < 0) return code; /* * Some CID fonts (from Adobe!) have invalid font indexes for * missing glyphs. Handle this now. */ if (gidx_next <= gidx) { /* missing glyph */ *pfidx = 0; if (pgd) gs_glyph_data_from_null(pgd); return_error(e_undefined); } if (fidx >= pfont->cidata.FDArray_size) return_error(e_rangecheck); *pfidx = (int)fidx; if (pgd == 0) return 0; return cid0_read_bytes(pfont, gidx, gidx_next - gidx, NULL, pgd); } }