diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-09-05 15:27:22 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-09-21 14:21:05 +0200 |
commit | 48b026e7500c5f7239e173d14d09b9e2e272e874 (patch) | |
tree | d6231e9b0c39d7a6eb361eff3762855ea05102d8 /source/tools/murun.c | |
parent | 60103f2af83eb04c1e74b32fa9d29c74bf01c118 (diff) | |
download | mupdf-48b026e7500c5f7239e173d14d09b9e2e272e874.tar.xz |
Regularize language and script names.
Drop the unused 'serif' argument to the CJK lookup functions.
Use the BCP 47 names for CJK scripts and languages:
zh-Hant for traditional Chinese,
zh-Hans for simplified Chinese,
ja for Japanese,
ko for Korean.
The lookup function also allows commonly used language+country codes:
zh-TW and zh-HK for traditional Chinese,
zh-CN for simplified Chinese.
Diffstat (limited to 'source/tools/murun.c')
-rw-r--r-- | source/tools/murun.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/source/tools/murun.c b/source/tools/murun.c index 810b32ce..961d6a7a 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -3285,9 +3285,12 @@ static void ffi_PDFDocument_addSimpleFont(js_State *J) pdf_obj *ind = NULL; int enc = PDF_SIMPLE_ENCODING_LATIN; - if (!strcmp(encname, "Latin")) enc = PDF_SIMPLE_ENCODING_LATIN; - else if (!strcmp(encname, "Greek")) enc = PDF_SIMPLE_ENCODING_GREEK; - else if (!strcmp(encname, "Cyrillic")) enc = PDF_SIMPLE_ENCODING_CYRILLIC; + if (!strcmp(encname, "Latin") || !strcmp(encname, "Latn")) + enc = PDF_SIMPLE_ENCODING_LATIN; + else if (!strcmp(encname, "Greek") || !strcmp(encname, "Grek")) + enc = PDF_SIMPLE_ENCODING_GREEK; + else if (!strcmp(encname, "Cyrillic") || !strcmp(encname, "Cyrl")) + enc = PDF_SIMPLE_ENCODING_CYRILLIC; fz_try(ctx) ind = pdf_add_simple_font(ctx, pdf, font, enc); @@ -3302,18 +3305,15 @@ static void ffi_PDFDocument_addCJKFont(js_State *J) fz_context *ctx = js_getcontext(J); pdf_document *pdf = js_touserdata(J, 0, "pdf_document"); fz_font *font = js_touserdata(J, 1, "fz_font"); - const char *on = js_tostring(J, 2); + const char *lang = js_tostring(J, 2); const char *wm = js_tostring(J, 3); const char *ss = js_tostring(J, 4); - int ord = FZ_ADOBE_JAPAN_1; + int ordering; int wmode = 0; int serif = 1; pdf_obj *ind = NULL; - if (!strcmp(on, "CNS1") || !strcmp(on, "TW") || !strcmp(on, "TC") || !strcmp(on, "Hant")) ord = FZ_ADOBE_CNS_1; - else if (!strcmp(on, "GB1") || !strcmp(on, "CN") || !strcmp(on, "SC") || !strcmp(on, "Hans")) ord = FZ_ADOBE_GB_1; - else if (!strcmp(on, "Korea1") || !strcmp(on, "KR") || !strcmp(on, "KO")) ord = FZ_ADOBE_KOREA_1; - else if (!strcmp(on, "Japan1") || !strcmp(on, "JP") || !strcmp(on, "JA")) ord = FZ_ADOBE_JAPAN_1; + ordering = fz_lookup_cjk_ordering_by_language(lang); if (!strcmp(wm, "V")) wmode = 1; @@ -3321,7 +3321,7 @@ static void ffi_PDFDocument_addCJKFont(js_State *J) serif = 0; fz_try(ctx) - ind = pdf_add_cjk_font(ctx, pdf, font, ord, wmode, serif); + ind = pdf_add_cjk_font(ctx, pdf, font, ordering, wmode, serif); fz_catch(ctx) rethrow(J); |