summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-font.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-07-17 18:42:33 +0100
committerRobin Watts <robin.watts@artifex.com>2013-07-19 19:54:27 +0100
commitf5f7c0e4dd83257f526b158e3998970717852a0e (patch)
treec34ee93ab7773e4fbe48506c97fb515c03707e57 /source/pdf/pdf-font.c
parent3c559928d88fccfe17da4953ea1c93ceb42a90cb (diff)
downloadmupdf-f5f7c0e4dd83257f526b158e3998970717852a0e.tar.xz
Initial work on progressive loading
We are testing this using a new -p flag to mupdf that sets a bitrate at which data will appear to arrive progressively as time goes on. For example: mupdf -p 102400 pdf_reference17.pdf Details of the scheme used here are presented in docs/progressive.txt
Diffstat (limited to 'source/pdf/pdf-font.c')
-rw-r--r--source/pdf/pdf-font.c82
1 files changed, 76 insertions, 6 deletions
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index 2c18d96a..a5174979 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -397,7 +397,7 @@ pdf_new_font_desc(fz_context *ctx)
*/
static pdf_font_desc *
-pdf_load_simple_font(pdf_document *doc, pdf_obj *dict)
+pdf_load_simple_font_by_name(pdf_document *doc, pdf_obj *dict, char *basefont)
{
pdf_obj *descriptor;
pdf_obj *encoding;
@@ -410,7 +410,6 @@ pdf_load_simple_font(pdf_document *doc, pdf_obj *dict)
int symbolic;
int kind;
- char *basefont;
char *estrings[256];
char ebuffer[256][32];
int i, k, n;
@@ -422,8 +421,6 @@ pdf_load_simple_font(pdf_document *doc, pdf_obj *dict)
fz_var(etable);
fz_var(has_lock);
- basefont = pdf_to_name(pdf_dict_gets(dict, "BaseFont"));
-
/* Load font file */
fz_try(ctx)
{
@@ -688,7 +685,7 @@ pdf_load_simple_font(pdf_document *doc, pdf_obj *dict)
}
fz_catch(ctx)
{
- /* FIXME: TryLater */
+ fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
fz_warn(ctx, "cannot load ToUnicode CMap");
}
@@ -744,6 +741,79 @@ pdf_load_simple_font(pdf_document *doc, pdf_obj *dict)
return fontdesc;
}
+static pdf_font_desc *
+pdf_load_simple_font(pdf_document *doc, pdf_obj *dict)
+{
+ char *basefont = pdf_to_name(pdf_dict_gets(dict, "BaseFont"));
+
+ return pdf_load_simple_font_by_name(doc, dict, basefont);
+}
+
+static int
+hail_mary_make_hash_key(fz_store_hash *hash, void *key_)
+{
+ hash->u.i.i0 = 0;
+ hash->u.i.i1 = 0;
+ return 1;
+}
+
+static void *
+hail_mary_keep_key(fz_context *ctx, void *key)
+{
+ return key;
+}
+
+static void
+hail_mary_drop_key(fz_context *ctx, void *key)
+{
+}
+
+static int
+hail_mary_cmp_key(void *k0, void *k1)
+{
+ return k0 == k1;
+}
+
+#ifndef NDEBUG
+static void
+hail_mary_debug_key(FILE *out, void *key_)
+{
+ fprintf(out, "hail mary ");
+}
+#endif
+
+static fz_store_type hail_mary_store_type =
+{
+ hail_mary_make_hash_key,
+ hail_mary_keep_key,
+ hail_mary_drop_key,
+ hail_mary_cmp_key,
+#ifndef NDEBUG
+ hail_mary_debug_key
+#endif
+};
+
+pdf_font_desc *
+pdf_load_hail_mary_font(pdf_document *doc)
+{
+ fz_context *ctx = doc->ctx;
+ pdf_font_desc *fontdesc;
+ pdf_font_desc *existing;
+
+ if ((fontdesc = fz_find_item(ctx, pdf_free_font_imp, &hail_mary_store_type, &hail_mary_store_type)))
+ {
+ return fontdesc;
+ }
+
+ /* FIXME: Get someone with a clue about fonts to fix this */
+ fontdesc = pdf_load_simple_font_by_name(doc, NULL, "Helvetica");
+
+ existing = fz_store_item(ctx, &hail_mary_store_type, fontdesc, fontdesc->size, &hail_mary_store_type);
+ assert(existing == NULL);
+
+ return fontdesc;
+}
+
/*
* CID Fonts
*/
@@ -1057,7 +1127,7 @@ pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_document *doc, pdf_obj *di
}
fz_catch(ctx)
{
- /* FIXME: TryLater */
+ fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
fz_warn(ctx, "ignored error when loading embedded font; attempting to load system font");
if (origname != fontname && !iscidfont)
pdf_load_builtin_font(ctx, fontdesc, fontname);