summaryrefslogtreecommitdiffstats
path: root/print/ghostscript7
diff options
context:
space:
mode:
authorlinimon <linimon@FreeBSD.org>2004-05-28 02:55:46 +0000
committerlinimon <linimon@FreeBSD.org>2004-05-28 02:55:46 +0000
commitc4d10f747d68e04fcc6a8007bb4e56210885109c (patch)
tree1752d96c812cb1ffcbfd72eb18ff744205434ae3 /print/ghostscript7
parent3d77e7d301880b420fc9a26419557329ebc036a0 (diff)
downloadFreeBSD-ports-c4d10f747d68e04fcc6a8007bb4e56210885109c.zip
FreeBSD-ports-c4d10f747d68e04fcc6a8007bb4e56210885109c.tar.gz
Handle NeverEmbed CJK TrueType into PDF, and write correct glyph widths
of CJK TrueType into PDF, and do not write CIDToGIDMap of NeverEmbed CJK TrueType and Encoding of CIDFont into PDF. PR: ports/62078 Submitted by: KOMATSU Shinichiro <koma2 at jiro dot c dot u-tokyo dot ac dot jp> Reviewed by: KATO Tsuguru <jungle at m8 dot dion dot ne dot jp>
Diffstat (limited to 'print/ghostscript7')
-rw-r--r--print/ghostscript7/files/patch-lib:gs_cidfn.ps51
-rw-r--r--print/ghostscript7/files/patch-lib:ps2pdfwr173
-rw-r--r--print/ghostscript7/files/patch-src:gdevpdff.c59
-rw-r--r--print/ghostscript7/files/patch-src:gdevpdff.h37
-rw-r--r--print/ghostscript7/files/patch-src:gdevpdfs.c41
-rw-r--r--print/ghostscript7/files/patch-src:gdevpdfw.c60
6 files changed, 421 insertions, 0 deletions
diff --git a/print/ghostscript7/files/patch-lib:gs_cidfn.ps b/print/ghostscript7/files/patch-lib:gs_cidfn.ps
new file mode 100644
index 0000000..98a763b
--- /dev/null
+++ b/print/ghostscript7/files/patch-lib:gs_cidfn.ps
@@ -0,0 +1,51 @@
+--- lib/gs_cidfn.ps.org 2003-04-12 23:02:38.000000000 +0900
++++ lib/gs_cidfn.ps 2003-09-03 07:28:28.000000000 +0900
+@@ -511,9 +511,32 @@
+
+ .loadinitialcidfonts
+
++% <fontname> <font> .RenameFontForNeverEmbed <fontname> <font'>
++/.RenameFontForNeverEmbed {
++ /DEVICE where { pop DEVICE (pdfwrite) eq {
++ currentdistillerparams /NeverEmbed get {
++ 2 index eq {
++ (*** unembeddable CIDFont: ) print 1 index == flush
++ dup length 1 add dict copy
++ dup /FID undef
++ dup /.orig_CIDFontName 1 index /CIDFontName get put
++ dup /CIDFontName 3 index dup type /stringtype eq {
++ dup rcheck {
++ dup length string 0 1 2 index length 1 sub {
++ 2 index 1 index get 3 copy put pop pop
++ } for exch pop
++ } if
++ } if put
++ dup /FontName 1 index /CIDFontName get put
++ } if
++ } forall
++ } if } if
++} bind def
++
+ /CIDFontmapHandler <<
+ /nametype {
+ /CIDFont findresource
++ .RenameFontForNeverEmbed
+ /CIDFont defineresource pop
+ } bind
+ /stringtype {
+@@ -528,6 +551,7 @@
+ pop pop
+ } {
+ % Give a name different from the name defined in the file
++ .RenameFontForNeverEmbed
+ /CIDFont defineresource pop
+ } ifelse
+ } {
+@@ -546,6 +570,7 @@
+ 3 -1 roll put
+ % Expand array
+ aload pop .loadcjkvttcidfont
++ .RenameFontForNeverEmbed
+ /CIDFont defineresource pop
+ } {
+ /undefinedresource signalerror
diff --git a/print/ghostscript7/files/patch-lib:ps2pdfwr b/print/ghostscript7/files/patch-lib:ps2pdfwr
new file mode 100644
index 0000000..ef2b946
--- /dev/null
+++ b/print/ghostscript7/files/patch-lib:ps2pdfwr
@@ -0,0 +1,173 @@
+--- lib/ps2pdfwr.org 2003-09-01 18:39:30.000000000 +0900
++++ lib/ps2pdfwr 2003-09-25 18:39:14.000000000 +0900
+@@ -31,6 +31,169 @@
+ outfile="$2"
+ fi
+
++[ "$NeverEmbedFontList" != "" ] || NeverEmbedFontList="
++/Courier
++/Courier-Bold
++/Courier-BoldOblique
++/Courier-Oblique
++/Helvetica
++/Helvetica-Bold
++/Helvetica-BoldOblique
++/Helvetica-Oblique
++/Symbol
++/Times-Bold
++/Times-BoldItalic
++/Times-Italic
++/Times-Roman
++/ZapfDingbats
++"
++[ "$AlwaysEmbedFontList" != "" ] || AlwaysEmbedFontList="
++/AvantGarde-Book
++/AvantGarde-BookOblique
++/AvantGarde-Demi
++/AvantGarde-DemiOblique
++/Bookman-Demi
++/Bookman-DemiItalic
++/Bookman-Light
++/Bookman-LightItalic
++/Helvetica-Narrow
++/Helvetica-Narrow-Bold
++/Helvetica-Narrow-BoldOblique
++/Helvetica-Narrow-Oblique
++/Palatino-Bold
++/Palatino-BoldItalic
++/Palatino-Italic
++/Palatino-Roman
++/ZapfChancery-MediumItalic
++
++/Arial-BoldItalicMT
++/Arial-BoldMT
++/Arial-ItalicMT
++/ArialMT
++/ArialNarrow
++/ArialNarrow-Bold
++/ArialNarrow-BoldItalic
++/ArialNarrow-Italic
++/BookmanOldStyle
++/BookmanOldStyle-Bold
++/BookmanOldStyle-BoldItalic
++/BookmanOldStyle-Italic
++/CenturyGothic
++/CenturyGothic-Bold
++/CenturyGothic-BoldItalic
++/CenturyGothic-Italic
++/CourierNewPS-BoldItalicMT
++/CourierNewPS-BoldMT
++/CourierNewPS-ItalicMT
++/CourierNewPSMT
++/NewCenturySchlbk-Bold
++/NewCenturySchlbk-BoldItalic
++/NewCenturySchlbk-Italic
++/NewCenturySchlbk-Roman
++/PalatinoLinotype-Bold
++/PalatinoLinotype-BoldItalic
++/PalatinoLinotype-Italic
++/PalatinoLinotype-Roman
++/TimesNewRomanPS-BoldItalicMT
++/TimesNewRomanPS-BoldMT
++/TimesNewRomanPS-ItalicMT
++/TimesNewRomanPSMT
++"
++[ "$NeverEmbedCIDFontList" != "" ] || NeverEmbedCIDFontList="
++/MSung-Light
++/MSung-Medium
++/MHei-Medium
++/MKai-Medium
++/STSong-Light
++/STFangsong-Light
++/STHeiti-Regular
++/STKaiti-Regular
++/Ryumin-Light
++/GothicBBB-Medium
++/HeiseiMin-W3
++/HeiseiKakuGo-W5
++/KozMin-Regular
++/HYGoThic-Medium
++/HYGungSo-Bold
++/HYKHeadLine-Bold
++/HYKHeadLine-Medium
++/HYSMyeongJo-Medium
++/HYRGoThic-Medium
++
++/MOEKai-Regular
++/MOESung-Regular
++/WadaGo-Bold
++/WadaMaruGo-Regular
++/WadaMaruGo-RegularH
++/WadaMin-Bold
++/WadaMin-Regular
++/WadaMin-RegularH
++/Munhwa-Bold
++/Munhwa-Regular
++/MunhwaGothic-Bold
++/MunhwaGothic-Regular
++/MunhwaGungSeo-Bold
++/MunhwaGungSeo-Light
++/MunhwaGungSeoHeulim-Bold
++/MunhwaGungSeoHeulim-Light
++/MunhwaHoonMin-Regular
++
++/MingLiU
++/PMingLiU
++/SimHei
++/SimSun
++/NSimSun
++/HGGothicE
++/HGGothicEPRO
++/HGGothicM
++/HGGyoshotai
++/HGMarugothicMPRO
++/HGPGothicE
++/HGPGothicM
++/HGPGyoshotai
++/HGPSoeiKakugothicUB
++/HGPSoeiKakupoptai
++/HGSGothicE
++/HGSGothicM
++/HGSGyoshotai
++/HGSSoeiKakugothicUB
++/HGSSoeiKakupoptai
++/HGSeikaishotaiPRO
++/HGSoeiKakugothicUB
++/HGSoeiKakupoptai
++/Kochi-Gothic
++/Kochi-Mincho
++/MojikumiKata-EB
++/Mona
++/MS-Mincho
++/MS-PMincho
++/MS-Gothic
++/MS-PGothic
++/MS-UIGothic
++/Batang
++/BatangChe
++/Gungsuh
++/GungsuhChe
++/Gulim
++/GulimChe
++/Dotum
++/DotumChe
++/New-Gulim
++
++/MHei-Medium-Acro
++/MSung-Light-Acro
++/STSong-Light-Acro
++/HeiseiKakuGo-W5-Acro
++/HeiseiMin-W3-Acro
++/HYGoThic-Medium-Acro
++/HYSMyeongJo-Medium-Acro
++"
++[ "$AlwaysEmbedCIDFontList" != "" ] || AlwaysEmbedCIDFontList="
++/SimSun-18030-Adobe-CNS1
++/NSimSun-18030-Adobe-CNS1
++/SimSun-18030
++/NSimSun-18030
++"
+ # We have to include the options twice because -I only takes effect if it
+ # appears before other options.
+-exec gs $OPTIONS -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "-sOutputFile=$outfile" $OPTIONS -c .setpdfwrite -f "$infile"
++exec gs $OPTIONS -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "-sOutputFile=$outfile" $OPTIONS -c ".setpdfwrite <</NeverEmbed [$NeverEmbedFontList $NeverEmbedCIDFontList] /AlwaysEmbed [$AlwaysEmbedFontList $AlwaysEmbedCIDFontList]>> setdistillerparams" -f "$infile"
diff --git a/print/ghostscript7/files/patch-src:gdevpdff.c b/print/ghostscript7/files/patch-src:gdevpdff.c
new file mode 100644
index 0000000..8a292bd
--- /dev/null
+++ b/print/ghostscript7/files/patch-src:gdevpdff.c
@@ -0,0 +1,59 @@
+--- src/gdevpdff.c.org 2003-01-17 09:49:02.000000000 +0900
++++ src/gdevpdff.c 2003-09-21 05:08:36.000000000 +0900
+@@ -276,6 +276,11 @@
+ const byte *chars = font->font_name.chars;
+ uint size = font->font_name.size;
+
++ /* CIDFonts has null string in font_name, key_name is used */
++ if (0 == size) {
++ chars = font->key_name.chars;
++ size = font->key_name.size;
++ }
+ /*
+ * The behavior of Acrobat Distiller changed between 3.0 (PDF 1.2),
+ * which will never embed the base 14 fonts, and 4.0 (PDF 1.3), which
+@@ -720,19 +725,22 @@
+ same &= ~FONT_SAME_METRICS;
+ break;
+ case FONT_EMBED_NO:
+- /*
+- * Per the PDF 1.3 documentation, there are only 3 BaseEncoding
+- * values allowed for non-embedded fonts. Pick one here.
+- */
+- BaseEncoding =
+- ((const gs_font_base *)base_font)->nearest_encoding_index;
+- switch (BaseEncoding) {
+- default:
+- BaseEncoding = ENCODING_INDEX_WINANSI;
+- case ENCODING_INDEX_WINANSI:
+- case ENCODING_INDEX_MACROMAN:
+- case ENCODING_INDEX_MACEXPERT:
+- break;
++ if (!(font->FontType == ft_CID_encrypted ||
++ font->FontType == ft_CID_TrueType)) {
++ /*
++ * Per the PDF 1.3 documentation, there are only 3 BaseEncoding
++ * values allowed for non-embedded fonts. Pick one here.
++ */
++ BaseEncoding =
++ ((const gs_font_base *)base_font)->nearest_encoding_index;
++ switch (BaseEncoding) {
++ default:
++ BaseEncoding = ENCODING_INDEX_WINANSI;
++ case ENCODING_INDEX_WINANSI:
++ case ENCODING_INDEX_MACROMAN:
++ case ENCODING_INDEX_MACEXPERT:
++ break;
++ }
+ }
+ code = pdf_compute_font_descriptor(pdev, &fdesc, font, NULL);
+ if (code < 0)
+@@ -888,6 +896,7 @@
+ memcpy(ppf->widths_known, ftemp_widths_known,
+ sizeof(ftemp_widths_known));
+ }
++ ppf->embed = embed;
+ code = pdf_register_font(pdev, font, ppf);
+
+ *pppf = ppf;
+
diff --git a/print/ghostscript7/files/patch-src:gdevpdff.h b/print/ghostscript7/files/patch-src:gdevpdff.h
new file mode 100644
index 0000000..f64a4e0
--- /dev/null
+++ b/print/ghostscript7/files/patch-src:gdevpdff.h
@@ -0,0 +1,37 @@
+--- src/gdevpdff.h.org 2003-01-17 09:49:02.000000000 +0900
++++ src/gdevpdff.h 2003-09-18 23:42:38.000000000 +0900
+@@ -117,6 +117,12 @@
+ FONT_SUBSET_NO
+ } pdf_font_do_subset_t;
+
++typedef enum {
++ FONT_EMBED_STANDARD, /* 14 standard fonts */
++ FONT_EMBED_NO,
++ FONT_EMBED_YES
++} pdf_font_embed_t;
++
+ struct pdf_font_descriptor_s {
+ pdf_resource_common(pdf_font_descriptor_t);
+ pdf_font_name_t FontName;
+@@ -198,6 +204,7 @@
+ gs_font *font; /* non-0 iff font will notify us; */
+ /* should be a weak pointer */
+ int index; /* in pdf_standard_fonts, -1 if not base 14 */
++ pdf_font_embed_t embed; /* status of pdf_font_embed_status() */
+ gs_matrix orig_matrix; /* FontMatrix of unscaled font for embedding */
+ bool is_MM_instance; /* for Type 1/2 fonts, true iff the font */
+ /* is a Multiple Master instance */
+@@ -320,12 +327,6 @@
+
+ /* ---------------- Exported by gdevpdff.c ---------------- */
+
+-typedef enum {
+- FONT_EMBED_STANDARD, /* 14 standard fonts */
+- FONT_EMBED_NO,
+- FONT_EMBED_YES
+-} pdf_font_embed_t;
+-
+ typedef struct pdf_standard_font_s {
+ const char *fname;
+ gs_encoding_index_t base_encoding;
+
diff --git a/print/ghostscript7/files/patch-src:gdevpdfs.c b/print/ghostscript7/files/patch-src:gdevpdfs.c
new file mode 100644
index 0000000..0378f15
--- /dev/null
+++ b/print/ghostscript7/files/patch-src:gdevpdfs.c
@@ -0,0 +1,41 @@
+--- src/gdevpdfs.c.org 2003-09-20 00:11:16.000000000 +0900
++++ src/gdevpdfs.c 2003-09-25 17:44:10.000000000 +0900
+@@ -481,15 +481,21 @@
+
+ if (cid < pfd->chars_count) {
+ int index = cid >> 3, mask = 0x80 >> (cid & 7);
++ int gid;
++
++ if (!(pfd->chars_used.data[index] & mask) ||
++ !(psubf->widths_known[index] & mask)) {
+
+- if (!(pfd->chars_used.data[index] & mask)) {
+- pfd->chars_used.data[index] |= mask;
+ if (psubf->CIDToGIDMap) {
+ gs_font_cid2 *const subfont2 =
+ (gs_font_cid2 *)subfont;
+- int gid =
+- subfont2->cidata.CIDMap_proc(subfont2, glyph);
+
++ gid = subfont2->cidata.CIDMap_proc(subfont2, glyph);
++ }
++ }
++ if (!(pfd->chars_used.data[index] & mask)) {
++ pfd->chars_used.data[index] |= mask;
++ if (psubf->CIDToGIDMap) {
+ if (gid >= 0) {
+ psubf->CIDToGIDMap[cid] = gid;
+ mark_glyphs_used(subfont, gid + gs_min_cid_glyph,
+@@ -500,7 +506,11 @@
+ if (!(psubf->widths_known[index] & mask)) {
+ int width;
+
+- code = pdf_glyph_width(psubf, glyph, subfont, &width);
++ if (psubf->CIDToGIDMap)
++ code = pdf_glyph_width(psubf, gid + gs_min_cid_glyph,
++ subfont, &width);
++ else
++ code = pdf_glyph_width(psubf, glyph, subfont, &width);
+ if (code == 0) {
+ psubf->Widths[cid] = width;
+ psubf->widths_known[index] |= mask;
diff --git a/print/ghostscript7/files/patch-src:gdevpdfw.c b/print/ghostscript7/files/patch-src:gdevpdfw.c
new file mode 100644
index 0000000..a08b87d
--- /dev/null
+++ b/print/ghostscript7/files/patch-src:gdevpdfw.c
@@ -0,0 +1,60 @@
+--- src/gdevpdfw.c.org 2003-01-17 09:49:02.000000000 +0900
++++ src/gdevpdfw.c 2003-09-25 17:50:54.000000000 +0900
+@@ -348,18 +348,19 @@
+ /* Use the most common width as DW. */
+
+ {
+- ushort counts[1001];
++ ushort counts[1500*2]; /* histogram of (-1500..1500) */
+ int dw_count = 0, i;
+
+ memset(counts, 0, sizeof(counts));
+ while (!psf_enumerate_glyphs_next(&genum, &glyph)) {
+- int width = ppf->Widths[glyph - gs_min_cid_glyph];
++ int cid = glyph - gs_min_cid_glyph;
++ int width = ppf->Widths[cid];
+
+- counts[min(width, countof(counts) - 1)]++;
++ counts[max(0,min(width+countof(counts)/2,countof(counts)-1))]++;
+ }
+- for (i = 0; i < countof(counts); ++i)
++ for (i = 0; i < countof(counts); i++)
+ if (counts[i] > dw_count)
+- dw = i, dw_count = counts[i];
++ dw = i - countof(counts)/2, dw_count = counts[i];
+ if (dw != 0)
+ pprintd1(s, "/DW %d\n", dw);
+ }
+@@ -496,14 +497,16 @@
+ if (pdf_has_subset_prefix(chars, size))
+ chars += SUBSET_PREFIX_SIZE, size -= SUBSET_PREFIX_SIZE;
+ pdf_put_name(pdev, chars, size);
+- if (pef->sub_font_type == ft_CID_encrypted &&
++ if ((pef->sub_font_type == ft_CID_encrypted ||
++ pef->sub_font_type == ft_CID_TrueType) &&
+ pef->cmapname[0] == '/'
+ ) {
+ stream_putc(s, '-');
+ pdf_put_name_chars(pdev, (const byte*) (pef->cmapname + 1),
+ strlen(pef->cmapname + 1));
+ }
+- pprints1(s, "/Encoding %s", pef->cmapname);
++ pprints1(s, (pef->cmapname[0] == '/') ? "/Encoding%s" : "/Encoding %s",
++ pef->cmapname);
+ pprintld1(s, "/DescendantFonts[%ld 0 R]",
+ pdf_resource_id((const pdf_resource_t *)pef->DescendantFont));
+ write_Widths = 0;
+@@ -563,8 +566,10 @@
+ break;
+ case -1:
+ pdf_write_CIDFont_widths(pdev, pef);
+- if (pef->FontType == ft_CID_TrueType)
+- pdf_write_CIDToGIDMap(pdev, pef, &cidmap_id);
++ if (pef->FontType == ft_CID_TrueType) {
++ if (pef->embed != FONT_EMBED_NO)
++ pdf_write_CIDToGIDMap(pdev, pef, &cidmap_id);
++ }
+ break;
+ }
+ if (pef->Differences) {
+
OpenPOWER on IntegriCloud