[Tex/LaTex] Displaying medieval scriptures and neumes in TeX

symbols

We have a friend who is trying to write his PhD thesis in LaTeX.
In his thesis, he has to use old scriptures and medieval music notations (neumes).
Unfortunately, for the kind of neumes (St. Gallen Neumes) he has to use, there aren't any packages.
So we're looking for some (awesome) person, who could help us to find a way to displaying these scriptures in TeX/PDF.

We already found out, that there is a way to create own TTF's through graphics and Corel Draw, but this won't be enough to display them in the PDF later, right?

The notations should appear above the lyrics (similar to simple chord-symbols).

Anyone any ideas?

Best Answer

I don't know if it is appropriate to include non-TeX programming language on this site, but about 6 years ago I wrote PC batch files to take TTF files and install them on my PC for LaTeX usage. I am using MiKTeX, so file locations may or may not be dependent on that. The program was for my own use, and so it would have to be customized for your own use (file locations, directory names, etc.). And if you have any questions, it could take me a while to try to develop an answer, because I haven't used it in a number of years. The good news is I installed well over 100 fonts on my W2K system with it, so I know it works, if the loose ends are resolved. I make no guarantees on how successful you will be, but you are welcome to it.

It has options if you are installing a single font, or up to four fonts as part of a font family (I didn't go beyond that).

It needs a copy of sed.exe, which you can get from gnu, as well as programs like ttf2tfm and ttf2afm, which are out there. It also invokes a few stencil files of mine, which it edits and uses, so I'll include those below, as well. Here goes...

mkTTfont.bat:

@echo off
REM  This file will create LaTeX fonts given a family of
REM  TrueType font files.  The files should be of the type:
REM   1) standard font
REM   2) + bold font
REM   3) + accented font (e.g., Oblique or Italic)
REM   4) + bold, accented font (e.g., BoldOblique or BoldItalic)
REM
REM
REM  Regardless of whether the accent is Italic or Oblique, this program
REM  will assign this accented font as "italic" as far as LaTeX is concerned.
REM  An "oblique" (also known as "slant") font will created by slanting the
REM  Standard and Bold fonts.  The default slant value of .167 may be 
REM  edited by the user.  Thus, with 4 font files, a total of 6 LaTeX fonts
REM  will be created, the four that are directly in the ttf files provided
REM  plus two slanted fonts created from the standard and bold-standard fonts.
REM  When only two font files are utilized, 4 LaTeX fonts will be
REM  created.  When only one font file is provided, 2 LaTeX fonts will
REM  be created
REM
REM  This program assumes your ttf files employ T1-WGL4 encoding, which 
REM  will need editing if it is otherwise.
REM
REM  The syntax of the command is mkTTfont <font supplier> <font family>
REM
REM    DEFAULT FONT TYPE NAMES & OPTIONS
set STD=Regular
set BLD=Bold
set SLNT=.167
REM    ENCODING:
set ENCODE=T1-WGL4.enc
REM    FILE LOCATIONS:
set HDIR=C:\DOCUME~1\steven\TeX\Fonts
set SEDEXE=C:\DOCUME~1\steven\TeX\Fonts\sed.exe
set LOCALTEX=c:\localtexmf
set PSMAP=%LOCALTEX%\pdftex\config\psfonts.map
set TTMAP=C:\texmf\ttf2tfm\base\ttfonts.map
set FONTDIR=%LOCALTEX%\fonts
set LATEXFONTDIR=%LOCALTEX%\tex\latex\fonts
set TTDIR=%LOCALTEX%\ttf2tfm
REM    WITH BELOW FOUR LINES, COOKED TFM/VF FILES ARE <FONTNAME>.tfm AND
REM    <FONTNAME>.vfm, WHILE RAW TFM FILES ARE r<FONTNAME>.tfm
set PX=ec
set RPX=rec
set CNM=%PX%%2
set RNM=%RPX%%2

REM================= Confirm number of arguments ========================

if "%2"=="" goto BADSYNTAX
goto CONTINUE1

:BADSYNTAX
echo Two arguments required: mkTTfont font-supplier font-family
goto THEEND

:CONTINUE1

REM================= Ascertain ttf filenames ============================

REM
set FNM=%1%2
if EXIST %FNM%%STD%.ttf goto JUSTFINE
if EXIST %FNM%.ttf goto FIXSTD
if EXIST %2%STD%.ttf goto FIXFNM
if EXIST %2.ttf goto FIXBOTH

echo.
echo For the standard font's filename, what word comes between 
echo ...%2 and .ttf (example: ...%2%STD%.ttf)?

SET /P STD=? 

if EXIST %FNM%%STD%.ttf goto JUSTFINE
if EXIST %2%STD%.ttf goto FIXFNM

echo Can't find specified font file, either
echo %FNM%%STD%.ttf, %2.ttf,
echo nor
echo %2%STD%.ttf
echo Aborting run.

goto THEEND

goto JUSTFINE

:FIXSTD

set STD=

goto JUSTFINE

:FIXFNM

set FNM=%2

goto JUSTFINE

:FIXBOTH

set FNM=%2
set STD=

:JUSTFINE

REM================= Confirm existence of all font files ================

echo.
echo How many font files do you wish to install from this family
Set /P NUM=(1, 2, 3, or 4)? 

IF "%NUM%"=="1" goto SKIPACNT
IF "%NUM%"=="2" goto SKIPACNT
IF "%NUM%"=="3" goto GETACTYP
IF "%NUM%"=="4" goto GETACTYP

echo.
echo Not prepared to install %NUM% fonts.
echo Aborting job.
goto THEEND

:GETACTYP

if NOT EXIST %FNM%Italic.ttf goto TYPEB
set ACNT=Italic
goto SKIPACNT

:TYPEB

if NOT EXIST %FNM%Oblique.ttf goto TYPEC
set ACNT=Oblique
goto SKIPACNT

:TYPEC

if NOT EXIST %FNM%i.ttf goto TYPED
set ACNT=i
goto SKIPACNT

:TYPED

if NOT EXIST %FNM%o.ttf goto GETACNT
set ACNT=o
goto SKIPACNT

:GETACNT

echo.
echo What filename phrase denotes the font accent
Set /P ACNT=(e.g. Italic, Oblique, i, o, etc.)?

:SKIPACNT

if %NUM%==1 goto SKIPBOLD

if NOT EXIST %FNM%Bold.ttf goto BOLDTYPEB
set BLD=Bold
goto SKIPBOLD

:BOLDTYPEB

if NOT EXIST %FNM%b.ttf goto GETBLD
set BLD=b
goto SKIPBOLD

:GETBLD

echo.
echo What filename phrase denotes the "bold" font
Set /P BLD=(e.g. Bold, b, Zier, etc.)?

:SKIPBOLD

echo.
echo Expected File(s):
echo.
echo Standard Font:    %FNM%%STD%.ttf
if     EXIST %FNM%%STD%.ttf echo   Found.
if NOT EXIST %FNM%%STD%.ttf goto FILEMSNG
if %NUM%==1 goto DONEFILES
echo Bold Font:        %FNM%%BLD%.ttf
if     EXIST %FNM%%BLD%.ttf echo   Found.
if NOT EXIST %FNM%%BLD%.ttf goto FILEMSNG
if %NUM%==2 goto DONEFILES
echo Accent Font:      %FNM%%ACNT%.ttf
if     EXIST %FNM%%ACNT%.ttf echo   Found.
if NOT EXIST %FNM%%ACNT%.ttf goto FILEMSNG
if %NUM%==3 goto DONEFILES
echo Bold Accent Font: %FNM%%BLD%%ACNT%.ttf
if     EXIST %FNM%%BLD%%ACNT%.ttf echo   Found.
if NOT EXIST %FNM%%BLD%%ACNT%.ttf goto FILEMSNG

goto DONEFILES

:FILEMSNG
echo   Missing.
echo.
echo Aborting Job.
goto THEEND

:DONEFILES
echo.
pause

REM================= Ascertain fontnames ================================

IF EXIST %SEDEXE% goto GETFNTNMS

echo You need to have sed.exe (sed stream editor) in the parent directory.
echo It is available through gnu.org.
echo Aborting installation.
goto THEEND

:GETFNTNMS

echo.
echo Determining Fontname(s):
echo.

ttf2afm -e %ENCODE% -o Fontname.afm   %FNM%%STD%.ttf 2>junk.out
afm2tfm Fontname.afm -T %ENCODE% Fontname.tfm 2>junk.out > fontline.out
type fontline.out | %SEDEXE% s/Fontname// > fontname.out
FOR /F %%A in ('type fontname.out') DO (
  @echo off
  set FNTNMS=%%A
)
echo %FNM%%STD%.ttf: %FNTNMS%
echo.
del Fontname.afm Fontname.tfm junk.out fontline.out fontname.out

if %NUM%==1 goto DONENAMES

ttf2afm -e %ENCODE% -o Fontname.afm   %FNM%%BLD%.ttf 2>junk.out
afm2tfm Fontname.afm -T %ENCODE% Fontname.tfm 2>junk.out > fontline.out
type fontline.out | %SEDEXE% s/Fontname// > fontname.out
FOR /F %%A in ('type fontname.out') DO (
  @echo off
  set FNTNMB=%%A
)
echo %FNM%%BLD%.ttf: %FNTNMB%
echo.
del Fontname.afm Fontname.tfm junk.out fontline.out fontname.out

if %NUM%==2 goto DONENAMES

ttf2afm -e %ENCODE% -o Fontname.afm   %FNM%%ACNT%.ttf 2>junk.out
afm2tfm Fontname.afm -T %ENCODE% Fontname.tfm 2>junk.out > fontline.out
type fontline.out | %SEDEXE% s/Fontname// > fontname.out
FOR /F %%A in ('type fontname.out') DO (
  @echo off
  set FNTNMA=%%A
)
echo %FNM%%ACNT%.ttf: %FNTNMA%
echo.
del Fontname.afm Fontname.tfm junk.out fontline.out fontname.out

if %NUM%==3 goto DONENAMES

ttf2afm -e %ENCODE% -o Fontname.afm   %FNM%%BLD%%ACNT%.ttf 2>junk.out
afm2tfm Fontname.afm -T %ENCODE% Fontname.tfm 2>junk.out > fontline.out
type fontline.out | %SEDEXE% s/Fontname// > fontname.out
FOR /F %%A in ('type fontname.out') DO (
  @echo off
  set FNTNMBA=%%A
)
echo %FNM%%BLD%%ACNT%.ttf: %FNTNMBA%
echo.
del Fontname.afm Fontname.tfm junk.out fontline.out fontname.out

:DONENAMES

pause

REM================= Get ready for file creation ========================

IF EXIST %HDIR%\t1STENCIL%NUM%.fd goto CONTINUE2

echo Can't find t1STENCIL%NUM%.fd in the home directory:
echo %HDIR%
echo Aborting installation.
goto THEEND

:CONTINUE2

echo Making sure certain files DON'T exist a priori:
del ttfonts.map
del psfonts.map

REM================= Make raw font metrics & create ttfonts map entry ===

ttf2tfm %FNM%%STD%.ttf       -q -T %ENCODE%     -v %CNM%.vpl   %RNM%.tfm   ^
  >> ttfonts.map
ttf2tfm %FNM%%STD%.ttf -q -T %ENCODE% -s %SLNT% -v %CNM%o.vpl  %RNM%o.tfm  ^
  >> ttfonts.map

if %NUM%==1 goto DONERAW

ttf2tfm %FNM%%BLD%.ttf       -q -T %ENCODE%     -v %CNM%b.vpl  %RNM%b.tfm  ^
  >> ttfonts.map
ttf2tfm %FNM%%BLD%.ttf -q -T %ENCODE% -s %SLNT% -v %CNM%bo.vpl %RNM%bo.tfm ^
  >> ttfonts.map

if %NUM%==2 goto DONERAW

ttf2tfm %FNM%%ACNT%.ttf      -q -T %ENCODE%     -v %CNM%i.vpl  %RNM%i.tfm  ^
  >> ttfonts.map

if %NUM%==3 goto DONERAW

ttf2tfm %FNM%%BLD%%ACNT%.ttf -q -T %ENCODE%     -v %CNM%bi.vpl %RNM%bi.tfm ^
  >> ttfonts.map

:DONERAW

echo %% Done font %2! on %date% at %time% >> ttfonts.map

REM================= Make cooked font metrics ===========================

vptovf %CNM%.vpl    %CNM%.vf    %CNM%.tfm
vptovf %CNM%o.vpl   %CNM%o.vf   %CNM%o.tfm

if %NUM%==1 goto DONECOOKED

vptovf %CNM%b.vpl   %CNM%b.vf   %CNM%b.tfm
vptovf %CNM%bo.vpl  %CNM%bo.vf  %CNM%bo.tfm

if %NUM%==2 goto DONECOOKED

vptovf %CNM%i.vpl   %CNM%i.vf   %CNM%i.tfm

if %NUM%==3 goto DONECOOKED

vptovf %CNM%bi.vpl  %CNM%bi.vf  %CNM%bi.tfm

:DONECOOKED

del *.vpl

REM================= Create Adobe font metrics ==========================

ttf2afm -e %ENCODE% -o %RNM%.afm   %FNM%%STD%.ttf

if %NUM%==1 goto DONEAFM

ttf2afm -e %ENCODE% -o %RNM%b.afm  %FNM%%BLD%.ttf

if %NUM%==2 goto DONEAFM

ttf2afm -e %ENCODE% -o %RNM%i.afm  %FNM%%ACNT%.ttf

if %NUM%==3 goto DONEAFM

ttf2afm -e %ENCODE% -o %RNM%bi.afm %FNM%%BLD%%ACNT%.ttf

:DONEAFM

REM================= Create target directories & move files there =======

IF NOT EXIST %FONTDIR% mkdir %FONTDIR%

IF NOT EXIST %FONTDIR%\truetype       mkdir %FONTDIR%\truetype
IF NOT EXIST %FONTDIR%\truetype\%1    mkdir %FONTDIR%\truetype\%1
IF NOT EXIST %FONTDIR%\truetype\%1\%2 mkdir %FONTDIR%\truetype\%1\%2

IF NOT EXIST %FONTDIR%\tfm       mkdir %FONTDIR%\tfm
IF NOT EXIST %FONTDIR%\tfm\%1    mkdir %FONTDIR%\tfm\%1
IF NOT EXIST %FONTDIR%\tfm\%1\%2 mkdir %FONTDIR%\tfm\%1\%2

IF NOT EXIST %FONTDIR%\vf       mkdir %FONTDIR%\vf
IF NOT EXIST %FONTDIR%\vf\%1    mkdir %FONTDIR%\vf\%1
IF NOT EXIST %FONTDIR%\vf\%1\%2 mkdir %FONTDIR%\vf\%1\%2

copy %FNM%*.ttf %FONTDIR%\truetype\%1\%2\

copy %CNM%*.tfm  %FONTDIR%\tfm\%1\%2\
copy %RNM%*.tfm %FONTDIR%\tfm\%1\%2\

copy %CNM%*.vf %FONTDIR%\vf\%1\%2\

IF NOT EXIST %TTDIR%      mkdir %TTDIR%
IF NOT EXIST %TTDIR%\base mkdir %TTDIR%\base
IF NOT EXIST %TTDIR%\base\ttfonts.map copy %TTMAP% %TTDIR%\base\ttfonts.map

type %TTDIR%\base\ttfonts.map | %SEDEXE% /%RNM%/d > tttemp.map
copy %TTDIR%\base\ttfonts.map %TTDIR%\base\ttfontsOLD.map
copy tttemp.map+ttfonts.map %TTDIR%\base\ttfonts.map
del tttemp.map

IF NOT EXIST %LATEXFONTDIR% mkdir %LATEXFONTDIR%
IF NOT EXIST %LATEXFONTDIR%\%1 mkdir %LATEXFONTDIR%\%1

type %HDIR%\t1STENCIL%NUM%.fd | %SEDEXE% s/COOKED/%CNM%/g ^
  | %SEDEXE% s/STENCIL/%2/g > t1%2.fd

echo t1%2.fd
copy t1%2.fd %LATEXFONTDIR%\%1

IF NOT EXIST %FONTDIR%\afm       mkdir %FONTDIR%\afm
IF NOT EXIST %FONTDIR%\afm\%1    mkdir %FONTDIR%\afm\%1
IF NOT EXIST %FONTDIR%\afm\%1\%2 mkdir %FONTDIR%\afm\%1\%2

copy %RNM%*.afm %FONTDIR%\afm\%1\%2


REM================= Create psfonts map entries =========================

afm2tfm %RNM%.afm   -T %ENCODE%           %RNM%.tfm    >> psf1.map
REM afm2tfm %RNM%.afm   -T %ENCODE% -s %SLNT% %RNM%o.tfm   >> psf1.map

if %NUM%==1 goto FINISHMAP

afm2tfm %RNM%b.afm  -T %ENCODE%           %RNM%b.tfm   >> psf1.map
REM afm2tfm %RNM%b.afm -T %ENCODE% -s %SLNT% %RNM%bo.tfm >> psf1.map

if %NUM%==2 goto FINISHMAP

afm2tfm %RNM%i.afm  -T %ENCODE%           %RNM%i.tfm   >> psf1.map

if %NUM%==3 goto FINISHMAP

afm2tfm %RNM%bi.afm -T %ENCODE%           %RNM%bi.tfm  >> psf1.map

:FINISHMAP

type psf1.map | %SEDEXE% s/T1-/%FNM%.ttf" T1-"/ > psf2.map


type psf2.map | %SEDEXE% -n /%FNTNMS%" "/p | %SEDEXE% s/.ttf/%STD%.ttf/  ^
  >> psf3.map

if %NUM%==1 goto DONEMAP

type psf2.map | %SEDEXE% -n /%FNTNMB%" "/p | %SEDEXE% s/.ttf/%BLD%.ttf/  ^
  >> psf3.map

if %NUM%==2 goto DONEMAP

type psf2.map | %SEDEXE% -n /%FNTNMA%/p    | %SEDEXE% s/.ttf/%ACNT%.ttf/ ^
  >> psf3.map

if %NUM%==3 goto DONEMAP

type psf2.map | %SEDEXE% -n /%FNTNMBA%/p | %SEDEXE% s/.ttf/%BLD%%ACNT%.ttf/ ^
  >> psf3.map

:DONEMAP

echo %% Done font %2! on %date% at %time% >> psf3.map

rename psf3.map psfonts.map
del psf1.map psf2.map

type %PSMAP% | %SEDEXE% /%RNM%/d > pstemp.map
copy %PSMAP% %PSMAP%.OLD
copy pstemp.map+psfonts.map %PSMAP%
del pstemp.map

REM Parting guidance

echo.
echo If this is a revision of an existing installation,
echo you will need to delete all the preexisting pk
echo fonts with the name %2, below the directory named
echo %FONTDIR%\pk

echo.
set /P HASHNOW=Would you like to update the MikTeX filename data base now? 
if %HASHNOW%==y goto DOHASH
if %HASHNOW%==Y goto DOHASH

echo.
echo You will need to update the MikTeX database before using this font.
goto THEEND

:DOHASH

texhash
echo.

:THEEND

t1STENCIL1.fd:

\ProvidesFile{t1STENCIL.fd}[TrueType font STENCIL]

\DeclareFontFamily{T1}{STENCIL}{}

\DeclareFontShape{T1}{STENCIL}{b}{n} {<-> COOKED}{}
\DeclareFontShape{T1}{STENCIL}{b}{sl}{<-> COOKEDo}{}
\DeclareFontShape{T1}{STENCIL}{b}{it}{<-> COOKEDo}{}

\DeclareFontShape{T1}{STENCIL}{m}{n} {<-> COOKED}{}
\DeclareFontShape{T1}{STENCIL}{m}{sl}{<-> COOKEDo}{}
\DeclareFontShape{T1}{STENCIL}{m}{it}{<-> COOKEDo}{}

\DeclareFontShape{T1}{STENCIL}{bx}{n} {<->ssub * STENCIL/b/n}{}
\DeclareFontShape{T1}{STENCIL}{bx}{sl}{<->ssub * STENCIL/b/sl}{}
\DeclareFontShape{T1}{STENCIL}{bx}{it}{<->ssub * STENCIL/b/it}{}

\endinput

t1STENCIL2.fd:

\ProvidesFile{t1STENCIL.fd}[TrueType font STENCIL]

\DeclareFontFamily{T1}{STENCIL}{}

\DeclareFontShape{T1}{STENCIL}{b}{n} {<-> COOKEDb}{}
\DeclareFontShape{T1}{STENCIL}{b}{sl}{<-> COOKEDbo}{}
\DeclareFontShape{T1}{STENCIL}{b}{it}{<-> COOKEDbo}{}

\DeclareFontShape{T1}{STENCIL}{m}{n} {<-> COOKED}{}
\DeclareFontShape{T1}{STENCIL}{m}{sl}{<-> COOKEDo}{}
\DeclareFontShape{T1}{STENCIL}{m}{it}{<-> COOKEDo}{}

\DeclareFontShape{T1}{STENCIL}{bx}{n} {<->ssub * STENCIL/b/n}{}
\DeclareFontShape{T1}{STENCIL}{bx}{sl}{<->ssub * STENCIL/b/sl}{}
\DeclareFontShape{T1}{STENCIL}{bx}{it}{<->ssub * STENCIL/b/it}{}

\endinput

t1STENCIL4.fd:

\ProvidesFile{t1STENCIL.fd}[TrueType font STENCIL]

\DeclareFontFamily{T1}{STENCIL}{}

\DeclareFontShape{T1}{STENCIL}{b}{n} {<-> COOKEDb}{}
\DeclareFontShape{T1}{STENCIL}{b}{sl}{<-> COOKEDbo}{}
\DeclareFontShape{T1}{STENCIL}{b}{it}{<-> COOKEDbi}{}

\DeclareFontShape{T1}{STENCIL}{m}{n} {<-> COOKED}{}
\DeclareFontShape{T1}{STENCIL}{m}{sl}{<-> COOKEDo}{}
\DeclareFontShape{T1}{STENCIL}{m}{it}{<-> COOKEDi}{}

\DeclareFontShape{T1}{STENCIL}{bx}{n} {<->ssub * STENCIL/b/n}{}
\DeclareFontShape{T1}{STENCIL}{bx}{sl}{<->ssub * STENCIL/b/sl}{}
\DeclareFontShape{T1}{STENCIL}{bx}{it}{<->ssub * STENCIL/b/it}{}

\endinput

I also have a comparable batch file for T1 fonts, but since you mention TTF, I did not include it here.

I also do include below a batch file for determining the name of the TTF font. Usually, the filename is the fontname, but not always, which can sometimes cause grief.

getTTfontname.bat:

@echo off
REM  This file will determine the font name of a particular TTF font file
REM
REM  This program assumes your font uses T1-WGL4 encoding, which will need
REM  editing if it is otherwise.
REM
REM  The syntax of the command is getfontname <fontfile>
REM

set SUF=
set ENCODE=T1-WGL4.enc

if "%1"=="" goto BADSYNTAX
goto CONTINUE1

:BADSYNTAX
echo One argument required: getfontname font-file
goto THEEND

:CONTINUE1

if EXIST %1 goto JUSTFINE
if EXIST %1.ttf goto FIXSTD

echo.
echo Can't find font file %1 or %1.ttf 
goto THEEND

:FIXSTD

set SUF=.ttf

:JUSTFINE

echo.
echo From reading the font, the font name has been determined as:
echo.

ttf2afm -e %ENCODE% -o Fontname.afm %1%SUF% 2>junk.out
afm2tfm Fontname.afm -T %ENCODE% Fontname.tfm 2>junk.out > fontline.out

type fontline.out | ..\sed s/Fontname// > fontname.out
FOR /F %%A in ('type fontname.out') DO (
  @echo off
  set FNTNM=%%A
)
echo %FNTNM%
echo.

del Fontname.afm Fontname.tfm junk.out fontline.out fontname.out

:THEEND

If I forgot any files, let me know.

p.s. I should just add that, after I installed a font, I kept a style file with commands like

\newcommand{\AlteSchwabacher}[1][]{\fontfamily{AlteSchwabacher}%
        #1\selectfont}

so that \Alteschwabacher would place me in that font. The optional argument is for any other specifications I want at time of invocation, for example

\fontsize{30}{36}
Related Question