Japanese Microsoft Gothic TTF
-----------------------------

Thanks to Gernot Hassenplug for this HOWTO.

### Warning: this HOWTO is unfinished; there seems to be a bug in either
###          Fontforge or vertical.pe, blocking the build process midway.
###          I hope this will be fixed at the next upload of latex-cjk-japanese.

This HOWTO will guide you through the process of getting Microsoft's Japanese
font "Gothic" to work with CJK on TeX (latex, dvipdfmx and pdflatex) in the
event that you already have a legal copy of the said font.

On a standard Debian or Ubuntu installation, TEXMFLOCAL can be considered
the same as /usr/local/share/texmf/.

As root, make the directories:
$ mkdir -p  /usr/local/share/fonts/truetype/microsoft

Still as root, make "msgothic.ttf" available both to X11 and TeX:
$ cp msgothic.ttf /usr/local/share/fonts/truetype/microsoft/
$ cd /usr/local/share/texmf/fonts/truetype
$ ln -s ../../../fonts/truetype/microsoft/

Linking the font to the TEXMFLOCAL tree will have no effect on latex, dvipdfmx
or pdflatex, but it is useful if you plan to use the next generation set of
TeX tools such as XeTeX.


As a regular user, build the fonts (will take some building time):
$ mkdir ~/msgothic
$ cd ~/msgothic
$ fontforge -script /usr/share/latex-cjk-common/utils/subfonts/subfonts.pe /usr/local/share/fonts/truetype/microsoft/msgothic.ttf msgothic /usr/share/texmf/fonts/sfd/Unicode.sfd

Now some vertical fonts:
# PROBLEM: fontforge version 20071110 will segment!  msgothicv.tfm will not be created,
# rendering the third Perl command below impossible to run.
$ fontforge -script /usr/share/latex-cjk-common/utils/subfonts/vertical.pe /usr/local/share/fonts/truetype/microsoft/msgothic.ttf msgothicv
$ fontforge -script /usr/share/latex-cjk-common/utils/subfonts/vertref.pe /usr/local/share/fonts/truetype/microsoft/msgothic.ttf msgothicvr
# Impossible to make with due to a possible bug in Fontforge:
$ perl /usr/share/latex-cjk-common/utils/subfonts/clonevf.pl msgothicv msgothv
$ perl uni2sfd.pl $(uninamestem) $(sfddir)/$(encoding).sfd $(sfdnamestem) $(codingscheme)

Clean up:
$ rm -f *.enc

Create a map file for the Type1 fontsto be embedded successfully:
$ for i in *.tfm; do echo "${i%.tfm} ${i%.tfm} < ${i%.tfm}.pfb" >> msgothic.map

Create cXXmsgothic.fd:
$ # UNTESTED: perl makefdx.pl $(uninamestem)vr.afm $(sfddir)/$(encoding).sfd c$(nfss_fontencoding) $(namestem)

Create c70msgothic.fd:
$ # UNTESTED: perl makefdx.pl -u $(uninamestem)vr.afm $(sfddir)/Unicode.sfd c70$ $(namestem)

% This is c70msgothic.fd for the CJK package
% created by Gernot Hassenpflug based on the tutorial
% by Edward G. J. Lee in his blog "LJG Font Notes"
\ProvidesFile{c70msgothic.fd}
\DeclareFontFamily{C70}{msgothic}{\hyphenchar \font\m@ne}
\DeclareFontShape{C70}{msgothic}{m}{n}{<-> CJK * msgothic}{}
\DeclareFontShape{C70}{msgothic}{bx}{n}{<-> CJKb * msgothic}{\CJKbold}
\endinput

Local installation: [change ~/ with TEXMFLOCAL to get a user-wide installation]
$ mkdir ~/texmf/fonts/map/dvips/microsoft
$ cp msgothic.map ~/texmf/fonts/map/dvips/microsoft/
$ mkdir ~/texmf/fonts/{tfm,type1}/microsoft
$ msgothic*.tfm ~/texmf/fonts/tfm/microsoft/
$ msgothic*.pfb ~/texmf/fonts/type/microsoft/
$ cp c70msgothic.fd ~/texmf/tex/latex/CJK/UTF8/

$ texhash ~/texmf
$ update-updmap
$ updmap --enable Map msgothic.map # Use updmap-sys if you are root.
