Fonts & Character SetsHow to install true type font to pdflatex?

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
nicolas
Posts: 3
Joined: Fri Jul 23, 2010 11:08 am

How to install true type font to pdflatex?

Post by nicolas »

Hi everybody!

I am trying to install a true type font for use with pdflatex to get chinese characters that are missing from wadalab or arphic font packages. I do not want to use xetex.

The system: ubuntu 10.04 and texlive-2009.

The following step-by-step process follows roughly what I found at http://www-alg.ist.hokudai.ac.jp/~jan/japfonts.html. And I tried it with two fonts that are installed on my ubuntu 10.04 system via the software center: IPAexGothic and WenQuanYin Micro Hei. The latter would be my want-to-get-it-going since it includes all characters I need. The problem I encounter is the same with both fonts, this cookbook is taken from trying to install the IPAex font.

I am trying to install in my local texmf-tree, all programs run as user without root permissions, so no single system-wide file is written. The local texmf-tree was not started by me trying to install the new font; I am extending the tree that came with a koma-script update (if I remember correctly).

First step is to generate tfm information:

Code: Select all

$ mkdir -p ~/.texmf/fonts/tfm/ipaex/gothic
$ cd ~/.texmf/fonts/tfm/ipaex/gothic
$ ttf2tfm /usr/share/fonts/opentype/ipaexfont/ipaexg.ttf ipaexg-uni@Unicode@
Following these steps I find 135 ipaexg-uni??.tfm files in that directory. Now make the font itself available:

Code: Select all

$ mkdir -p ~/.texmf/fonts/truetype
$ ln -s /usr/share/fonts/opentype/ipaexfont/ipaexg.ttf ~/.texmf/fonts/truetype
Next step is the font description. I do not know anything about font description files, so maybe here is my error?

Code: Select all

$ mkdir -p ~/.texmf/tex/latex
$ cat > ~/.texmf/tex/latex/c70ipaexg.fd <<EOF

\ProvidesFile{c70ipaexg.fd}[IPAex gothic font]
\DeclareFontFamily{C70}{ipaexg}{\hyphenchar \font\m@ne}
\DeclareFontShape{C70}{ipaexg}{m}{n}{<-> CJK  ipaexg-uni}{}
\DeclareFontShape{C70}{ipaexg}{bx}{n}{<-> CJKb * ipaexg-uni}{\CJKbold}
EOF
Add the map-file:

Code: Select all

$ mkdir -p ~/.texmf/fonts/map
$ cat > ~/.texmf/fonts/map/ipaex.map <<EOF
ipaexg-uni@Unicode@ ipaexg.ttf

EOF
Now update the local ~/.texmf/ls-R file:

Code: Select all

$ mktexlsr
Finally set up a custom updmap.cfg by copying it to ~/.texmf/web2c/updmap.cfg and adding a line for the created ipaex.map file:

Code: Select all

Map ipaex.map
Then I ran the following command:

Code: Select all

$ updmap --cnffile ~/.texmf/web2c/updmap.cfg
So far I noticed no errors in the output. To my surprise I am not able to process the simplest tex-file I can think of:

Code: Select all

$ cat > helloworld.tex <<EOF
\documentclass{article}
\begin{document}
Hello world.
\end{document}
EOF
Running 'pdflatex helloworld.tex' outputs:

Code: Select all

This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
 restricted \write18 enabled.
entering extended mode
(./helloworld.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, ngerman, german, german-x-2009-06-19, ngerman-x-2009-06-19, pinyin,
 loaded.
(/usr/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size10.clo))
No file helloworld.aux.
[1{/home/nicolas/.texmf-var/fonts/map/pdftex/updmap/pdftex.map{Unicode.sfd}Segmentation fault
What is causing the segmentation fault?

If there is some documentation that could help me, please point me to it. For example, where can I learn more about fd-files? There is some documentation out there on the internet, but how can I know if it is still valid/up-to-date?

And of course: if you've been able to see where I am mistaken in my installation procedure, please tell me ;-)

best regards!
Nicolas

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

How to install true type font to pdflatex?

Post by frabjous »

I’ve never done it “the hard way” as you seem to be trying. Have you tried simply using fontinst? (Which you may already have installed; at any rate, there’s an Ubuntu package that provides it, though I cannot recall which one at the moment.)

That worked for me for every font I tried it with, though that wasn’t many.

XeLaTeX is even easier; not sure why you don’t want to go that way.

Are you using 32 bit or 64 bit Ubuntu out of curiousity?
nicolas
Posts: 3
Joined: Fri Jul 23, 2010 11:08 am

Re: How to install true type font to pdflatex?

Post by nicolas »

Thank you for pointing me to fontinst. I never came across this one, maybe I looked too specific for ways to install japanese/chinese fonts. I come back regarding this approach when I had time to check it out.

I decided to stick with pdflatex for some reasons: the microtype package, and some flaws I come across when using xelatex: I failed to get rid of the indentation of the first line of the first paragraph of a section/chapter. Then I use koma script and don't understand why the headings suddenly lack umlauts. This raises some concerns, that xelatex will spoil me with some other details as well. However you are right: font handling with xelatex is pretty easy.

My machine is 32-bit.

Thanks again!
nicolas
Posts: 3
Joined: Fri Jul 23, 2010 11:08 am

How to install true type font to pdflatex?

Post by nicolas »

Okay - it now works for me. However there is room for improvement. After successfully installing one of the truetype fonts pdflatex uses the font but is awfully slow with it - processing the document now takes about thirty minutes for a single pass. This might be the reason, why all the fonts on my system are included via postscript fonts?

Now I actually would like to check whether I can speed things up by wrapping the ttf to type42 or converting it to postscript. However the font is a ttc and the tools don't know how to cope with that (ttf2tfm can deal with it and pdflatex also).

The differences to my approach described in the first posting are:

(1) c70ipaexg.map now looks like this (added \endinput):

Code: Select all

\ProvidesFile{c70ipaexg.fd}[IPAex gothic font]
\DeclareFontFamily{C70}{ipaexg}{\hyphenchar \font\m@ne}
\DeclareFontShape{C70}{ipaexg}{m}{n}{<-> CJK * ipaexg}{}
\DeclareFontShape{C70}{ipaexg}{bx}{n}{<-> CJKb * ipaexg}{\CJKbold}
\endinput
(2) reason for the segmentation fault was the map entry; writing it this way does the trick (single character '<'):

Code: Select all

ipaexg@Unicode@ <ipaexg.ttf
Post Reply