# Convert certain newtx fonts to truetype or opentype

I've found I like the newtx package because it uses a Helvetica clone for sans-serif characters and a Times clone for the greek letters. How can I generate opentype or truetype versions of these clone fonts? I want to install them as system fonts so other applications can use them.

When I look for font files installed with the newtx package, I see that there are font definition files (.fd), font metric files (.tfm, and .afm), but there are only a few font outline files (.pfb). I can't seem to locate the font outline files for 'ntxmi' (italic math font), 'ntxmia' (upright math font), or 'ntxss' (sans-serif font). Where is pdfLaTeX grabbing these font outline files? Once I have them, what do I do with them?

In case it matters, I have font forge installed, but I am no expert on it's usage.

-

There is no outline font for that font, it is a virtual font, which means that essentially each "character" is a fragment of DVI code that combines characters from other fonts, typically (although not necessarily) each uses a glyph from one of the constituent fonts. (In special cases a single character in the virtual font may be constructed from multiple characters from possibly different fonts) The vf file also encodes spacing and positioning details.

If you look in a pdf file generated using the virtual font, you do not see the virtual font being used but instead see the constituent fonts (which for this font, and typically, are normal outline fonts).

You can convert the vf file to human readable property list form and see the constituent fonts with

``````vftovp /usr/local/texlive/2013/texmf-dist/fonts/vf/public/newtx/ntxmia.vf
``````

(Or whatever equivalent path on your system)

Of course it would in theory be possible to actually make the font using a font editor such as font forge to combine the constituents and set all the appropriate kerning, but it would essentially be a new font creation project, the existing vf file is probably not a lot of help in that.

-
I am sure you didn't mean this but that is not what a virtual font (necessarily) is. A virtual font can consist entirely of characters found in an outline font - it doesn't have to construct new characters from fragments, although that is one thing which virtual fonts can do. Many of the characters in that virtual font are characters drawn directly from the outline fonts, although others are indeed constructed from fragments. Also, a virtual font is able to combine characters from different outline fonts into a "single" font, as this one does. –  cfr Dec 31 '13 at 2:01
@cfr I'll try to make it clearer, I meant exactly what you said that a vf file uses characters from other fonts, the "fragment" referred to the fact that the vf format itself is (loosely) a fragment of dvi as if TeX had positioned the characters. –  David Carlisle Dec 31 '13 at 2:05
@cfr is that clearer? –  David Carlisle Dec 31 '13 at 2:10
Thank you for the quick reply. I obviously was not aware of virtual fonts. Perhaps I should ask Michael Sharpe (the creator of newtx) if he has truetype versions of the fonts. –  Stretch Dec 31 '13 at 2:14
@DavidCarlisle Yes, that's much clearer. Thanks. I wanted to clarify this further by actually explaining some of the instructions from the .vf file. I hope you don't mind but I put that in a supplementary answer as it was too much code for a comment. –  cfr Dec 31 '13 at 2:27

I can't put this in a comment but here is part of the output of vftopl for ntxmia.vf:

Each of these MAPFONT commands corresponds to a non-virtual font used to construct this one:

``````(MAPFONT D 0
(FONTNAME txmia)
(FONTCHECKSUM O 4141071701)
(FONTAT R 1.0)
(FONTDSIZE R 10.0)
)
(MAPFONT D 1
(FONTNAME txsyc)
(FONTCHECKSUM O 2224045220)
(FONTAT R 1.0)
(FONTDSIZE R 10.0)
)
(MAPFONT D 2
(FONTNAME txr)
(FONTCHECKSUM O 32212676346)
(FONTAT R 1.0)
(FONTDSIZE R 10.0)
)
(MAPFONT D 3
(FONTNAME ntxexb)
(FONTCHECKSUM O 624127613)
(FONTAT R 0.833)
(FONTDSIZE R 10.0)
)
(MAPFONT D 4
(FONTNAME rtxmio)
(FONTCHECKSUM O 2235410564)
(FONTAT R 1.0)
(FONTDSIZE R 10.0)
)
(MAPFONT D 5
(FONTNAME ntxsyralt)
(FONTCHECKSUM O 20635152700)
(FONTAT R 1.0)
(FONTDSIZE R 10.0)
)
(MAPFONT D 6
(FONTNAME txsyb)
(FONTCHECKSUM O 24667272411)
(FONTAT R 1.0)
(FONTDSIZE R 10.0)
)
(MAPFONT D 7
(FONTNAME ptmr8r)
(FONTCHECKSUM O 4767720433)
(FONTAT R 1.0)
(FONTDSIZE R 10.0)
)
(MAPFONT D 8
(FONTNAME zxxrl7z)
(FONTCHECKSUM O 36463136262)
(FONTAT R 1.0)
(FONTDSIZE R 10.0)
)
``````

So there are 9 fonts in use here. The one labelled with a 0 is the main, default one. That is, unless otherwise specified, characters are taken from txmia.

Here is the character assigned to the first slot (slot 0):

``````(CHARACTER O 0
(CHARWD R 0.546)
(CHARHT R 0.667999)
(CHARIC R 0.05)
(COMMENT
(KRN O 177 R 0.035)
)
(MAP
(MOVERIGHT R 0.02)
(SETCHAR O 0)
(MOVERIGHT R -0.03)
)
)
``````

This adjusts the character's position relative to its natural position in the original font. That is, TeX will move slightly before it makes a space for the character and then it will move slightly in the other direction. (As far as TeX is concerned, all characters are rectangular boxes.)

Here's a character from a later slot:

``````(CHARACTER C 6
(CHARWD R 0.636)
(CHARHT R 0.615)
(CHARDP R 0.102)
(MAP
(SELECTFONT D 1)
(SETCHAR C 1)
)
)
``````

The SELECTFONT instruction says that this character is to be taken not from txmia but, rather, from txsyc.

This character is created by combining the two previous ideas:

``````(CHARACTER O 100
(CHARWD R 0.482)
(CHARHT R 0.6925)
(CHARDP R 0.013499)
(CHARIC R -0.01)
(COMMENT
(KRN O 177 R 0.025)
)
(MAP
(MOVERIGHT R -0.01)
(SELECTFONT D 4)
(SETCHAR O 100)
(MOVERIGHT R -0.02)
)
)
``````

The character is taken from rtxmio this time, but TeX will also move somewhat before and after setting it (twice in the same direction this time).

Virtual fonts can also create entirely new characters as David Carlisle explained. For example, if a font lacks the fi ligature, you can create one by combining its f and its i in the appropriate slot in the virtual font. (Of course, it won't be a real ligature - it will just be an f followed by an i - but it will allow words such as 'fish' to be typeset easily.)

-
+1 :-)......... –  David Carlisle Dec 31 '13 at 2:28
Hmmm… I imagine the virtual fonts primarily use one font. Perhaps I will just track down that font and install it. –  Stretch Dec 31 '13 at 2:32
@Stretch You already have all of the fonts it uses. If you didn't you would get empty spaces in your DVI or PDF files. This is because the virtual fonts don't contain the actual glyphs - that is, the little pictures of each character. Those have to be got from the outline fonts themselves. You can see what this is using. The main font is txmia.pfb although many of its characters are repositioned slightly. But it is also using characters from the other 8 fonts listed. You must also have the pfb files for these fonts. –  cfr Dec 31 '13 at 2:37
Yeah, I understood the idea that I already have all the fonts. I just thought that I could avoid the effort of combining the other fonts if the characters are not commonly used. However, the fact that Michael Sharpe altered the txmia.pfb character positions means that it will never quite be right. Grrr… –  Stretch Dec 31 '13 at 3:22
In that case, I think you need to start with that requirement in mind and see what options you have. For example, you could easily do this using Latin Modern etc. because those fonts are available as opentype as well as set up for use with latex. Or if you just need a subset of characters in Illustrator, concentrate on those. But start from there rather than picking out combinations of fonts for TeX which combine stuff from various fonts. Otherwise you are just asking for unexpected (and probably aesthetically displeasing) surprises down the line. At least, that would be my approach. –  cfr Dec 31 '13 at 4:53