diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-04-19 14:57:56 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-04-25 12:26:33 +0200 |
commit | 73ce99685536764bf17dc097f5cba7208cd8f9c1 (patch) | |
tree | 4840bd0debf0160f1a0b48b2087162a5ad0a86c8 /source | |
parent | c17e8a57934a863dc24476300d89e9483b9773e9 (diff) | |
download | mupdf-73ce99685536764bf17dc097f5cba7208cd8f9c1.tar.xz |
Don't use WMode as part of CJK font lookup.
Return TTC subfont index from fz_lookup_noto_font.
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/font.c | 9 | ||||
-rw-r--r-- | source/fitz/noto.c | 22 | ||||
-rw-r--r-- | source/pdf/pdf-font.c | 2 | ||||
-rw-r--r-- | source/tools/pdfcreate.c | 2 |
4 files changed, 19 insertions, 16 deletions
diff --git a/source/fitz/font.c b/source/fitz/font.c index b92d40e9..badc7028 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -374,6 +374,7 @@ fz_font *fz_load_fallback_font(fz_context *ctx, int script, int language, int se fz_font **fontp; const unsigned char *data; int index; + int subfont; int size; if (script < 0 || script > nelem(ctx->font->fallback)) @@ -408,9 +409,9 @@ fz_font *fz_load_fallback_font(fz_context *ctx, int script, int language, int se *fontp = fz_load_system_fallback_font(ctx, script, language, serif, bold, italic); if (!*fontp) { - data = fz_lookup_noto_font(ctx, script, language, serif, &size); + data = fz_lookup_noto_font(ctx, script, language, serif, &size, &subfont); if (data) - *fontp = fz_new_font_from_memory(ctx, NULL, data, size, 0, 0); + *fontp = fz_new_font_from_memory(ctx, NULL, data, size, subfont, 0); } } @@ -646,11 +647,11 @@ fz_new_base14_font(fz_context *ctx, const char *name) } fz_font * -fz_new_cjk_font(fz_context *ctx, int ordering, int serif, int wmode) +fz_new_cjk_font(fz_context *ctx, int ordering, int serif) { const unsigned char *data; int size, index; - data = fz_lookup_cjk_font(ctx, ordering, serif, wmode, &size, &index); + data = fz_lookup_cjk_font(ctx, ordering, serif, &size, &index); if (!data) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find builtin CJK font"); return fz_new_font_from_memory(ctx, NULL, data, size, index, 0); diff --git a/source/fitz/noto.c b/source/fitz/noto.c index 1d039794..90df0f05 100644 --- a/source/fitz/noto.c +++ b/source/fitz/noto.c @@ -139,9 +139,9 @@ fz_lookup_builtin_font(fz_context *ctx, const char *name, int is_bold, int is_it } const unsigned char * -fz_lookup_cjk_font(fz_context *ctx, int ordering, int serif, int wmode, int *size, int *index) +fz_lookup_cjk_font(fz_context *ctx, int ordering, int serif, int *size, int *subfont) { - if (index) *index = 0; + *subfont = 0; #ifndef TOFU_CJK #ifndef TOFU_CJK_EXT #ifndef TOFU_CJK_LANG @@ -169,11 +169,13 @@ fz_lookup_cjk_font(fz_context *ctx, int ordering, int serif, int wmode, int *siz if (serif) { RETURN(noto_Noto ## SERIF ## _Regular_ttf); } else { RETURN(noto_Noto ## SANS ## _Regular_ttf); } const unsigned char * -fz_lookup_noto_font(fz_context *ctx, int script, int language, int serif, int *size) +fz_lookup_noto_font(fz_context *ctx, int script, int language, int serif, int *size, int *subfont) { /* TODO: Noto(SansSyriacEstrangela); */ /* TODO: Noto(SansSyriacWestern); */ + *subfont = 0; + switch (script) { default: @@ -183,20 +185,20 @@ fz_lookup_noto_font(fz_context *ctx, int script, int language, int serif, int *s break; case UCDN_SCRIPT_HANGUL: - return fz_lookup_cjk_font(ctx, FZ_ADOBE_KOREA_1, serif, 0, size, NULL); + return fz_lookup_cjk_font(ctx, FZ_ADOBE_KOREA_1, serif, size, subfont); case UCDN_SCRIPT_HIRAGANA: case UCDN_SCRIPT_KATAKANA: - return fz_lookup_cjk_font(ctx, FZ_ADOBE_JAPAN_1, serif, 0, size, NULL); + return fz_lookup_cjk_font(ctx, FZ_ADOBE_JAPAN_1, serif, size, subfont); case UCDN_SCRIPT_BOPOMOFO: - return fz_lookup_cjk_font(ctx, FZ_ADOBE_CNS_1, serif, 0, size, NULL); + return fz_lookup_cjk_font(ctx, FZ_ADOBE_CNS_1, serif, size, subfont); case UCDN_SCRIPT_HAN: switch (language) { - case FZ_LANG_ja: return fz_lookup_cjk_font(ctx, FZ_ADOBE_JAPAN_1, serif, 0, size, NULL); - case FZ_LANG_ko: return fz_lookup_cjk_font(ctx, FZ_ADOBE_KOREA_1, serif, 0, size, NULL); - case FZ_LANG_zh_Hant: return fz_lookup_cjk_font(ctx, FZ_ADOBE_CNS_1, serif, 0, size, NULL); + case FZ_LANG_ja: return fz_lookup_cjk_font(ctx, FZ_ADOBE_JAPAN_1, serif, size, subfont); + case FZ_LANG_ko: return fz_lookup_cjk_font(ctx, FZ_ADOBE_KOREA_1, serif, size, subfont); + case FZ_LANG_zh_Hans: return fz_lookup_cjk_font(ctx, FZ_ADOBE_GB_1, serif, size, subfont); default: - case FZ_LANG_zh_Hans: return fz_lookup_cjk_font(ctx, FZ_ADOBE_GB_1, serif, 0, size, NULL); + case FZ_LANG_zh_Hant: return fz_lookup_cjk_font(ctx, FZ_ADOBE_CNS_1, serif, size, subfont); } #ifndef TOFU_NOTO diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index 3ed8cbb9..106a6657 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -406,7 +406,7 @@ pdf_load_substitute_cjk_font(fz_context *ctx, pdf_font_desc *fontdesc, const cha int len; int index; - data = fz_lookup_cjk_font(ctx, ros, serif, fontdesc->wmode, &len, &index); + data = fz_lookup_cjk_font(ctx, ros, serif, &len, &index); if (!data) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find builtin CJK font"); diff --git a/source/tools/pdfcreate.c b/source/tools/pdfcreate.c index f89bc2e4..a8502fdc 100644 --- a/source/tools/pdfcreate.c +++ b/source/tools/pdfcreate.c @@ -90,7 +90,7 @@ static void add_cjkfont_res(pdf_obj *resources, char *name, char *on, char *wm, else serif = 1; - data = fz_lookup_cjk_font(ctx, ordering, serif, wmode, &size, &index); + data = fz_lookup_cjk_font(ctx, ordering, serif, &size, &index); font = fz_new_font_from_memory(ctx, NULL, data, size, index, 0); subres = pdf_dict_get(ctx, resources, PDF_NAME(Font)); |