diff options
author | keith <keith@FreeBSD.org> | 2000-11-28 02:00:45 +0800 |
---|---|---|
committer | keith <keith@FreeBSD.org> | 2000-11-28 02:00:45 +0800 |
commit | a1cd169a8c24b0614e10ff73f8569867c85541ec (patch) | |
tree | 170c4264ce5bc86e3fd8e744e808a74f0fb0c03f | |
parent | 0692f81b3bbe6ce33778ed1eff680c8e61fd1298 (diff) | |
download | freebsd-ports-gnome-a1cd169a8c24b0614e10ff73f8569867c85541ec.tar.gz freebsd-ports-gnome-a1cd169a8c24b0614e10ff73f8569867c85541ec.tar.zst freebsd-ports-gnome-a1cd169a8c24b0614e10ff73f8569867c85541ec.zip |
Initial version.
This port adds Chinese support to enscript, which means it can convert
a BIG5/CNS plain text to a PS document, with all the fancy features
provided by enscript. Unlike bg5ps, it can't manage GB yet, but it's
easy to add. Another useful feature is with the ps2pdf and zh-ghostscript6,
it is now possible to generate font-embedded Chinese pdf document from
plain text on the fly, which also means platform-independent.
Due to some problems in the CMap files provided by Adobe, Eten-B5-H and
B5-H CMaps are unable to map correct ascii glyphs in TTFs. BIG5 users
are suggested to use B5pc-H for the time being.
Maybe it's time to re-organize ports/chinese/* font relationships.
-rw-r--r-- | chinese/enscript/Makefile | 29 | ||||
-rw-r--r-- | chinese/enscript/files/README.BIG5 | 13 | ||||
-rw-r--r-- | chinese/enscript/files/patch-aa | 268 | ||||
-rw-r--r-- | chinese/enscript/files/patch-ab | 11 | ||||
-rw-r--r-- | chinese/enscript/pkg-message | 7 |
5 files changed, 328 insertions, 0 deletions
diff --git a/chinese/enscript/Makefile b/chinese/enscript/Makefile new file mode 100644 index 000000000000..44f80939b367 --- /dev/null +++ b/chinese/enscript/Makefile @@ -0,0 +1,29 @@ +# New ports collection makefile for: zh Big5/GB-izedenscript (a4) +# Date created: 27 Nov, 2000 +# Whom: Jing-Tang Keith Jang <keith@FreeBSD.org> +# +# $FreeBSD$ +# + +PAPERSIZE= a4 +MASTERDIR= ${.CURDIR}/../../print/enscript-letter + +MAINTAINER= keith@FreeBSD.org + +RUN_DEPENDS= ttfm.sh:${PORTSDIR}/chinese/ttfm \ + ${LOCALBASE}/share/ghostscript/CJK/CMap/ac13/cid2code.txt:${PORTSDIR}/chinese/ghostscript6 + +EXTRA_PATCHES= ${.CURDIR}/files/patch-* +PLIST= ${WRKDIR}/pkg-plist +PKGMESSAGE= ${.CURDIR}/pkg-message + +post-patch: + @${ECHO} "share/enscript/README.BIG5" > ${WRKDIR}/pkg-plist + @${CAT} ${MASTERDIR}/pkg-plist >> ${WRKDIR}/pkg-plist + +do-install: + @(cd ${INSTALL_WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} ${INSTALL_TARGET}) + @${INSTALL_DATA} ${.CURDIR}/files/README.BIG5 ${PREFIX}/share/enscript + @${CAT} ${PKGMESSAGE} + +.include "${MASTERDIR}/Makefile" diff --git a/chinese/enscript/files/README.BIG5 b/chinese/enscript/files/README.BIG5 new file mode 100644 index 000000000000..9c4ed0d21d05 --- /dev/null +++ b/chinese/enscript/files/README.BIG5 @@ -0,0 +1,13 @@ +Sept. 9 2000: + +This version of enscript is patched by Chen-Shan Chin +(cschin@u.washington.edu) to support BIG5 and UniCNS-UTF8 +encoded text file. Two new encoding name "big5" and +"UniCNS-UTF8" are added. Since there is no easy way to +get AFM for CJK CID-font, I simply assign the width for +the same for all character. + +You need to have a CID-font for these encoding to use +this function. + +Chen-Shan Chin diff --git a/chinese/enscript/files/patch-aa b/chinese/enscript/files/patch-aa new file mode 100644 index 000000000000..98321c177486 --- /dev/null +++ b/chinese/enscript/files/patch-aa @@ -0,0 +1,268 @@ +--- ./src/gsint.h.orig Thu Jun 25 15:18:32 1998 ++++ ./src/gsint.h Mon Nov 27 22:18:18 2000 +@@ -188,7 +188,9 @@ + ENC_VMS, + ENC_HP8, + ENC_KOI8, +- ENC_PS ++ ENC_PS, ++ ENC_BIG5, ++ ENC_UNICNS_UTF8, + } InputEncoding; + + typedef enum +--- ./src/main.c.orig Thu Jun 25 16:26:00 1998 ++++ ./src/main.c Mon Nov 27 22:18:18 2000 +@@ -864,7 +864,8 @@ + {{"koi8", NULL, NULL}, ENC_KOI8, '\n', 8}, + {{"ps", "PS", NULL}, ENC_PS, '\n', 8}, + {{"pslatin1", "ISOLatin1Encoding", NULL}, ENC_ISO_8859_1, '\n', 8}, +- ++ {{"big5", "Formal Chinese", NULL}, ENC_BIG5, '\n', 8}, ++ {{"UniCNS-UTF8", "Formal Chinese", NULL}, ENC_UNICNS_UTF8, '\n', 8}, + {{NULL, NULL, NULL}, 0, 0, 0}, + }; + +--- ./src/psgen.c.orig Thu Jun 25 15:18:54 1998 ++++ ./src/psgen.c Mon Nov 27 22:18:18 2000 +@@ -303,15 +303,22 @@ + if (!paste_file ("enscript", ".pro")) + FATAL ((stderr, _("couldn't find prolog \"%s\": %s\n"), "enscript.pro", + strerror (errno))); ++ if (encoding == ENC_BIG5 || encoding == ENC_UNICNS_UTF8) ++ { /*overwrite the defintion of MF for CJK */ ++ OUTPUT((cofp, "/MF {exch findfont definefont pop} def\n")); ++ } + OUTPUT ((cofp, "%%%%EndResource\n")); + + /* Encoding vector. */ +- OUTPUT ((cofp, "%%%%BeginResource: procset Enscript-Encoding-%s %s\n", +- encoding_name, ps_version_string)); +- if (!paste_file (encoding_name, ".enc")) +- FATAL ((stderr, _("couldn't find encoding file \"%s.enc\": %s\n"), +- encoding_name, strerror (errno))); +- OUTPUT ((cofp, "%%%%EndResource\n")); ++ if (encoding != ENC_BIG5 && encoding != ENC_UNICNS_UTF8) { ++ OUTPUT ((cofp, "%%%%BeginResource: procset Enscript-Encoding-%s %s\n", ++ encoding_name, ps_version_string)); ++ if (!paste_file (encoding_name, ".enc")) ++ FATAL ((stderr, _("couldn't find encoding file \"%s.enc\": %s\n"), ++ encoding_name, strerror (errno))); ++ OUTPUT ((cofp, "%%%%EndResource\n")); ++ } ++ + + OUTPUT ((cofp, "%%%%EndProlog\n")); + +@@ -339,6 +346,7 @@ + /* Select our fonts. */ + + /* Header font HF. */ ++ + OUTPUT ((cofp, "/%s /HF-gs-font MF\n", HFname)); + OUTPUT ((cofp, + "/HF /HF-gs-font findfont [HFpt_w 0 0 HFpt_h 0 0] makefont def\n")); +@@ -1033,7 +1041,12 @@ + /* Help macros. */ + + /* Check if character <ch> fits to current line. */ +-#define FITS_ON_LINE(ch) ((linepos + CHAR_WIDTH (ch) < linew) || col == 0) ++/* NO wraping for CJK at this moment. Added by C.S. Chin Sept.1 */ ++ ++#define FITS_ON_LINE(ch) ( ( (encoding == ENC_BIG5 && b5firstc) ||\ ++ (encoding == ENC_UNICNS_UTF8 && u8firstc) ) ?\ ++ (linepos + 2 * CHAR_WIDTH (ch) < linew) :\ ++ (linepos + CHAR_WIDTH (ch) < linew || in_u8) ) + + /* Is line buffer empty? */ + #define BUFFER_EMPTY() (bufpos == 0) +@@ -1473,8 +1486,12 @@ + static unsigned int buflen = 0; /* output buffer's length */ + unsigned int bufpos = 0; /* current position in output buffer */ + int ch = 0; ++ int ch2 = 0; + int done = 0; + int i; ++ int b5firstc = 0; ++ int u8firstc = 0; ++ int in_u8 = 0; + static int pending_token = tNONE; + unsigned int original_col = col; + +@@ -1624,6 +1641,39 @@ + break; + } + ++ /*Check for big5 characters*/ ++ if (encoding == ENC_BIG5) ++ { ++ if (ch >= 161 && ch <= 249 && b5firstc == 0) ++ { ++ ch2 = is_getc (is); ++ if ((ch2 >= 161 && ch2 <=254) || (ch2 >=64 && ch2 <= 126)) /*big5 char*/ ++ { ++ b5firstc = 1; ++ } else { ++ b5firstc = 0; ++ } ++ is_ungetc(ch2, is); ++ } else { ++ b5firstc = 0; ++ } ++ } ++ ++ /*Check for utf8 character*/ ++ if (encoding == ENC_UNICNS_UTF8) ++ { ++ if (ch >= 0340 && u8firstc==0) { ++ u8firstc = 1; ++ } else { ++ u8firstc = 0; ++ } ++ if (ch >= 0200) { ++ in_u8 = 1; ++ } else { ++ in_u8 = 0; ++ } ++ } ++ + /* Check normal characters. */ + if (EXISTS (ch)) + { +@@ -1741,7 +1791,7 @@ + /* Got a string. */ + + /* Check for wrapped line. */ +- if (done == DONE_WRAP) ++ if (done == DONE_WRAP) + { + /* This line is too long. */ + ch = nl; +--- ./src/util.c.orig Wed Jun 24 14:48:21 1998 ++++ ./src/util.c Mon Nov 27 22:18:18 2000 +@@ -774,6 +774,7 @@ + if (!strhash_get (afm_cache, Fname, strlen (Fname), (void **) &font)) + { + /* AFM file was not cached, open it from disk. */ ++ + error = afm_open_font (afm, AFM_I_COMPOSITES, Fname, &font); + if (error != AFM_SUCCESS) + { +@@ -782,11 +783,18 @@ + * Do not report failures for "Courier*" fonts because + * AFM library's default font will fix them. + */ +- if (strncmp (Fname, COUR, strlen (COUR)) != 0) +- MESSAGE (0, +- (stderr, +- _("couldn't open AFM file for font \"%s\", using default\n"), +- Fname)); ++ if (strncmp (Fname, COUR, strlen (COUR)) != 0) { ++ if (encoding == ENC_BIG5 || encoding == ENC_UNICNS_UTF8) ++ { MESSAGE(0, ++ (stderr, ++ _("CJK encoding, ignore AFM file, use default.\n"),Fname)); ++ } else { ++ MESSAGE (0, ++ (stderr, ++ _("couldn't open AFM file for font \"%s\", using default\n"), ++ Fname)); ++ } ++ } + error = afm_open_default_font (afm, &font); + if (error != AFM_SUCCESS) + { +@@ -796,7 +804,7 @@ + buf)); + } + } +- ++ + /* Apply encoding. */ + switch (encoding) + { +@@ -879,6 +887,12 @@ + case ENC_PS: + /* Let's use font's default encoding -- nothing here. */ + break; ++ case ENC_BIG5: ++ /* CJK encoding, ignore AFM, added by C.S.Chin Aug.31 00 */ ++ break; ++ case ENC_UNICNS_UTF8: ++ /* CJK encoding, ignore AFM, added by C.S.Chin Aug.31 00 */ ++ break; + } + + /* Put it to the AFM cache. */ +@@ -888,20 +902,57 @@ + + font_info = (CachedFontInfo *) xcalloc (1, sizeof (*font_info)); + /* Read character widths and types. */ +- for (i = 0; i < 256; i++) +- { +- AFMNumber w0x, w0y; +- +- (void) afm_font_charwidth (font, Fpt.w, i, &w0x, &w0y); +- font_info->font_widths[i] = w0x; +- +- if (font->encoding[i] == AFM_ENC_NONE) +- font_info->font_ctype[i] = ' '; +- else if (font->encoding[i] == AFM_ENC_NON_EXISTENT) +- font_info->font_ctype[i] = '.'; +- else +- font_info->font_ctype[i] = '*'; +- } ++ if (encoding != ENC_BIG5 && encoding != ENC_UNICNS_UTF8) { ++ for (i = 0; i < 256; i++) ++ { ++ AFMNumber w0x, w0y; ++ ++ (void) afm_font_charwidth (font, Fpt.w, i, &w0x, &w0y); ++ font_info->font_widths[i] = w0x; ++ ++ if (font->encoding[i] == AFM_ENC_NONE) ++ font_info->font_ctype[i] = ' '; ++ else if (font->encoding[i] == AFM_ENC_NON_EXISTENT) ++ font_info->font_ctype[i] = '.'; ++ else ++ font_info->font_ctype[i] = '*'; ++ } ++ } else { ++ if (encoding == ENC_BIG5) ++ { ++ for (i = 0; i < 256; i++) ++ { ++ AFMNumber w0x, w0y; ++ if ( i < 040 ) ++ { ++ font_info->font_widths[i] = Fpt.w * 0.525; ++ font_info->font_ctype[i] = ' '; ++ } else { ++ font_info->font_widths[i] = Fpt.w * 0.525; ++ font_info->font_ctype[i] = '*'; ++ } ++ } ++ } else { ++ /*UTF8*/ ++ for (i = 0; i < 256; i++) ++ { ++ AFMNumber w0x, w0y; ++ if ( i < 040 ) ++ { ++ font_info->font_widths[i] = Fpt.w * 0.525; ++ font_info->font_ctype[i] = ' '; ++ } else { ++ if (i >= 0200) { ++ font_info->font_widths[i] = Fpt.w * 0.525 * 2.0 / 3.0; ++ } else { ++ font_info->font_widths[i] = Fpt.w * 0.525; ++ } ++ font_info->font_ctype[i] = '*'; ++ } ++ } ++ } ++ } ++ + + font_info->font_is_fixed + = font->writing_direction_metrics[0].IsFixedPitch; diff --git a/chinese/enscript/files/patch-ab b/chinese/enscript/files/patch-ab new file mode 100644 index 000000000000..d3d0793a4907 --- /dev/null +++ b/chinese/enscript/files/patch-ab @@ -0,0 +1,11 @@ +--- lib/enscript.cfg.in.orig Mon Nov 27 22:26:17 2000 ++++ lib/enscript.cfg.in Mon Nov 27 22:39:04 2000 +@@ -42,7 +42,7 @@ + Clean7Bit: 1 + + # Default input encoding. +-DefaultEncoding: latin1 ++DefaultEncoding: big5 + + # Default fancy header. + DefaultFancyHeader: enscript diff --git a/chinese/enscript/pkg-message b/chinese/enscript/pkg-message new file mode 100644 index 000000000000..8ab61d34c70b --- /dev/null +++ b/chinese/enscript/pkg-message @@ -0,0 +1,7 @@ +======================================================================== +For BIG5 users, use commands like this to generate PS documents: + +enscript -X big5 -f DefaultMingB5-Regular-B5pc-H@12 -o [output.ps] [file] + +Make sure to use those fonts having "B5pc" in their names. +======================================================================== |