diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2015-09-15 12:38:37 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2015-09-15 21:57:43 +0200 |
commit | c97ba05ef627bfdea79bf925e5728ae27270d25e (patch) | |
tree | c37c65fa05c33f7bf70c8beff33a02b9b753fb09 /source/html/html-font.c | |
parent | 334444a89f9099b540f93f7bc0e2f0509de536d7 (diff) | |
download | mupdf-c97ba05ef627bfdea79bf925e5728ae27270d25e.tar.xz |
epub: Use a fallback font.
Diffstat (limited to 'source/html/html-font.c')
-rw-r--r-- | source/html/html-font.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/html/html-font.c b/source/html/html-font.c index 08da04f5..e9c17719 100644 --- a/source/html/html-font.c +++ b/source/html/html-font.c @@ -1,6 +1,7 @@ #include "mupdf/html.h" unsigned char *pdf_lookup_builtin_font(fz_context *ctx, const char *name, unsigned int *len); +unsigned char *pdf_lookup_substitute_cjk_font(fz_context *ctx, int ros, int serif, int wmode, unsigned int *len, int *index); static const char *font_names[16] = { @@ -34,6 +35,23 @@ fz_load_html_font(fz_context *ctx, fz_html_font_set *set, return set->fonts[idx]; } +fz_font * +fz_load_html_fallback_font(fz_context *ctx, fz_html_font_set *set) +{ + if (!set->fallback) + { + unsigned char *data; + unsigned int size; + int index; + + data = pdf_lookup_substitute_cjk_font(ctx, FZ_ADOBE_GB_1, 0, 0, &size, &index); + if (!data) + fz_throw(ctx, FZ_ERROR_GENERIC, "cannot load fallback font"); + set->fallback = fz_new_font_from_memory(ctx, "fallback", data, size, index, 0); + } + return set->fallback; +} + fz_html_font_set *fz_new_html_font_set(fz_context *ctx) { return fz_malloc_struct(ctx, fz_html_font_set); @@ -44,5 +62,6 @@ void fz_drop_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_drop_font(ctx, set->fallback); fz_free(ctx, set); } |