3

I have recently downloaded a font from https://www.dafont.com, which, when I call it into my document, requires the fontspec package and compilation with lualatex. This has caused several problems, most of which (though not all), I have been able to take care of.

I don't know if this is possible, but I am trying to find a way to call in the aforesaid font into my document without using fontspec.

Consider the following code:

\documentclass{book}

\ifdefined\directlua \usepackage{fontspec} \else \usepackage[T1]{fontenc} \usepackage[nomath]{lmodern} \fi

\newfontfamily\CloisterBlack{CloisterBlack.ttf} \begin{document} \thispagestyle{empty} \huge \CloisterBlack{How to Use This Font without Fontspec?} \end{document}

which when compiled with lualatex produces the following result:

enter image description here

I thought, perhaps, that I might replace \usepackage{fontspec} package with \usepackage[T1]{fontenc}\usepackage[nomath]{lmodern}, but when I compile the code with pdflatex I get an error.

QUESTION: How (if possible) may I invoke an externally downloaded font into a document and compile it without using fontspec? (I thought I found a way by replacing fontspec with unicode-math until I discovered that the latter package automatically loads the prior). Suggestions are welcome.

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36
  • 4
    If you want to use pdflatex you need to produce various support files (e.g. with autoinst) and install them if you want to use such a font. This requires some skills about the pdflatex font handling. With lualatex you should use fontspec and solve whatever problem you have with it. – Ulrike Fischer Feb 28 '22 at 13:03
  • I'm sure this answer is long out of date: https://tex.stackexchange.com/questions/95327/displaying-medieval-scriptures-and-neumes-in-tex/100943#100943 And this: https://tex.stackexchange.com/questions/106002/convert-matematical-pi-6-font-type1-into-vf-files/106077#106077 ...but they may give you a gist of how one might proceed. – Steven B. Segletes Feb 28 '22 at 13:31
  • you have \newfontfamily\CloisterBlack{CloisterBlack.ttf} in the wrong place that has to be in the \ifdefined\directlua branch obviously it can not work if \newfontfamily is not defined and pdflatex can not read ttf gonts. – David Carlisle Feb 28 '22 at 13:38
  • @StevenB.Segletes Thank you for providing these two posts. I had looked at several others before posting the question and most of the one that were applicable to my question were over ten years old. – DDS Feb 28 '22 at 13:39
  • You are welcome. The first change I would make is to ditch the T1-WGL4.enc encoding that I used and use something more standard. – Steven B. Segletes Feb 28 '22 at 13:41
  • You are asking the wrong question. The question is not how can you use the font wothout fontspec (that is relatively easy) the question is how can you use the font in pdftex (the answer is that you can not, without first building some 8bit font metics for some specified subset, as tex can not read ttf fonts). – David Carlisle Feb 28 '22 at 13:41
  • @DavidCarlisle Is it a matter of shifting it some other place or must I add other things as well? – DDS Feb 28 '22 at 13:41
  • shift to the luatex branch and use luatex – David Carlisle Feb 28 '22 at 13:42
  • @David Carlisle lualatex is fine with me if I can use the font without fontspec as fontspec has caused problems. This is easy to solve?? I just thought of pdflatex as a possible alternative because it does not handle fontspec. – DDS Feb 28 '22 at 13:45
  • 2
    fontspec is not your issue at all the problem is that tex is an 8bit system where a "font" is an array of 256 things and a Unicode Truetype or OpenType font is nothing like that at all. as with any tex you can load a font using font primitives but that will cut out all of latex's font handling so if you want \bfseries or \itshape to do the right thing using fontspec is the thing to do, if you are having issues with fontspec you probably have errors in your other code so the fix is probably not to avoid fontspec, but instead to fix whatever is causing the error. – David Carlisle Feb 28 '22 at 13:48
  • @David Carlisle How does one shift to the lautex branch using TexStudio? All my compiler choices right now have "latex" in their names. I'll keep looking as my text editor is, I'm sure, more archaic than yours. Thank you for your very helpful comment. – DDS Feb 28 '22 at 13:49
  • No I mean shift your \newfontfamily command into the \ifdefined\directlua branch of your code so that it is only used where it is defined. That is a fontspec command so just use it in the branch where you load fontspec. – David Carlisle Feb 28 '22 at 13:51
  • @David Carlisle Thanks. That compiles in the MWE. Now I must see if it I can get it to help in the document. – DDS Feb 28 '22 at 13:55
  • also font family commands are like \fmfamily and have no argument, your use of \CloisterBlack{How to Use This Font without Fontspec?} ABC will not generate an error but the braces do nothing useful and ABC will also be in the font. – David Carlisle Feb 28 '22 at 13:56
  • @David Carlisle Thanks. I didn't think of that. – DDS Feb 28 '22 at 13:57
  • @StevenB.Segletes Thank you for the information regarding T1-WGL4.enc – DDS Feb 28 '22 at 13:59

1 Answers1

9

In pdftex (i.e. 8bit TeX) the font management is 100times more complicated than in luaTeX because there is decal of long development into a dead end. You have to manage tfm files, enc files, map files, pfb files, vf files etc. I hope that you don't want to do this.

But if you want this then I show you more simplified management (without virtual fonts and with fixed enc file existed in TeXlive). Run on command line:

otftotfm --no-virtual -e xl2 CloisterBlack.ttf cloister

This creates the file cloister.tfm. Keep it in actual directory. Then you can try:

\ifx\directlua\undefined
  \pdfmapline{=cloister  CloisterBlack "XL2encoding ReEncodeFont" <xl2.enc <CloisterBlack.ttf}
  \font\cl=cloister
\else
  \input luafonts  % initializing extended \font primitive
  \font\cl=[CloisterBlack]
\fi

{\cl How to Use This Font without Fontspec?}

\bye

You can use pdftex or luatex for testing this. Note that in neither case did I use fontspec.

wipet
  • 74,238