static void pdf_parse_codespace_range(fz_context *ctx, pdf_cmap *cmap, fz_stream *file) { pdf_lexbuf buf; int tok; int lo, hi; buf.size = PDF_LEXBUF_SMALL; while (1) { tok = pdf_lex_cmap(file, &buf); /* RJW: Lost debugging: "syntaxerror in cmap" */ if (tok == TOK_END_CODESPACE_RANGE) return; else if (tok == PDF_TOK_STRING) { lo = pdf_code_from_string(buf.scratch, buf.len); tok = pdf_lex_cmap(file, &buf); /* RJW: Lost debugging: "syntaxerror in cmap" */ if (tok == PDF_TOK_STRING) { hi = pdf_code_from_string(buf.scratch, buf.len); pdf_add_codespace(ctx, cmap, lo, hi, buf.len); } else break; } else break; } fz_throw(ctx, "expected string or endcodespacerange"); }
static void pdf_parse_codespace_range(pdf_cmap *cmap, fz_stream *file) { char buf[256]; int tok; int len; int lo, hi; while (1) { tok = pdf_lex_cmap(file, buf, sizeof buf, &len); /* RJW: Lost debugging: "syntaxerror in cmap" */ if (tok == TOK_END_CODESPACE_RANGE) return; else if (tok == PDF_TOK_STRING) { lo = pdf_code_from_string(buf, len); tok = pdf_lex_cmap(file, buf, sizeof buf, &len); /* RJW: Lost debugging: "syntaxerror in cmap" */ if (tok == PDF_TOK_STRING) { hi = pdf_code_from_string(buf, len); pdf_add_codespace(file->ctx, cmap, lo, hi, len); } else break; } else break; } fz_throw(file->ctx, "expected string or endcodespacerange"); }
/* * Create an Identity-* CMap (for both 1 and 2-byte encodings) */ pdf_cmap * pdf_new_identity_cmap(int wmode, int bytes) { pdf_cmap *cmap = pdf_new_cmap(); sprintf(cmap->cmap_name, "Identity-%c", wmode ? 'V' : 'H'); pdf_add_codespace(cmap, 0x0000, 0xffff, bytes); pdf_map_range_to_range(cmap, 0x0000, 0xffff, 0); pdf_sort_cmap(cmap); pdf_set_wmode(cmap, wmode); return cmap; }
/* * Create an Identity-* CMap (for both 1 and 2-byte encodings) */ pdf_cmap * pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes) { pdf_cmap *cmap = pdf_new_cmap(ctx); fz_try(ctx) { sprintf(cmap->cmap_name, "Identity-%c", wmode ? 'V' : 'H'); pdf_add_codespace(ctx, cmap, 0x0000, 0xffff, bytes); pdf_map_range_to_range(ctx, cmap, 0x0000, 0xffff, 0); pdf_sort_cmap(ctx, cmap); pdf_set_cmap_wmode(ctx, cmap, wmode); } fz_catch(ctx) { pdf_drop_cmap(ctx, cmap); fz_rethrow(ctx); } return cmap; }
/* * Create an Identity-* CMap (for both 1 and 2-byte encodings) */ pdf_cmap * pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes) { pdf_cmap *cmap = pdf_new_cmap(ctx); fz_try(ctx) { unsigned int high = (1 << (bytes * 8)) - 1; sprintf(cmap->cmap_name, "Identity-%c", wmode ? 'V' : 'H'); pdf_add_codespace(ctx, cmap, 0, high, bytes); pdf_map_range_to_range(ctx, cmap, 0, high, 0); pdf_sort_cmap(ctx, cmap); pdf_set_cmap_wmode(ctx, cmap, wmode); } fz_catch(ctx) { pdf_drop_cmap(ctx, cmap); fz_rethrow(ctx); } return cmap; }