summaryrefslogtreecommitdiff
path: root/source/html
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-05-17 16:45:08 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-05-20 14:31:08 +0200
commita4b7981d56e3cb22e2a1c18e40906e88fc331da5 (patch)
tree18d28476fd50f2740cd1d2945f81467836f46079 /source/html
parentc04aa7a89f5bbb5a4657c92a7748c4f41984c4e3 (diff)
downloadmupdf-a4b7981d56e3cb22e2a1c18e40906e88fc331da5.tar.xz
html: Add SVG image support.
Diffstat (limited to 'source/html')
-rw-r--r--source/html/html-layout.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index a720a9f8..cef2acd3 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -1,4 +1,5 @@
#include "mupdf/html.h"
+#include "mupdf/svg.h"
#include "hb.h"
#include "hb-ft.h"
@@ -395,7 +396,13 @@ static fz_image *load_html_image(fz_context *ctx, fz_archive *zip, const char *b
fz_try(ctx)
{
buf = fz_read_archive_entry(ctx, zip, path);
- img = fz_new_image_from_buffer(ctx, buf);
+ if (strstr(path, ".svg"))
+ {
+ fz_write_buffer_byte(ctx, buf, 0);
+ img = fz_new_image_from_svg(ctx, buf);
+ }
+ else
+ img = fz_new_image_from_buffer(ctx, buf);
}
fz_always(ctx)
fz_drop_buffer(ctx, buf);
@@ -728,15 +735,17 @@ static void generate_boxes(fz_context *ctx, fz_xml *node, fz_html *top,
static void measure_image(fz_context *ctx, fz_html_flow *node, float max_w, float max_h)
{
float xs = 1, ys = 1, s = 1;
+ float image_w = node->content.image->w * 72 / node->content.image->xres;
+ float image_h = node->content.image->h * 72 / node->content.image->yres;
node->x = 0;
node->y = 0;
- if (node->content.image->w > max_w)
- xs = max_w / node->content.image->w;
- if (node->content.image->h > max_h)
- ys = max_h / node->content.image->h;
+ if (image_w > max_w)
+ xs = max_w / image_w;
+ if (image_h > max_h)
+ ys = max_h / image_h;
s = fz_min(xs, ys);
- node->w = node->content.image->w * s;
- node->h = node->content.image->h * s;
+ node->w = image_w * s;
+ node->h = image_h * s;
}
typedef struct string_walker