在 TeX 中显示中世纪经文和纽姆

在 TeX 中显示中世纪经文和纽姆

我们有一位朋友正在尝试用 LaTeX 撰写他的博士论文。在他的论文中,他必须使用古老的经文和中世纪的音乐符号 (neumes)。不幸的是,对于他必须使用的那种 neumes (St. Gallen Neumes),没有任何软件包。所以我们正在寻找一些 (很棒的) 人,他们可以帮助我们找到一种在 TeX/PDF 中显示这些经文的方法。

我们已经发现,有一种方法可以通过图形和 Corel Draw 创建自己的 TTF,但这不足以稍后在 PDF 中显示它们,对吗?

符号应出现在歌词上方(类似于简单的和弦符号)。

有人有什么想法吗?

答案1

我不知道是否适合将非 TeX 编程语言包含在本网站中,但大约 6 年前我编写了 PC 批处理文件来获取 TTF 文件并将其安装到我的 PC 上以供 LaTeX 使用。我使用的是 MiKTeX,因此文件位置可能依赖于它,也可能不依赖于它。该程序是供我自己使用的,因此必须对其进行自定义以供您自己使用(文件位置、目录名称等)。如果您有任何疑问,我可能需要一段时间才能找到答案,因为我已经很多年没有使用它了。好消息是我用它在 W2K 系统上安装了 100 多种字体,所以我知道如果解决了问题,它就可以正常工作。我不能保证您会成功,但欢迎您使用它。

如果您要安装单一字体,或者安装字体系列的最多四种字体(我没有超出这个范围),它会提供选项。

它需要 的​​副本sed.exe,您可以从 gnu 获得,以及像ttf2tfm和 这样的程序ttf2afm,它们已经存在。它还会调用我的一些模板文件,它会编辑和使用这些模板文件,因此我也会将它们包括在下面。开始吧...

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

我也有用于 T1 字体的类似批处理文件,但由于您提到了 TTF,所以我没有将其包含在此处。

我还在下面包含了一个用于确定 TTF 字体名称的批处理文件。通常,文件名就是字体名称,但并非总是如此,这有时会造成麻烦。

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

如果我忘记了任何文件,请告诉我。

我应该补充一点,在我安装字体之后,我保存了一个带有类似命令的样式文件

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

这样就\Alteschwabacher可以将我置于该字体中。可选参数用于我在调用时想要的任何其他规范,例如

\fontsize{30}{36}

相关内容