diff options
Diffstat (limited to 'source/tools')
-rw-r--r-- | source/tools/murun.c | 20 | ||||
-rw-r--r-- | source/tools/pdfcreate.c | 29 |
2 files changed, 24 insertions, 25 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); diff --git a/source/tools/pdfcreate.c b/source/tools/pdfcreate.c index 52d16dbe..043936e4 100644 --- a/source/tools/pdfcreate.c +++ b/source/tools/pdfcreate.c @@ -22,7 +22,7 @@ static void usage(void) "\t%%%%MediaBox LLX LLY URX URY\n" "\t%%%%Rotate Angle\n" "\t%%%%Font Name Filename (or base 14 font name)\n" - "\t%%%%CJKFont Name Ordering WMode Style (Ordering=CNS1|GB1|Japan1|Korea1, WMode=H|V, Style=serif|sans)\n" + "\t%%%%CJKFont Name Language WMode Style (Language=zh-Hant|zh-Hans|ja|ko, WMode=H|V, Style=serif|sans)\n" "\t%%%%Image Name Filename\n\n" ); fputs(fz_pdf_write_options_usage, stderr); @@ -55,9 +55,12 @@ static void add_font_res(pdf_obj *resources, char *name, char *path, char *encna enc = PDF_SIMPLE_ENCODING_LATIN; if (encname) { - 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; } ref = pdf_add_simple_font(ctx, doc, font, enc); @@ -67,18 +70,14 @@ static void add_font_res(pdf_obj *resources, char *name, char *path, char *encna fz_drop_font(ctx, font); } -static void add_cjkfont_res(pdf_obj *resources, char *name, char *on, char *wm, char *style) +static void add_cjkfont_res(pdf_obj *resources, char *name, char *lang, char *wm, char *style) { const unsigned char *data; int size, index, ordering, wmode, serif; fz_font *font; pdf_obj *subres, *ref; - if (!strcmp(on, "CNS1") || !strcmp(on, "TW") || !strcmp(on, "TC") || !strcmp(on, "Hant")) ordering = FZ_ADOBE_CNS_1; - else if (!strcmp(on, "GB1") || !strcmp(on, "CN") || !strcmp(on, "SC") || !strcmp(on, "Hans")) ordering = FZ_ADOBE_GB_1; - else if (!strcmp(on, "Japan1") || !strcmp(on, "JP") || !strcmp(on, "JA")) ordering = FZ_ADOBE_JAPAN_1; - else if (!strcmp(on, "Korea1") || !strcmp(on, "KR") || !strcmp(on, "KO")) ordering = FZ_ADOBE_KOREA_1; - else ordering = FZ_ADOBE_JAPAN_1; + ordering = fz_lookup_cjk_ordering_by_language(lang); if (wm && !strcmp(wm, "V")) wmode = 1; @@ -90,7 +89,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, &size, &index); + data = fz_lookup_cjk_font(ctx, ordering, &size, &index); font = fz_new_font_from_memory(ctx, NULL, data, size, index, 0); subres = pdf_dict_get(ctx, resources, PDF_NAME(Font)); @@ -134,7 +133,7 @@ The input is a raw content stream, with commands embedded in comments: %%MediaBox LLX LLY URX URY %%Rotate Angle %%Font Name Filename (or base 14 font name) [Encoding (Latin, Greek or Cyrillic)] -%%CJKFont Name Ordering WMode Style (Ordering=CNS1|GB1|Japan1|Korea1, WMode=H|V, Style=serif|sans) +%%CJKFont Name Language WMode Style (Language=zh-Hant|zh-Hans|ja|ko, WMode=H|V, Style=serif|sans) %%Image Name Filename */ static void create_page(char *input) @@ -183,12 +182,12 @@ static void create_page(char *input) else if (!strcmp(s, "%%CJKFont")) { char *name = fz_strsep(&p, " "); - char *ordering = fz_strsep(&p, " "); + char *lang = fz_strsep(&p, " "); char *wmode = fz_strsep(&p, " "); char *style = fz_strsep(&p, " "); - if (!name || !ordering) + if (!name || !lang) fz_throw(ctx, FZ_ERROR_GENERIC, "CJKFont directive missing arguments"); - add_cjkfont_res(resources, name, ordering, wmode, style); + add_cjkfont_res(resources, name, lang, wmode, style); } else if (!strcmp(s, "%%Image")) { |