undefomizing ghostscript?
Is removing defoma safe for ghostscript? If not, how can we fix a problem?
Summary
- ghostscript's fontconfig support is very limited.
- CIDFnmap is obsolete. Let's remove it.
- CMap can be merged into poppler-data or cmap-adobe-* instead of using defoma. But it needs alternative symlinks.
- How to handle Fontmap/cidfmap, especially aliases?
fontconfig?
Debian ghostscript 8.70 supports fontconfig. But unfortunately, it won't work as we expected.
- base/gp_unix.c: makePSFontName() returns a UTF-8 name, for example "IPA明朝-Unknown". Such UTF-8 characters is probihited by the Postscript definition. If we run gs without LANG setting, it will return safe ASCII-only name (IPAMincho-Unknown).
- psi/zfontenum.c: z_fontenum() calls gp_enumerate_fonts_next() (base/gp_unix.c), then it calls makePSFontName(). So should we insert unsetenv("LANG") into z_fontenum()?
Well, even the fontname matches a target PSfont of PS file, it won't work yet.
$ grep IPA article9-f.ps /RYUMIN { /IPAMincho-Unknown findfont exch dup $ gs article9-f.ps ... Can't find (or can't open) font file /usr/share/ghostscript/8.70/Resource/Font/IPAMincho-Unknown. Can't find (or can't open) font file IPAMincho-Unknown. Didn't find this font on the system! Substituting font Courier for IPAMincho-Unknown.
I suspect the fontconfig support works.
- fontconfig seems return the informations of only real fonts. There is no way to get any alias lists. This will become a problem to make a fontmap from fontconfig informations.
Fedora/Gentoo uses the fontconfig support. how? Fedora Gentoo: After observation, there isn't any new techniques, at least for CJK fonts (cidfmap).
- fontconfig upstream keithp helps us if we can make clear what need is.
FAPI?
FAPI is a freetype rendering structure and is disabled by default on Debian. It is quite different from the fontconfig font management and seems very beginning, doesn't reach the product level.
CIDFnmap?
This fontmap is absolutely obsolete, because the patch to use this file is dropped from Debian source. I don't know what this fontmap and patch made at the first.
CMap
CMap is a table between some encoding characters and CID code points, mainly for Chinese/Japanese/Korean. They had been distributed under Adobe's restricted license. Fortunatelly now they are relicensed under BSD license.
There are some packages have CMap; poppler-data, cmap-adobe-japan1, cmap-adobe-japan2, cmap-adobe-cns1, cmap-adobe-gb1, cmap-adobe-korea1, xpdf-japanese, xpdf-chinese-simplified, xpdf-chinese-traditional, xpdf-korean, and gs-cjk-resource. They include completely same files. The difference is only their locations. poppler-data package looks the best, because it has active upstream and active maintainer.
ghostscript has /usr/share/ghostscript/8.70/Resource/CMap/. Currently this directory links /var/lib/defoma/gs.d/CMap/. Because ghostscript doesn't find subdirectories, just linking to poppler-data won't work. Flat symlinking is needed.
- pabs thinks making poppler-data as the master is not good idea.
what's the problem if we let poppler-data to take CMaps from cmap-*? > poppler-data maintainer: henrich
Fontmap
Fontmap is a map for Latin Type1 fonts (*.pfb). There are 2 types.
- /PS-Fontname (real-fontpath) ;
- /PS-Fontname /Alias ;
fontpath is absolute or relative path. Because ghostscript finds /usr/share/fonts/type1/gsfonts also, Fontmap isn't necessary to define. On the other hand, Fontmap is important key to define aliases. Currently these aliases are managed by defoma. So we have to make them by another way.
/HelveticaNarrow-BoldOblique /NimbusSanL-BoldCondItal ; /Times-Bold /NimbusRomNo9L-Medi ; /Courier-Oblique /NimbusMonL-ReguObli ; /Palatino-Italic /URWPalladioL-Ital ; /Helvetica /NimbusSanL-Regu ; /Helvetica-Narrow-BoldOblique /NimbusSanL-BoldCondItal ; /NewCenturySchlbk-BoldItalic /CenturySchL-BoldItal ; /Helvetica-BoldOblique /NimbusSanL-BoldItal ; /AvantGarde-Book /URWGothicL-Book ; /NewCenturySchlbk-Roman /CenturySchL-Roma ; /Times-BoldItalic /NimbusRomNo9L-MediItal ; /Courier-Bold /NimbusMonL-Bold ; /Palatino-Bold /URWPalladioL-Bold ; /AvantGarde-BookOblique /URWGothicL-BookObli ; /AvantGarde-Demi /URWGothicL-Demi ; /Bookman-Demi /URWBookmanL-DemiBold ; /Courier /NimbusMonL-Regu ; /HelveticaNarrow-Oblique /NimbusSanL-ReguCondItal ; /Bookman-LightItalic /URWBookmanL-LighItal ; /NewCenturySchlbk-Bold /CenturySchL-Bold ; /Helvetica-Oblique /NimbusSanL-ReguItal ; /Helvetica-Narrow-Bold /NimbusSanL-BoldCond ; /AvantGarde-DemiOblique /URWGothicL-DemiObli ; /HelveticaNarrow /NimbusSanL-ReguCond ; /NewCenturySchlbk-Italic /CenturySchL-Ital ; /Palatino-BoldItalic /URWPalladioL-BoldItal ; /Times-Roman /NimbusRomNo9L-Regu ; /Palatino-Roman /URWPalladioL-Roma ; /Helvetica-Narrow-Oblique /NimbusSanL-ReguCondItal ; /HelveticaNarrow-Bold /NimbusSanL-BoldCond ; /Times-Italic /NimbusRomNo9L-ReguItal ; /Bookman-DemiItalic /URWBookmanL-DemiBoldItal ; /Helvetica-Bold /NimbusSanL-Bold ; /ZapfDingbats /Dingbats ; /Courier-BoldOblique /NimbusMonL-BoldObli ; /Bookman-Light /URWBookmanL-Ligh ; /ZapfChancery-MediumItalic /URWChanceryL-MediItal ; /Helvetica-Narrow /NimbusSanL-ReguCond ;
- gsfonts provides core fonts.
- lmodern provides some TeX fonts.
cidfmap
cidfmap is a map for TrueType/CID fonts. There are some types but we use only two types as usual.
/PS-Fontname << ?/FileType ?/TrueType /Path (real-fontpath) /SubfontID 0 /CSI [(LANGV) VERSION] >> ;
- /PS-Fontname /Alias ;
SubfontID is for TTC/OTF and chooses which font will be used from such multiple fonts collection.
LANGV is a CMap group; such as Japan1, Japan2, CNS1, GB1, or Korea1.
VERSION is a character set version. Larger version includes more glyphs. Japan1 font will take from 1 to 6, but it is very rare that free Japanese font supports 5 or 6. Well, what does 0 mean? It would be nice if we can get this number automatically from the font file.
/VL-PGothic-Regular << /FileType /TrueType /Path (/usr/share/fonts/truetype/vlgothic/VL-PGothic-Regular.ttf) /SubfontID 0 /CSI [(Japan1) 0] >> ; /IPA-Mincho-Regular << /FileType /TrueType /Path (/usr/share/fonts/opentype/ipafont/ipam.otf) /SubfontID 0 /CSI [(Japan1) 0] >> ; /SazanamiGothic-Regular-JaH << /FileType /TrueType /Path (/usr/share/fonts/truetype/sazanami/sazanami-gothic.ttf) /SubfontID 0 /CSI [(Japan2) 0] >> ; /SazanamiGothic-Regular << /FileType /TrueType /Path (/usr/share/fonts/truetype/sazanami/sazanami-gothic.ttf) /SubfontID 0 /CSI [(Japan1) 0] >> ; /Adobe-Japan1-Bold /VL-PGothic-Regular ; /Ryumin-Light /SazanamiMincho-Regular ; /GothicBBB-Medium /VL-PGothic-Regular ; /Adobe-Japan1 /VL-PGothic-Regular ; /HeiseiKakuGo-W5 /VL-PGothic-Regular ; /HeiseiMin-W3 /SazanamiMincho-Regular ;
There are some important aliases for Japanese language:
- Ryumin-Light: Japanese standard serif font for Postscript. Japanese TeX normally uses this.
- GothicBBB-Medium: Japanese standard sans-serif font for Postscript. Japanese TeX normally uses this.
- Adobe-Japan1: Acrobat PDF uses.
- Adobe-Japan1-Bold: Acrobat PDF uses.
Chinese (CNS1):
- MOESung-Regular
- MSung-Light
- MSung-Medium
- MHei-Medium
- MKai-Medium
- Adobe-CNS1
- Adobe-CNS1-Bold
Chinese (GB1):
- Song-Medium
- STSong-Light
- STFangsong-Light
- STHeiti-Regular
- STKaiti-Regular
- Adobe-GB1
- Adobe-GB1-Bold
Korean:
- HYSMyeongJo-Medium
- HYGoThic-Medium
- HYRGoThic-Medium
- Adobe-Korea1
- Adobe-Korea1-Bold
So how can we indicate this alias to proper TTF/OTF font?
fedora applies a patch to separate cidfmap against gs_init.ps. It adds .runlibfileexists function. http://pkgs.fedoraproject.org/gitweb/?p=ghostscript.git;a=blob;f=ghostscript-runlibfileifexists.patch
Here is a separeted cidfmap sample.
%! % Don't change following line. We should ensure that the original one is surely loaded. (cidfmap.GS) .runlibfile % following lines are for CJK fonts. (cidfmap.ja) .runlibfileifexists (cidfmap.ko) .runlibfileifexists (cidfmap.zh_CN) .runlibfileifexists (cidfmap.zh_TW) .runlibfileifexists % must be at the bottom of line to allow people overriding everything. (cidfmap.local) .runlibfileifexists
Unfortunatelly maintaining cidmap.* is manual. Gentoo and Fedora simply provides static files.
% cidfmap.ja /Kochi-Gothic << /FileType /TrueType /Path (/usr/share/fonts/kochi-substitute/kochi-gothic-subst.ttf) /CSI [(Japan1) 6] >> ; /Kochi-Gothic-Regular /Kochi-Gothic ; /Kochi-Gothic-JaH << /FileType /TrueType /Path (/usr/share/fonts/kochi-substitute/kochi-gothic-subst.ttf) /CSI [(Japan2) 0] >> ; /Kochi-Gothic-Regular-JaH /Kochi-Gothic-JaH ; /Kochi-Mincho << /FileType /TrueType /Path (/usr/share/fonts/kochi-substitute/kochi-mincho-subst.ttf) /CSI [(Japan1) 6] >> ; /Kochi-Mincho-Regular /Kochi-Mincho ; /Kochi-Mincho-JaH << /FileType /TrueType /Path (/usr/share/fonts/kochi-substitute/kochi-mincho-subst.ttf) /CSI [(Japan2) 0] >> ; /Kochi-Mincho-Regular-JaH /Kochi-Mincho-JaH ; /Ryumin-Light /Kochi-Mincho ; /GothicBBB-Medium /Kochi-Gothic ; /Adobe-Japan1 /Kochi-Gothic ; /Adobe-Japan2 /Kochi-Gothic-JaH ;
update-gsfontmap?
(kmuto's personal idea)
Implemantation: http://people.debian.org/~kmuto/gs/
- ghostscript drops /var/lib/defoma/gs.d, but alternatively provides /var/lib/ghostscript/ and /etc/ghostscript/.
- Link CMap files flatly under /var/lib/ghostscript/CMap/.
- The Resource/CMap of ghostscript links /var/lib/ghostscript/CMap/. Because ghostscript Resource directory has a volatile version name, it will be better to use static directory to keep CMap files.
- /var/lib/ghostscript/fonts/ has Fontmap and cidfmap. These files are made from /etc/ghostscript/ configuration files.
- Each CJK fonts puts maps to /etc/ghostscript/cidfmap.d/*.conf. Type1 uses /etc/ghostscript/fontmap.d/*.conf. (needs a policy for ordering.)
- update-gsfontmap merges /etc/ghostscript/cidfmap.d/*.conf to /var/lib/ghostscript/fonts/cidfmap, and /etc/ghostscript/fontmap.d/*.conf to /var/lib/ghostscript/fonts/Fontmap.
- ghostscript respects earlier configuration. So local settings should be use first number.
- policy draft: number must be two digits (00-99).
- 00-09: for local use (will overwrites other aliases)
- 10: core PS fonts (gsfonts)
- 50: normal PS/TTF/OTF fonts
- 90: default alias (gs-cjk-resource)
- Japanese Ryumin/GothicBBB: otf-ipafont? I use ttf-japanese-mincho.ttf and ttf-japanese-gothic.ttf at this moment.
- Chinese ?
- Korean ?
font package configuration
The number of affected packages may be very few.
Chinese/Japanese/Korean fonts (Type1 / TrueType / ?OpenType), only if you'd like to provide your font to TeX or Ghostscript.
- Latin Type1 fonts, only if you'd like to provide your font to TeX or Ghostscript.
1. Modify postinst to call update-gsfontmap.
configure) if [ -x /usr/sbin/update-gsfontmap ]; then update-gsfontmap fi ;;
2. Modify prerm also.
remove|upgrade|deconfigure) if [ -x /usr/sbin/update-gsfontmap ]; then update-gsfontmap fi ;;
3. Write conf file as debian/NN<package-name><-optionalAsYouLike>.conf.
% otf-ipafont sample (50otf-ipafont.conf) /IPA-Mincho-Regular << /FileType /TrueType /Path (/usr/share/fonts/opentype/ipafont/ipam.otf) /SubfontID 0 /CSI [(Japan1) 0] >> ; /IPA-Gothic-Regular << /FileType /TrueType /Path (/usr/share/fonts/opentype/ipafont/ipag.otf) /SubfontID 0 /CSI [(Japan1) 0] >> ;
4. Modify rules (and maybe dirs also) to copy conf file to /etc/ghostscript/cidfmap.d/ or /etc/ghostscript/fontmap.d/.
(debian/rules) install: build ... install -m 644 $(CURDIR)/debian/50otf-ipafont.conf $(CURDIR)/debian/etc/ghostscript/cidfmap.d/ ... (debian/dirs) ... etc/ghostscript/cidfmap.d
5. Remove defoma hint file. (TODO: should we remove old defoma files on prerm or postinst?)
6. Remove things of defoma from rules, postinst, prerm and control.