From 211234411c68f4578c3bbfafeb84e8d26040443a Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 19 Sep 2018 13:20:01 +0200 Subject: Add fz_lookup_cjk_font_by_name to create builtin CJK fonts. --- source/fitz/noto.c | 9 +++++++++ source/tools/murun.c | 2 ++ 2 files changed, 11 insertions(+) (limited to 'source') 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 @@ -176,6 +176,15 @@ fz_lookup_cjk_ordering_by_language(const char *name) return -1; } +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) { 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 -- cgit v1.2.3