From 9dc58cc827521b11d4eb8e2dd14e7e26bef74edb Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 31 Mar 2016 15:32:38 +0200 Subject: epub: Add stripped Charis SIL font to use as the default font for EPUB. --- source/fitz/noto.c | 12 ++++++++++++ source/html/html-font.c | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/fitz/noto.c b/source/fitz/noto.c index 1ac6e6c6..c428c324 100644 --- a/source/fitz/noto.c +++ b/source/fitz/noto.c @@ -4,6 +4,7 @@ Base 14 PDF fonts from URW. Noto fonts from Google. DroidSansFallback from Android for CJK. + Charis SIL from SIL. Define TOFU to skip all the Noto fonts except CJK. @@ -13,6 +14,7 @@ Define TOFU_EMOJI to skip emoji font. Define TOFU_HISTORIC to skip ancient/historic scripts. Define TOFU_SYMBOL to skip symbol font. + Define TOFU_SIL to skip the SIL fonts. */ #ifdef NOTO_SMALL @@ -20,6 +22,7 @@ #define TOFU_EMOJI #define TOFU_HISTORIC #define TOFU_SYMBOL +#define TOFU_SIL #endif #ifdef NOCJK @@ -30,6 +33,7 @@ #define TOFU_EMOJI #define TOFU_HISTORIC #define TOFU_SYMBOL +#define TOFU_SIL #endif #define RETURN(NAME) \ @@ -85,6 +89,14 @@ fz_lookup_builtin_font(fz_context *ctx, const char *name, int is_bold, int is_it NimbusRomNo9L_Med_cff, NimbusRomNo9L_MedIta_cff) } +#ifndef TOFU_SIL + if (!strcmp(name, "Charis SIL")) { + FAMILY(CharisSIL_R_cff, + CharisSIL_I_cff, + CharisSIL_B_cff, + CharisSIL_BI_cff) + } +#endif #ifndef TOFU if (!strcmp(name, "Noto Serif")) { RETURN(NotoSerif_Regular_ttf); diff --git a/source/html/html-font.c b/source/html/html-font.c index 389ddb34..3b8f7c72 100644 --- a/source/html/html-font.c +++ b/source/html/html-font.c @@ -5,7 +5,8 @@ fz_load_html_default_font(fz_context *ctx, fz_html_font_set *set, const char *fa { int is_mono = !strcmp(family, "monospace"); int is_sans = !strcmp(family, "sans-serif"); - const char *real_family = is_mono ? "Courier" : is_sans ? "Helvetica" : "Times"; + const char *real_family = is_mono ? "Courier" : is_sans ? "Helvetica" : "Charis SIL"; + const char *backup_family = is_mono ? "Courier" : is_sans ? "Helvetica" : "Times"; int idx = (is_mono ? 8 : is_sans ? 4 : 0) + is_bold * 2 + is_italic; if (!set->fonts[idx]) { @@ -13,6 +14,8 @@ fz_load_html_default_font(fz_context *ctx, fz_html_font_set *set, const char *fa int size; data = fz_lookup_builtin_font(ctx, real_family, is_bold, is_italic, &size); + if (!data) + data = fz_lookup_builtin_font(ctx, backup_family, is_bold, is_italic, &size); if (!data) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot load html font: %s", real_family); set->fonts[idx] = fz_new_font_from_memory(ctx, NULL, data, size, 0, 1); -- cgit v1.2.3