From f329dcd69f4fb827f696adb13eefe0348482833f Mon Sep 17 00:00:00 2001 From: Sambhav Dusad Date: Tue, 4 Feb 2020 02:30:07 +0530 Subject: [PATCH] added support for CJK fonts --- charset/pdf.utf-8.simple | 1 + filter/texttopdf.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/charset/pdf.utf-8.simple b/charset/pdf.utf-8.simple index 1280f25c8..f7d3adf71 100644 --- a/charset/pdf.utf-8.simple +++ b/charset/pdf.utf-8.simple @@ -30,3 +30,4 @@ charset utf8 0000 04FF ltor single monospace monospace:bold monospace:oblique monospace:bold:oblique 0500 05FF rtol single monospace +3000 9FFF ltor double ARPLUmingCN diff --git a/filter/texttopdf.c b/filter/texttopdf.c index 55a8309ca..50a0876c9 100644 --- a/filter/texttopdf.c +++ b/filter/texttopdf.c @@ -39,9 +39,9 @@ int UTF8 = 1; /* Use UTF-8 encoding? */ #endif /* CUPS_1_4 */ -EMB_PARAMS *font_load(const char *font); +EMB_PARAMS *font_load(const char *font, int fontwidth); -EMB_PARAMS *font_load(const char *font) +EMB_PARAMS *font_load(const char *font, int fontwidth) { OTF_FILE *otf; @@ -74,7 +74,7 @@ EMB_PARAMS *font_load(const char *font) FcPatternGetString (candidates->fonts[i], FC_FONTFORMAT, 0, &fontformat); FcPatternGetInteger (candidates->fonts[i], FC_SPACING, 0, &spacing); - if ( (fontformat)&&(spacing == FC_MONO) ) { + if ( (fontformat)&&((spacing == FC_MONO) || (fontwidth == 2)) ) { // check for monospace or double width fonts if (strcmp((const char *)fontformat, "TrueType") == 0) { fontname = FcPatternFormat (candidates->fonts[i], (const FcChar8 *)"%{file|cescape}/%{index}"); break; @@ -554,7 +554,7 @@ WriteProlog(const char *title, /* I - Title of job */ } if (k==num_fonts) { // not found - fonts[num_fonts] = Fonts[NumFonts][i] = font_load(valptr); + fonts[num_fonts] = Fonts[NumFonts][i] = font_load(valptr, Widths[NumFonts]); if (!fonts[num_fonts]) { // font missing/corrupt, replace by first fprintf(stderr,"WARNING: Ignored bad font \"%s\"\n",valptr); break; @@ -738,7 +738,7 @@ WriteProlog(const char *title, /* I - Title of job */ } if (k==num_fonts) { // not found - fonts[num_fonts] = Fonts[NumFonts][i] = font_load(valptr); + fonts[num_fonts] = Fonts[NumFonts][i] = font_load(valptr, Widths[NumFonts]); if (!fonts[num_fonts]) { // font missing/corrupt, replace by first fprintf(stderr,"WARNING: Ignored bad font \"%s\"\n",valptr); break; -- 2.47.2