#!/bin/bash # tfm generate script by wkpark@kldp.org 2003.03.10 LIGFILE='Unicode' usage() { echo echo "usage: $0 ttf-fontname tex-fontname [-f font family] [-r pk-fontname]" echo " $0 /usr/share/fonts/gulim.ttf bmg -r baekmuk" echo " set folder name and tfm prefix as 'baekmuk'" echo " $0 gulim.ttf bmg" echo " $0 gungseo.ttf bmb -f gs set font family as 'gs'" echo " the default family is 'mj'" echo " $0 -texmf local for packaging" echo " $0 -clean delete test.*" echo " $0 -v show messages (verbose)" echo " $0 -s do not generate tfm files (silent)" echo exit 1 } maketexmf() { PACKAGE=$1 PACKDIR=$1 if [ x$PACKAGE = xlocal ]; then PACKDIR='public' fi mkdir -p texmf.$PACKAGE/ttf2pk/base mkdir -p texmf.$PACKAGE/dvipdfm/base mkdir -p texmf.$PACKAGE/tex/latex/cjklatex/$PACKDIR mkdir -p texmf.$PACKAGE/fonts/tfm/$PACKDIR echo '' > texmf.$PACKAGE/dvipdfm/base/cid-$PACKAGE.map echo '' > texmf.$PACKAGE/ttf2pk/base/$PACKAGE.map echo '\ifx\clearocplists\undefined' > texmf.$PACKAGE/tex/latex/cjklatex/$PACKDIR/$PACKAGE.sty for X in *; do [ ! -d $X ] && continue [ ! -e $X/C70$X.fd ] && continue mkdir -p texmf.$PACKAGE/fonts/tfm/$PACKDIR/$X cp -r $X/*.tfm texmf.$PACKAGE/fonts/tfm/$PACKDIR/$X/ cp -r $X/*.fd texmf.$PACKAGE/tex/latex/cjklatex/$PACKDIR/ cat $X/cid-$X.map >> texmf.$PACKAGE/dvipdfm/base/cid-$PACKAGE.map [ -e $X/ttfonts.map ] && cat $X/ttfonts.map >> texmf.$PACKAGE/ttf2pk/base/$PACKAGE.map # FONTNAME=$(basename $X/*.sty .sty) # if [ -e $X/ttfonts.map ]; then # echo $X # fi done #cat >> texmf.$PACKAGE/tex/latex/cjklatex/$PACKDIR/$PACKAGE.sty <dvipdfmx.cfg cat > _profile < $DIR/test.tex %& --translate-file=cp8bit.tcx \documentclass[12pt]{article} \usepackage{CJK} % we want the Unicode font for normal text also %\usepackage[T1]{fontenc} \renewcommand\rmdefault{$FONTNAME} \begin{document} \begin{CJK}{UTF8}{$FONTNAME} \noindent CJK LaTeX\\\\Hello KTUG\\\\ ¾È³çÇϼ¼¿ä\\\\äÌÒ»\\\\ £Á£Â£Ã£Ä£Ü£ß£þ¤þ¡ª¡«¡¬¡­¢°¢¨\\\\¨±¨²¨³¨´¨µ¨¶¨·¨¸¨¹¨º¨»¨¼¨½¨¾\\\\ ª¢ª¤ª¦ª¨ªª«¢«¤«¦«¨«ª\\\\¬¡¬¢¬£¬¤¬¥¬¦¬§¬¨\\\\ \end{CJK} \end{document} EOF } for arg; do case $# in 0) break ;; esac option=$1 shift case $option in -r) REAL=$1;shift ;; -f) FAMILY=$1;shift ;; -b) TTFB=$1;shift TTFNAMEB=$(basename $TTFB) ;; -s) SILENT=1 ;; -v) VERBOSE=1 ;; -t) OPTION=$option ;; -texmf) if [ x$1 != x ]; then TEXMF=$1; else TEXMF='local'; fi maketexmf $TEXMF exit 0 ;; -clean) rm -f test.* echo "*** Temporary files are removed" exit 0 ;; *) if [ x$TTF = x ]; then TTF=$option TTFNAME=$(basename $TTF) [ -n "$VERBOSE" ] && echo "$0: TTF=$option" else FONTNAME=$option [ -n "$VERBOSE" ] && echo "$0: FONTNAME=$option" fi ;; esac done KPSEWHICH=kpsewhich STYLENAME=$FONTNAME # check arguments [ x$TTF = x ] && usage [ x$FONTNAME = x ] && usage # set font family for using the HLaTeX if [ x$HFAMILY = x ]; then HFAMILY="mj" fi [ -n "$VERBOSE" ] && echo "$0: FONT FAMILY=$HFAMILY" if [ x$TTFB = x ]; then TTFB=$TTF TTFNAMEB=$TTFNAME fi [ -n "$VERBOSE" ] && echo "$0: BOLD TTF FONT=$TTF" # if [ $((`echo $HFAMILY | wc -c`)) -ne 3 ]; then echo echo "*** FATAL ***" echo "FontFamilyName have to consist with two characters"; echo exit 0 fi if [ $((`echo $FONTNAME | wc -c`)) -gt 6 ]; then echo echo "*** FATAL ***" echo "Font Name have to consist with two or three characters"; echo exit; fi if [ x$REAL = x ]; then REAL=$FONTNAME; fi if [ -d $REAL ]; then echo "*** WARNNING ***" echo " '$REAL' folder exist" else [ -n "$VERBOSE" ] && echo "$0: '$FONTNAME' folder created" mkdir -p $REAL fi [ -n "$VERBOSE" ] && echo "$0: generate '$REAL/*.fd' files..." cat >$REAL/C70$FONTNAME.fd < CJK * ${REAL}}{} \DeclareFontShape{C70}{$FONTNAME}{m}{sl}{<-> CJK * ${REAL}s}{} \DeclareFontShape{C70}{$FONTNAME}{m}{it}{<-> CJKssub * ${FONTNAME}/m/sl}{} \DeclareFontShape{C70}{$FONTNAME}{bx}{n}{<-> CJKb * ${REAL}}{\CJKbold} \DeclareFontShape{C70}{$FONTNAME}{bx}{sl}{<-> CJKb * ${REAL}s}{\CJKbold} \DeclareFontShape{C70}{$FONTNAME}{bx}{it}{<-> CJKssub * ${FONTNAME}/bx/sl}{\CJKbold} EOF for TYPE in 'T1' 'OT1'; do cat >$REAL/$TYPE$FONTNAME.fd < ${REAL}00}{} \DeclareFontShape{$TYPE}{$FONTNAME}{m}{sl}{<-> ${REAL}s00}{} \DeclareFontShape{$TYPE}{$FONTNAME}{m}{it}{<-> CJKssub * ${REAL}/m/sl}{} \DeclareFontShape{$TYPE}{$FONTNAME}{bx}{n}{<-> ${REAL}00}{\CJKbold} \DeclareFontShape{$TYPE}{$FONTNAME}{bx}{sl}{<-> ${REAL}s00}{\CJKbold} \DeclareFontShape{$TYPE}{$FONTNAME}{bx}{it}{<-> CJKssub * ${REAL}/bx/sl}{\CJKbold} EOF done [ -n "$VERBOSE" ] && echo "$0: generate '$REAL/$STYLENAME.sty' file" cat >$REAL/$STYLENAME.sty <$REAL/cid-$REAL.map < $REAL/dvipdfmx.cfg # make Makefile [ -n "$VERBOSE" ] && echo "$0: generate '$REAL/Makefile'" cat >$REAL/Makefile <ttfonts.map;\\ ttf2tfm $TTF \$\$OPTIONS -s .167 ${REAL}o@$LIGFILE@ >> ttfonts.map # ttf2tfm $TTFB \$\$OPTIONS ${REAL}b@$LIGFILE@ >> ttfonts.map;\\ # ttf2tfm $TTFB \$\$OPTIONS -s .167 ${REAL}bo@$LIGFILE@ >> ttfonts.map local: if test -f ../$TTF ; then ln -sf ../$TTF; fi ttf2tfm $TTF -q -l -P 3 -E 5 ${REAL}@$LIGFILE@ >ttfonts.map;\\ ttf2tfm $TTF \$\$OPTIONS -s .167 ${REAL}o@$LIGFILE@ >> ttfonts.map # ttf2tfm $TTFB \$\$OPTIONS ${REAL}b@$LIGFILE@ >> ttfonts.map;\\ # ttf2tfm $TTFB \$\$OPTIONS -s .167 ${REAL}bo@$LIGFILE@ >> ttfonts.map dist-clean: rm -f Hs$FONTNAME.fd Hw$FONTNAME.fd Hh$FONTNAME.fd $FONTNAME.sty ttfonts.map cid-$FONTNAME.map $FONTNAME*.tfm *pk test.* *.log clean: rm -f $FONTNAME*.tfm *pk test.log EOF [ -n "$VERBOSE" ] && echo "$0: generate '$REAL/test.tex file'" gentesttex $STYLENAME $REAL # check ttf2pk [ -n "$VERBOSE" ] && echo "$0: check Ligfiles with kpsewhich" $KPSEWHICH --progname=ttf2pk -format="other text files" UKS-HLaTeX.sfd >/dev/null if [ "$?" = "1" ]; then echo '*** FATAL ***' echo ' $TTF2PKINPUTS, $TTF2TTFMINPUTS in the texmf.cnf dose not configured correctly' exit fi # check fonts [ -n "$VERBOSE" ] && echo "$0: check TTFs with kpsewhich" $KPSEWHICH --progname=ttf2pk -format="font files" $(basename $TTF) > /dev/null # automatically make all tfms if [ "$?" = "1" ]; then echo '*** ERROR ***' echo " kpsewhich can't found TTFs" echo " $TTF does not exists on the font path correctly." exit 1 fi # make tfms if [ ! -n "$SILENT" ]; then cd $REAL make if [ "$?" = "1" ]; then echo '*** ERROR ***' echo 'Your font file is not a unicode TrueType' echo 'Now it considerd as a ksx1001(Wansung) type TrueType' make wansung fi fi echo '...done'