summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-09-19 13:20:01 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-09-21 14:21:05 +0200
commit211234411c68f4578c3bbfafeb84e8d26040443a (patch)
treeb640e31e93aded0d3d6ddeeddeb74873a4c88c89
parent48b026e7500c5f7239e173d14d09b9e2e272e874 (diff)
downloadmupdf-211234411c68f4578c3bbfafeb84e8d26040443a.tar.xz
Add fz_lookup_cjk_font_by_name to create builtin CJK fonts.
-rw-r--r--docs/manual-mutool-run.html1
-rw-r--r--include/mupdf/fitz/font.h1
-rw-r--r--source/fitz/noto.c9
-rw-r--r--source/tools/murun.c2
4 files changed, 13 insertions, 0 deletions
diff --git a/docs/manual-mutool-run.html b/docs/manual-mutool-run.html
index c1fe6237..f9fcf976 100644
--- a/docs/manual-mutool-run.html
+++ b/docs/manual-mutool-run.html
@@ -500,6 +500,7 @@ Times-Roman, Times-Italic, Times-Bold, Times-BoldItalic,
Helvetica, Helvetica-Oblique, Helvetica-Bold, Helvetica-BoldOblique,
Courier, Courier-Oblique, Courier-Bold, Courier-BoldOblique,
Symbol, and ZapfDingbats.
+<br>The built-in CJK fonts are referenced by language code: zh-Hant, zh-Hans, ja, ko.
<dt>Font#getName()
<dd>Get the font name.
<dt>Font#encodeCharacter(unicode)
diff --git a/include/mupdf/fitz/font.h b/include/mupdf/fitz/font.h
index d9a5f7b2..4565983c 100644
--- a/include/mupdf/fitz/font.h
+++ b/include/mupdf/fitz/font.h
@@ -290,6 +290,7 @@ const unsigned char *fz_lookup_icc(fz_context *ctx, enum fz_colorspace_type name
Returns a pointer to the font file data, or NULL if not present.
*/
const unsigned char *fz_lookup_cjk_font(fz_context *ctx, int ordering, int *len, int *index);
+const unsigned char *fz_lookup_cjk_font_by_language(fz_context *ctx, const char *lang, int *size, int *subfont);
/*
fz_lookup_cjk_ordering_by_language: Return the matching FZ_ADOBE_* ordering
diff --git a/source/fitz/noto.c b/source/fitz/noto.c
index c3eea9d6..7ab62488 100644
--- a/source/fitz/noto.c
+++ b/source/fitz/noto.c
@@ -177,6 +177,15 @@ fz_lookup_cjk_ordering_by_language(const char *name)
}
const unsigned char *
+fz_lookup_cjk_font_by_language(fz_context *ctx, const char *lang, int *size, int *subfont)
+{
+ int ordering = fz_lookup_cjk_ordering_by_language(lang);
+ if (ordering >= 0)
+ return fz_lookup_cjk_font(ctx, ordering, size, subfont);
+ return *size = 0, *subfont = 0, NULL;
+}
+
+const unsigned char *
fz_lookup_noto_font(fz_context *ctx, int script, int language, int *size, int *subfont)
{
/* TODO: Noto(SansSyriacEstrangela); */
diff --git a/source/tools/murun.c b/source/tools/murun.c
index 961d6a7a..0f8be8f3 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -2357,6 +2357,8 @@ static void ffi_new_Font(js_State *J)
fz_try(ctx) {
data = fz_lookup_base14_font(ctx, name, &size);
+ if (!data)
+ data = fz_lookup_cjk_font_by_language(ctx, name, &size, &index);
if (data)
font = fz_new_font_from_memory(ctx, name, data, size, index, 0);
else