2

I am new to TeX, working on an iPhone/iPad app that displays pages from a collection of PDF documents. Every PDF document in the collection contains one or more math expressions. Each PDF file is fairly small, but the overall collection has thousands of files.

Using a default LaTeX configuration, each file ends up containing about 3 - 8 subsetted Postscript Type 1 fonts (Latin Modern, Computer Modern, etc.), and there is a lot of repetition of fonts from file to file.

I'm trying an experiment to see if we can decrease the overall size of the document collection (note that another obvious solution, merging the small PDF files into larger PDF files is problematic for reasons I won't go into here):

Starting with iOS 13, apps are allowed to install fonts. I may be able to decrease the size of the overall collection by not embedding any fonts in the individual PDF documents. Instead, my app would install the fonts that are needed and, hopefully, iOS' PDF display framework (PDFKit) will pick up on all fonts needed to display the PDF documents from its environment. (In the PDF spec, viewers are supposed to default to searching for fonts in the display environment if they cannot be found within the document.)

One limitation is that iOS' new font management framework only works with what Apple calls "modern" fonts: TrueType and OpenType. Several of the fonts that TeX uses by default (Computer Modern, Latin Modern, etc.) cannot be installed because they are Postscript Type 1 fonts, which Apple apparently considers to be a non-"modern" 1980's technology.

For this experiment, I created a simple test file that uses unicode-math and OpenType fonts (which required switching from using LaTeX to LuaLaTeX). I'm not sure it was necessary to use unicode-math, but it was an easy way to bring in several OpenType font packages:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{texgyrepagella-regular.otf}
\usepackage{unicode-math}
\usepackage{mathtools}
\setmathfont{texgyrepagella-math.otf}

\begin{document}
Here comes a math expression:
\[x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}\]
\end{document}

I am running into some snags, and need help with the following questions:

Question 1: When I generate a PDF file using the source above, then look at it with the Properties/Fonts dialog in Acrobat Reader, I do see the TeXGyrePagella fonts listed, but they are described as "Type 1 (CID)". I was expecting the description to say something like "OpenType". I assume that "Type 1 (CID)" is a more specific description of one kind of OpenType font. Can anyone confirm my assumption? (See screenshot at the end of this question.)

Question 2: How can I generate a PDF file in which the fonts are not embedded at all? I see a lot of advice on tex.stackexchange about how to generate PDF files where the entire font is embedded with no subsetting, but I want to do the opposite: I don't want any fonts to be embedded.

Question 2b: Experimenting with LaTeX, I was able to eliminate some of the embedded fonts by using the \pdfcompresslevel=0 and \pdfobjcompresslevel=0 commands. What is the equivalent of these commands in the LuaLaTeX environment?

Screenshot of Adobe Reader Properties/Fonts dialog:

2

Please try to restrict questions to one question in the future, but they are closely related, so I'll answer anyway.

Why is Type 1 (CID) used instead of OpenType? It is possible to directly import OpenType fonts in PDF files, but that is not done in any TeX engine I know. Instead, especially for Type 1 based OpenType fonts (typically font files ending with .otf instead of .ttf), only the actual glyph data (in CFF format (CFF is a compresssed version of Type 1)) is extracted from the OpenType file and included into the PDF file directly, without being wrapped into the OpenType structure. This is only a small subset of the information available in OpenType fonts, especially information about Ligatures/Kerning is lost. (That's mostly done for compatibility and because these information aren't necessary: All font layout/ligature/kerning stuff is already handled by TeX itself, so there is no point in adding this information.)

Can you disable font embedding? Yes, but you shouldn't. The conversion from OpenType to a pure CFF font and some other internal changes LuaTeX does to a font lead to a situation, where everything works fine if the font is embedded, but a separate font most likely wouldn't work, either because it has a different format is therefore isn't found or because some values changed and therefore the font is displayed incorrectly. Also PDF files access external OpenType fonts in another way than internal fonts and the specification leaves some aspects implementation defined, so TeX would have basically no way to reliably select the right glyph from external OpenType fonts, even if it would set everything up to use OpenType fonts directly. If you still want to try, see Force lualatex to **not embed** fonts

The LuaTeX equivalent to

\pdfcompresslevel=0
\pdfobjcompresslevel=0

is

\pdfvariable compresslevel=0
\pdfvariable objcompresslevel=0

but it is often better to do the same thing using l3pdf which works on almost all engines:

\usepackage{l3pdf}
\ExplSyntaxOn
\pdf_uncompress:
\ExplSyntaxOff

But disabling compression would not eliminate any embedded fonts, so I'm not sure what you are trying to archive there.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.