summaryrefslogtreecommitdiff
path: root/pdf/pdf_unicode.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-09-14 17:36:57 +0100
committerRobin Watts <Robin.Watts@artifex.com>2011-09-15 14:50:17 +0100
commitb51ef0eea028c73b6379e832eaa34fff3fbbb927 (patch)
tree1ab685ccd356e7fdc832b2e3322c0486b2670cfb /pdf/pdf_unicode.c
parent89ae81f651bfa112b8e07317eb6983beaf7cb212 (diff)
downloadmupdf-b51ef0eea028c73b6379e832eaa34fff3fbbb927.tar.xz
Add context to mupdf.
Huge pervasive change to lots of files, adding a context for exception handling and allocation. In time we'll move more statics into there. Also fix some for(i = 0; i < function(...); i++) calls.
Diffstat (limited to 'pdf/pdf_unicode.c')
-rw-r--r--pdf/pdf_unicode.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/pdf/pdf_unicode.c b/pdf/pdf_unicode.c
index 3f27eeb7..25781e1c 100644
--- a/pdf/pdf_unicode.c
+++ b/pdf/pdf_unicode.c
@@ -13,6 +13,7 @@ pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref,
int ucsbuf[8];
int ucslen;
int i;
+ fz_context *ctx = xref->ctx;
if (pdf_is_stream(xref, fz_to_num(cmapstm), fz_to_gen(cmapstm)))
{
@@ -20,7 +21,7 @@ pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref,
if (error)
return fz_error_note(error, "cannot load embedded cmap (%d %d R)", fz_to_num(cmapstm), fz_to_gen(cmapstm));
- font->to_unicode = pdf_new_cmap();
+ font->to_unicode = pdf_new_cmap(ctx);
for (i = 0; i < (strings ? 256 : 65536); i++)
{
@@ -29,15 +30,15 @@ pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref,
{
ucslen = pdf_lookup_cmap_full(cmap, i, ucsbuf);
if (ucslen == 1)
- pdf_map_range_to_range(font->to_unicode, cid, cid, ucsbuf[0]);
+ pdf_map_range_to_range(ctx, font->to_unicode, cid, cid, ucsbuf[0]);
if (ucslen > 1)
- pdf_map_one_to_many(font->to_unicode, cid, ucsbuf, ucslen);
+ pdf_map_one_to_many(ctx, font->to_unicode, cid, ucsbuf, ucslen);
}
}
- pdf_sort_cmap(font->to_unicode);
+ pdf_sort_cmap(ctx, font->to_unicode);
- pdf_drop_cmap(cmap);
+ pdf_drop_cmap(ctx, cmap);
}
else if (collection)
@@ -45,13 +46,13 @@ pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref,
error = fz_okay;
if (!strcmp(collection, "Adobe-CNS1"))
- error = pdf_load_system_cmap(&font->to_unicode, "Adobe-CNS1-UCS2");
+ error = pdf_load_system_cmap(ctx, &font->to_unicode, "Adobe-CNS1-UCS2");
else if (!strcmp(collection, "Adobe-GB1"))
- error = pdf_load_system_cmap(&font->to_unicode, "Adobe-GB1-UCS2");
+ error = pdf_load_system_cmap(ctx, &font->to_unicode, "Adobe-GB1-UCS2");
else if (!strcmp(collection, "Adobe-Japan1"))
- error = pdf_load_system_cmap(&font->to_unicode, "Adobe-Japan1-UCS2");
+ error = pdf_load_system_cmap(ctx, &font->to_unicode, "Adobe-Japan1-UCS2");
else if (!strcmp(collection, "Adobe-Korea1"))
- error = pdf_load_system_cmap(&font->to_unicode, "Adobe-Korea1-UCS2");
+ error = pdf_load_system_cmap(ctx, &font->to_unicode, "Adobe-Korea1-UCS2");
if (error)
return fz_error_note(error, "cannot load ToUnicode system cmap %s-UCS2", collection);
@@ -62,7 +63,7 @@ pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref,
/* TODO one-to-many mappings */
font->cid_to_ucs_len = 256;
- font->cid_to_ucs = fz_calloc(256, sizeof(unsigned short));
+ font->cid_to_ucs = fz_calloc(ctx, 256, sizeof(unsigned short));
for (i = 0; i < 256; i++)
{