diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2011-10-04 18:44:19 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2011-10-04 18:44:19 +0100 |
commit | d208be26537db558edb70236ae517cea31b7ebab (patch) | |
tree | 57da95b97e354a53bd4517a42010e90968f007d9 /pdf/pdf_unicode.c | |
parent | ba46cad4b09bb957085900a203206c8fa5868cd4 (diff) | |
download | mupdf-d208be26537db558edb70236ae517cea31b7ebab.tar.xz |
Move to exception handling rather than error passing throughout.
This frees us from passing errors back everywhere, and hence enables us
to pass results back as return values.
Rather than having to explicitly check for errors everywhere and bubble
them, we now allow exception handling to do the work for us; the
downside to this is that we no longer emit as much debugging information
as we did before (though this could be put back in). For now, the
debugging information we have lost has been retained in comments
with 'RJW:' at the start.
This code needs fuller testing, but is being committed as a work in
progress.
Diffstat (limited to 'pdf/pdf_unicode.c')
-rw-r--r-- | pdf/pdf_unicode.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/pdf/pdf_unicode.c b/pdf/pdf_unicode.c index 46c68a52..7968036a 100644 --- a/pdf/pdf_unicode.c +++ b/pdf/pdf_unicode.c @@ -3,11 +3,10 @@ /* Load or synthesize ToUnicode map for fonts */ -fz_error +void pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, char **strings, char *collection, fz_obj *cmapstm) { - fz_error error = fz_okay; pdf_cmap *cmap; int cid; int ucsbuf[8]; @@ -17,9 +16,8 @@ pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, if (pdf_is_stream(xref, fz_to_num(cmapstm), fz_to_gen(cmapstm))) { - error = pdf_load_embedded_cmap(&cmap, xref, cmapstm); - if (error) - return fz_error_note(error, "cannot load embedded cmap (%d %d R)", fz_to_num(cmapstm), fz_to_gen(cmapstm)); + cmap = pdf_load_embedded_cmap(xref, cmapstm); + /* RJW: "cannot load embedded cmap (%d %d R)", fz_to_num(cmapstm), fz_to_gen(cmapstm) */ font->to_unicode = pdf_new_cmap(ctx); @@ -43,19 +41,17 @@ pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, else if (collection) { - error = fz_okay; - if (!strcmp(collection, "Adobe-CNS1")) - error = pdf_load_system_cmap(ctx, &font->to_unicode, "Adobe-CNS1-UCS2"); + font->to_unicode = pdf_load_system_cmap(ctx, "Adobe-CNS1-UCS2"); else if (!strcmp(collection, "Adobe-GB1")) - error = pdf_load_system_cmap(ctx, &font->to_unicode, "Adobe-GB1-UCS2"); + font->to_unicode = pdf_load_system_cmap(ctx, "Adobe-GB1-UCS2"); else if (!strcmp(collection, "Adobe-Japan1")) - error = pdf_load_system_cmap(ctx, &font->to_unicode, "Adobe-Japan1-UCS2"); + font->to_unicode = pdf_load_system_cmap(ctx, "Adobe-Japan1-UCS2"); else if (!strcmp(collection, "Adobe-Korea1")) - error = pdf_load_system_cmap(ctx, &font->to_unicode, "Adobe-Korea1-UCS2"); + font->to_unicode = pdf_load_system_cmap(ctx, "Adobe-Korea1-UCS2"); - if (error) - return fz_error_note(error, "cannot load ToUnicode system cmap %s-UCS2", collection); + return; + /* RJW: "cannot load ToUnicode system cmap %s-UCS2", collection */ } if (strings) @@ -79,6 +75,4 @@ pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, /* TODO: synthesize a ToUnicode if it's a freetype font with * cmap and/or post tables or if it has glyph names. */ } - - return fz_okay; } |