[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Need help: how to package fonts for TeX in debian?



Hi all!


From: Frank Küster <frank@debian.org>

> "Arne Götje (高盛華)" <arne@linux.org.tw> wrote:
> 
> > I am the maintainer of the ttf-arphic-{ukai|uming} packages in Debian
> > and the upstream author of those fonts.
> >
> > The fonts are Pan-CJK Unicode fonts and contain glyphs in the BMP as
> > well as in Planes 2 and 15 (PUA).
> > Therefor it is not possible to generate tfm files with ttf2tfm like the
> > existing tfm packages for the original arphic fonts do.
> > Instead I asked Werner Lemberg for help and he pointed me to his latest
> > CJK-latex package and the subfonts utils within that package.
> >
> > I used it on my fonts and it took my PC 36 (!) hours to generate the
> > .enc, .afm, .pfm and .tfm files for my 4 fonts.
> 
> Uff.  And I thought the 5 hours without any other load that it took mine
> to build the latex-cjk-chinese-arphic package were long...

Ouch.  And I only got 512MB of memory; that'll be some swapping...


> > The files are here: http://debian.linux.org.tw/~arne/tfm.tar.bz2 (70MB!)
> >
> > The fonts names are:
> > ukai	AR PL ZenKai Uni
> > ukaimbe	AR PL ZenKai Uni MBE
> > uming	AR PL ShanHeiSun Uni
> > umingmbe	AR PL ShanHeiSun Uni MBE
> >
> > I asked Werner how to install the fonts in my TeX system...
> > but it seems that in Debian the directories and file locations are quite
> > different...
> 
> That surprises me.  The only thing that's different is that a package
> maintainer shouldn't try to edit updmap.cfg directly, see
> file:///usr/share/doc/tex-common/Debian-TeX-Policy.html/ch4.html#s4.2 

I never noticed anything strange; it adheres to TDS1.1.


> > Can someone please give me a helping hand to produce debian packages for
> > those fonts?
> >
> > Werner's reply was basically this:
> > -------------
> > 1. delete the .enc files, as they are not needed.
> 
> In other words, don't install them in the deb

Certainly remove the .enc files.  There were only useful in the
ttf2tfm era, just to get embedded fonts with pdflatex.
The latest version of CJK doesn't require the .enc files; in fact, it
will only mess up things.


> > 2. gzip the .afm files (they are also not needed, but usually kept along
> > with the .pfb and .tfm files)
> 
> It's your choice whether you want to install them, or just keep them in
> the source package.

Perhaps I should gzip them as well; saves some space.


> > 3. put the .afm, .pfb and .tfm files into their proper locations in the
> > local TEXMF tree (best with subdirectories)
> 
> For a Debian package, it shouldn't be the local TEXMF tree, but the
> TEXMFMAIN tree, /usr/share/texmf, see
> file:///usr/share/doc/tex-common/Debian-TeX-Policy.html/ch3.html#s3.2 

I install the Arphic fonts in
/usr/share/texmf/fonts/{afm,map,tfm,type1,vf}/.


> > 4. generate MAP files (uming00 AR-PL-ShanHeiSun-Uni-00 < uming00.pfb)
> > (is this correct?)
> 
> I'm not sure about the format of the map files.  They should be map
> files for dvips, the format is described in the dvips info manual in the
> section 6.4 `psfonts.map': PostScript font catalog.

In the debian/rules file of the Arphic TFM fonts, I have this:

cd $(builddir); for filename in *.pfb; do if [ $$filename != "$(uninamestem)vr.pfb" ] ; then echo "$$(basename $$filename .pfb) $$(basename $$filename .pfb) <$$filename" >> $(uninamestem).map; fi; done

Perhaps I should change the Arphic fonts' PostScript names into
something like "AR PL Mingti2L Big5 / ShanHeiSun-Light" as well.


> > 5. put the MAP files into fonts/map/dvips
> 
> Same on Debian.

Exactly.  Make a subdirectory in dvips/ to keep it clean. ;)


> > 6. in TEXMF/dvips create config files: config.uming, which looks like
> > p +uming01.map
> > p +uming02.map
> > ...
> 
> I'm not sure whether this is needed, but it doesn't harm.

It's not necessary, but creating the config.* files will allow you to
use the -P option directly with dvips, even if the map file has been
disabled in updmap.

For example, if you install the Wadalab Type1 fonts for CJK, the
package installs a config.wadalab file as well.  Even if I disable the
wadalab.map file in the updmap configuration, "dvips -P wadalab x.dvi"
will still use the Wadalab Type1 fonts.

If I were you, I would include it.  It never harms, makes everything
complete, and some HOWTO pages make use of the -P option for their
examples.


> > 7. register the Map files in TEXMF/web2c/updmap.cfg
> > Map uming01.map
> > 8. run the updmap script
> 
> These two steps are different in Debian (and teTeX-3.0, by the way).
> Please read the first link to the TeX policy I gave above, and in
> particular
> file:///usr/share/doc/tex-common/Debian-TeX-Policy.html/apA.html#s-appen-sample-font
> and feel free to ask if you're unsure about the details.

I would name the file just "uming.map"; you don't need a map file for
every plane.  Unless the font is called "01", of course.

The Arphic bkai00mp TFM package installs a file at
/etc/texmf/updmap.d/10latex-cjk-chinese-arphic-bkai00mp.cfg with 

# 10latex-cjk-chinese-arphic-bkai00mp.cfg
# You can change/add entries to this file and changes will be preserved
# over upgrades, even if you have removed the main package prior
# (not if you purged it). You should leave the following pseudo comment
# present in the file!
# -_- DebPkgProvidedMaps -_-
#
Map bkaiu.map

You could put several Map and MixedMap lines in it, of course.

BTW, it's not updmap anymore, it's now updmap-sys.  And I would really
use the dh_installtex command if I were you.  It makes sure you won't
forget a step.


> > Now, how to do this in Debian? and how to produce a package for this? Or
> > should this go into the latex-cjk /cjk-latex stuff?
> 
> Hm, I guess a package that takes 36 hours to build from source should be
> on its own.  Even if you decide to include the things you generated in
> the tarball, and not regenerate it on every package build.

I too would prefer a separate package: the original Arphic fonts also
are put in a different source package, and the Unicode Korean HLaTeX
will also be packaged individually.


Attached you will find my debian/rules file for the (new and hopefully
soon to be official) Arphic TFM packages where you'll just have to
change a few variables in the first section (and cross your thumbs it
will work after 36 hours, if not more because of the generation of
vertical font variants).

I will myself try to generate the fonts ASAP, and see if it works,
perhaps we could join efforts?



Danai SAE-HAN
韓達耐

-- 
題目:《春日》
作者:程顥(1032-1085)

云淡風輕近午天,傍花隨柳過前川。
時人不識余心樂,將謂偷閑學少年。
#!/usr/bin/make -f
# -*- makefile -*-

# debian/rules file
# GNU GPL v2, Copyright (C) 2005-2006, Danai SAE-HAN <danai.sae-han@edpnet.be>

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Arphic PL fonts information

fonts = bsmi bkai gbsn gkai

bsmi_typeface = bsmi00lp
bsmi_namestem = bsmi
bsmi_sfdnamestem = bsmilp
bsmi_uninamestem = bsmiu
bsmi_familyname = AR PL Mingti2L Big5
bsmi_encoding = UBig5

bkai_typeface = bkai00mp
bkai_namestem = bkai
bkai_sfdnamestem = bkaimp
bkai_uninamestem = bkaiu
bkai_familyname = AR PL KaitiM Big5
bkai_encoding = UBig5

gbsn_typeface = gbsn00lp
gbsn_namestem = gbsn
gbsn_sfdnamestem = gbsnlp
gbsn_uninamestem = gbsnu
gbsn_familyname = AR PL SungtiL GB
gbsn_encoding = UGB

gkai_typeface = gkai00mp
gkai_namestem = gkai
gkai_sfdnamestem = gkaimp
gkai_uninamestem = gkaiu
gkai_familyname = AR PL KaitiM GB
gkai_encoding = UGB

cjk_fontencoding = 0
UBig5_planes = 55
UBig5_inputencoding = 0
UBig5_texinput = usr/share/texmf/tex/latex/CJK/Bg5/
UBig5_codingscheme = cjkbig5
UGB_planes = 35
UGB_inputencoding = 1
UGB_texinput = usr/share/texmf/tex/latex/CJK/GB/
UGB_codingscheme = cjkgb

fonttype = truetype
supplier = arphic

typeface = $($(abbrev)_typeface)
familyname = $($(abbrev)_familyname)
encoding = $($(abbrev)_encoding)
namestem = $($(abbrev)_namestem)
sfdnamestem = $($(abbrev)_sfdnamestem)
uninamestem = $($(abbrev)_uninamestem)
planes = $($(encoding)_planes)
nfss_fontencoding = $($(encoding)_inputencoding)$(cjk_fontencoding)
codingscheme = $($(encoding)_codingscheme)
bin-package = latex-cjk-chinese-$(supplier)-$(typeface)
binary_fonts = $(addprefix binary_,$(fonts))
build-stamp_fonts = $(addprefix build-stamp.,$(fonts))
install_fonts = $(addprefix install_,$(fonts))
clean_fonts = $(addprefix clean_,$(fonts))

# Path names

d = debian/$(bin-package)
texmf = usr/share/texmf
fontpath = usr/share/fonts/$(fonttype)/$(supplier)
dest_texfontpath = $(texmf)/fonts/$(fonttype)/$(supplier)
dest_afmpath = $(texmf)/fonts/afm/$(supplier)/$(uninamestem)
dest_type1path = $(texmf)/fonts/type1/$(supplier)/$(uninamestem)
dest_uni-tfmpath = $(texmf)/fonts/tfm/$(supplier)/$(uninamestem)
dest_sfd-tfmpath = $(texmf)/fonts/tfm/$(supplier)/$(sfdnamestem)
dest_vfpath = $(texmf)/fonts/vf/$(supplier)/$(namestem)
dest_docpath = usr/share/doc/texmf/fonts/$(fonttype)/$(supplier)
dest_fd = $($(encoding)_texinput)
builddir = build/$(typeface)
sfddir = /$(texmf)/fonts/sfd

ERR = cat log; echo "Errare humanum! Please have a look at $(builddir)/log."; exit 1


build: build-stamp

build-stamp: $(build-stamp_fonts)
	dh_testdir

# Add here commands to compile the package.

	touch build-stamp

$(build-stamp_fonts): abbrev = $(patsubst build-stamp.%,%,$@)
$(build-stamp_fonts):
	dh_testdir
	mkdir -p $(builddir)
	( cd $(builddir); ln -s /$(fontpath)/$(typeface).ttf; cp ../../debian/latex-cjk/* . )

	# You will find a detailed log of the build process in $(builddir)/log.

	# Create Unicode encoded subfonts `$(uninamestem)00' .. `$(uninamestem)ff'.
	# This will take more than an hour.  Make yourself a cup of tea.
	@echo fontforge -script subfonts.pe $(typeface).ttf $(uninamestem) $(sfddir)/Unicode.sfd
	@( cd $(builddir); fontforge -script subfonts.pe $(typeface).ttf $(uninamestem) $(sfddir)/Unicode.sfd > log 2>&1 || ($(ERR)) )
	@echo

	# Create font `$(uninamestem)v' with all vertical glyph representation forms.
	@echo fontforge -script vertical.pe $(typeface).ttf $(uninamestem)v
	@( cd $(builddir); fontforge -script vertical.pe $(typeface).ttf $(uninamestem)v >> log 2>&1 || ($(ERR)) )
	@echo

	# Create font `$(uninamestem)vr' which has the same structure as `$(uninamestem)v',
	# but normal glyphs instead of vertical representation forms.
	@echo fontforge -script vertref.pe $(typeface).ttf $(uninamestem)vr
	@( cd $(builddir); fontforge -script vertref.pe $(typeface).ttf $(uninamestem)vr >> log 2>&1 || ($(ERR)) )
	@echo

	# Create a virtual font `$(sfdnamestem)v' which is a clone of `$(uninamestem)v'.
	@echo perl clonevf.pl $(uninamestem)v $(sfdnamestem)v
	@( cd $(builddir); perl clonevf.pl $(uninamestem)v $(sfdnamestem)v >> log 2>&1 || ($(ERR)) )
	@echo

	# Create virtual fonts `$(sfdnamestem)00' .. `$(sfdnamestem)$(planes)' in $(encoding) encoding
	# which use Unicode encoded `$(uninamestem)XX' subfonts as raw fonts
	# and `$(codingscheme)' as the `CODINGSCHEME' parameter value.
	@echo perl uni2sfd.pl $(uninamestem) $(sfddir)/$(encoding).sfd $(sfdnamestem) $(codingscheme)
	@( cd $(builddir); perl uni2sfd.pl $(uninamestem) $(sfddir)/$(encoding).sfd $(sfdnamestem) $(codingscheme) >> log 2>&1 || ($(ERR)) )
	@echo

	# Create entries for the extended font definition file
	# `c$(nfss_fontencoding)$(namestem).fdx' (which uses $(encoding) encoding), with `$(uninamestem)vr' as
	# the reference font.
	@echo perl makefdx.pl $(uninamestem)vr.afm $(sfddir)/$(encoding).sfd c$(nfss_fontencoding)$(namestem).fdx
	@( cd $(builddir); perl makefdx.pl $(uninamestem)vr.afm $(sfddir)/$(encoding).sfd c$(nfss_fontencoding)$(namestem).fdx >> log 2>&1 || ($(ERR)) )
	@echo

	# Create entries for the extended font definition file
	# `c$(nfss_fontencoding)$(namestem).fdx' (which uses Unicode encoding), with `$(uninamestem)vr' as
	# the reference font.
	@echo perl makefdx.pl $(uninamestem)vr.afm $(sfddir)/Unicode.sfd c70$(namestem).fdx
	@( cd $(builddir); perl makefdx.pl $(uninamestem)vr.afm $(sfddir)/Unicode.sfd c70$(namestem).fdx >> log 2>&1 || ($(ERR)) )
	@echo

	# Remove the *.enc files; they're not used.
	@( cd $(builddir); rm -f *.enc )
	@echo

	# Create a Type1 font map.
	@( cd $(builddir); for filename in *.pfb; do if [ $$filename != "$(uninamestem)vr.pfb" ] ; then echo "$$(basename $$filename .pfb) $$(basename $$filename .pfb) <$$filename" >> $(uninamestem).map; fi; done )
	@echo

	# Create entries for the font definition file
	# `c$(nfss_fontencoding)$(namestem).fd' (which uses $(encoding) encoding).
	@cd debian; \
	    sed -e 's/@NFSS_FONTENCODING@/$(nfss_fontencoding)/g' \
		-e 's/@NAMESTEM@/$(namestem)/g' \
		-e 's/@ENCODING@/$(encoding)/g' \
		-e 's/@FONTENCODING@/$(encoding)/g' \
		-e 's/@FAMILYNAME@/$(familyname)/g' \
		-e 's/@SUBNAMESTEM@/$(sfdnamestem)/g' \
		font.fd.in > ../$(builddir)/c$(nfss_fontencoding)$(namestem).fd
	@echo

	# Create entries for the font definition file
	# `c70$(namestem).fd' (which uses Unicode encoding).
	@cd debian; \
	    sed -e 's/@NFSS_FONTENCODING@/70/g' \
		-e 's/@NAMESTEM@/$(namestem)/g' \
		-e 's/@ENCODING@/$(encoding)/g' \
		-e 's/@FONTENCODING@/Unicode/g' \
		-e 's/@FAMILYNAME@/$(familyname)/g' \
		-e 's/@SUBNAMESTEM@/$(uninamestem)/g' \
		font.fd.in > ../$(builddir)/c70$(namestem).fd
	@echo

	touch $@

clean: pre-clean $(clean_fonts)
	dh_testdir
	dh_testroot
	rm -f build-stamp

	dh_clean 
	rm -rf build/

pre-clean:
	cd debian; cp control.stem.in control

$(clean_fonts): abbrev = $(patsubst clean_%,%,$@)
$(clean_fonts): DH_OPTIONS = -p$(bin-package) -P$(d)
$(clean_fonts):
	@cd debian; \
	    sed -e 's/@TYPEFACE@/$(typeface)/g' \
		-e 's/@FAMILYNAME@/$(familyname)/g' \
		control.leaf.in >> control
	@cd debian; \
	    sed -e 's/@ABBREV@/$(abbrev)/g' \
		-e 's/@FAMILYNAME@/$(familyname)/g' \
		-e 's/@TYPEFACE@/$(typeface)/g' \
		copyright.in > $(bin-package).copyright
	dh_clean $(DH_OPTIONS)
	rm -f build-stamp.$(abbrev)


install: build $(install_fonts)
$(install_fonts): abbrev = $(patsubst install_%,%,$@)
$(install_fonts): DH_OPTIONS = -p$(bin-package) -P$(d)
$(install_fonts):
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs

binary-indep: build install $(binary_fonts)
$(binary_fonts): abbrev = $(patsubst binary_%,%,$@)
$(binary_fonts): DH_OPTIONS = -p$(bin-package) -P$(d)
$(binary_fonts):
	dh_testdir $(DH_OPTIONS)
	dh_testroot $(DH_OPTIONS)
	dh_installchangelogs $(DH_OPTIONS)
	dh_installdocs $(DH_OPTIONS)
	dh_installexamples $(DH_OPTIONS)
	dh_install $(DH_OPTIONS) $(builddir)/*.afm $(dest_afmpath)/
	dh_install $(DH_OPTIONS) $(builddir)/$(uninamestem)*.tfm $(dest_uni-tfmpath)/
	dh_install $(DH_OPTIONS) $(builddir)/$(sfdnamestem)*.tfm $(dest_sfd-tfmpath)/
	dh_install $(DH_OPTIONS) $(builddir)/*.pfb $(dest_type1path)/
	dh_install $(DH_OPTIONS) $(builddir)/*.vf $(dest_vfpath)/
	dh_install $(DH_OPTIONS) $(builddir)/$(uninamestem).map /usr/share/texmf/fonts/map/dvips/arphic/
	dh_install $(DH_OPTIONS) $(builddir)/c$(nfss_fontencoding)$(namestem).fd{,x} $(dest_fd)/
	dh_install $(DH_OPTIONS) $(builddir)/c70$(namestem).fd{,x} usr/share/texmf/tex/latex/CJK/UTF8/
	dh_link $(DH_OPTIONS)
#	dh_installtexfonts $(DH_OPTIONS) Map=$(uninamestem).map
	dh_installtex $(DH_OPTIONS) --flavor=map:config_for_all_maps map=Map,$(uninamestem).map
	dh_strip $(DH_OPTIONS)
	dh_compress $(DH_OPTIONS)
	dh_fixperms $(DH_OPTIONS)
	dh_perl $(DH_OPTIONS)
	dh_installdeb $(DH_OPTIONS)
	dh_gencontrol $(DH_OPTIONS)
	dh_md5sums $(DH_OPTIONS)
	dh_builddeb $(DH_OPTIONS)


# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install \
	$(fonts) $(install_fonts) $(binary_fonts) $(clean_fonts) pre-clean

Reply to: