TransWikia.com

How to change font encoding in pdflatex?

TeX - LaTeX Asked by user21455 on May 26, 2021

Consider two identical tex files file1.tex and file2.tex:

documentclass[10pt]{article}
begin{document}
    Hello World
end{document}

The following two methods can be used to generate a pdf file from these identical
tex files

Method 1

pdflatex file1.tex

Method 2

latex file2.tex
dvips file2.dvi
ps2pdf file2.ps

On a machine with TeX Live 2015, these methods generate pdf files with
different font encoding, i.e., the outputs of

   pdffonts file1.pdf
   pdffonts file2.pdf

have different ‘encoding’. While file1.pdf has Builtin encoding, file2.pdf has WinAnsi encoding. What change in the texfile will force pdflatex to generate pdfs with WinAnsi encoding? Related posts 1, 2, 3, and 4, don’t seem to help.

One Answer

I’m going to do a frame challenge here. You (practically) never want to do that.

Your file in either of those cases is actually going to use a font in the OT1 encoding. There are no fonts that ship with TeX in the Windows-1252 encoding. If your PDF reader thinks the document is using a different encoding than it really is, that’s not good. It might not be that bad (things like copy-and-paste will break, but maybe you can live with that), but it’s not good.

Could you create your own Type-1 font in the Windows-1252 encoding? Technically you could, but it’d be a lot of effort for no benefit. Modern fonts come encoded in Unicode, not a legacy 8-bit code page. Older Windows fonts used Microsoft’s TrueType instead of the Adobe Type-1 format that PDFTeX does. There aren’t any free, Type-1, Windows-1252 fonts that you could legally upload with your document sources. If you tried to use the first 255 characters in a modern font, they would map to the Latin-1 encoding, which is a subset of Windows-1252 but lacks some important characters, such as opening and closing quotes or em and en dashes.

But, if you’re not required to submit sources that compile in PDFTeX, there’s absolutely nothing forcing you to use legacy 8-bit fonts. If you were able to use Windows-1252, you would be able to just use modern fonts with LuaLaTeX and unicode-math.

Answered by Davislor on May 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP