summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/html/html-font.c12
-rw-r--r--source/html/html-layout.c17
2 files changed, 20 insertions, 9 deletions
diff --git a/source/html/html-font.c b/source/html/html-font.c
index e5d42bdc..c7b1cf3c 100644
--- a/source/html/html-font.c
+++ b/source/html/html-font.c
@@ -1,7 +1,8 @@
#include "mupdf/html.h"
#include "mupdf/pdf.h" /* for pdf_lookup_builtin_font */
-static const char *font_names[16] = {
+static const char *font_names[16] =
+{
"Times-Roman", "Times-Italic", "Times-Bold", "Times-BoldItalic",
"Helvetica", "Helvetica-Oblique", "Helvetica-Bold", "Helvetica-BoldOblique",
"Courier", "Courier-Oblique", "Courier-Bold", "Courier-BoldOblique",
@@ -24,10 +25,8 @@ fz_load_html_font(fz_context *ctx, fz_html_font_set *set,
if (!set->fonts[idx])
{
data = pdf_lookup_builtin_font(font_names[idx], &size);
- if (!data) {
- printf("data=%p idx=%d s=%s\n", data, idx, font_names[idx]);
- abort();
- }
+ if (!data)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot load html font: %s", font_names[idx]);
set->fonts[idx] = fz_new_font_from_memory(ctx, font_names[idx], data, size, 0, 1);
}
@@ -41,5 +40,8 @@ fz_html_font_set *fz_new_html_font_set(fz_context *ctx)
void fz_free_html_font_set(fz_context *ctx, fz_html_font_set *set)
{
+ int i;
+ for (i = 0; i < nelem(set->fonts); ++i)
+ fz_drop_font(ctx, set->fonts[i]);
fz_free(ctx, set);
}
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index 384a2720..59719de5 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -116,11 +116,20 @@ static void generate_image(fz_context *ctx, fz_archive *zip, const char *base_ur
fz_strlcat(path, src, sizeof path);
fz_cleanname(path);
- buf = fz_read_archive_entry(ctx, zip, path);
- img = fz_new_image_from_buffer(ctx, buf);
- fz_drop_buffer(ctx, buf);
+ fz_try(ctx)
+ {
+ buf = fz_read_archive_entry(ctx, zip, path);
+ img = fz_new_image_from_buffer(ctx, buf);
+ fz_drop_buffer(ctx, buf);
- add_flow_image(ctx, flow, &box->style, img);
+ add_flow_image(ctx, flow, &box->style, img);
+ }
+ fz_catch(ctx)
+ {
+ const char *alt = "[image]";
+ fz_warn(ctx, "html: cannot add image src='%s'", src);
+ add_flow_word(ctx, flow, &box->style, alt, alt + 7);
+ }
}
static void init_box(fz_context *ctx, struct box *box, fz_xml *node)