Fonts in pdf documents screwed up when generated with latex (specifically, pdflatex) on mac osx
Asked Answered
C

6

4

My colleague suggests that texniscope is somehow to blame and that I should try purging it from my system. I really hope not to have to resort to that!

Possible clues:

  • This wasn't an issue till I upgraded to Leopard.

  • When I say the fonts are screwed up, I mean the main text looks like maybe it's the default mac system font, and all math is completely unreadable. Basically all special symbols are completely garbled.

  • I installed latex from here: http://www.tug.org/mactex/. I had already had texniscope installed.

  • When I run /usr/texbin/pdflatex foo.tex, it seems to work:

     This is pdfTeXk, Version 3.1415926-1.40.9 (Web2C 7.5.7)
     %&-line parsing enabled.
     entering extended mode
    ...

but the resulting pdf file has screwed up fonts.

  • The same thing happens both with pdflatex on the command line, or using TeXShop.
Crossexamine answered 19/12, 2008 at 23:56 Comment(0)
P
5

Apple knows about the problem and isn't planning to fix it (I had a faculty member spend a lot of time testing and submit a bug to Apple). Their claim is that PDFTeX is embedding the fonts incorrectly, and they have fixed the Apple PDF library to be more strict about what it will and won't accept, which means that you will continue to see problems with PDF documents created with PDFTeX in Preview, TeXShop, or other tools that display PDF using Apple's PDF engine. Unfortunately, they weren't at all clear about exactly what it is that PDFTeX is doing wrong, which makes fixing it or even reporting the bug to the PDFTeX developers problematic. Note that Adobe's Acrobat or Reader applications can often display these documents without any problems; presumably Adobe's error-checking is more liberal than Apple's.

You can actually recover from this problem without rebooting, although you may see it recur with the same document in the same session. You need to run

atsutil server -shutdown

which will kill the Apple Type Services server daemon (ATSServer) and spawn a new instance, coincidentally rebuilding its cache files.

Parmenter answered 18/2, 2009 at 23:8 Comment(2)
"claim is that PDFTeX is embedding the fonts incorrectly" I would be very surprised if this is true. Acrobat 8 has no trouble working with pdfTeX files, and pdfTeX with microtype uses per-line font scaling with transformation matrices; if the fonts are embedded wrongly, that shouldn't work at all.Cambell
See my answer, the bug was indeed in pdftex :) Doesn't excuse Apple not helping pinpoint the bug though.Noel
N
3

TUG recently released updated binaries fixing the bug that triggers the font cache corruption : http://www.tug.org/mactex/fontcache/

Noel answered 16/4, 2009 at 22:29 Comment(3)
Oh! Does this mean I can use texniscope again? Skim is driving me nuts. See: https://mcmap.net/q/274173/-don-39-t-make-me-manually-abort-a-latex-compile-when-there-39-s-an-errorCrossexamine
I don't know, texniscope apparently hasn't been maintained since 2004... About Skim, that behavior is indeed annoying, I'd submit a bug/feature report to the developers about that.Noel
There are a number of ways that a font can be embedded incorrectly that can generate "renderable" documents. This can include, incorrect font metrics, incorrect outlines, incorrect subsetting, incorrect hints, incorrect licensing (ie, embedding a font that forbids embedding). Further, Acrobat may look at the font and decide "oh yeah, I know that font" and ignore it or if the font generates errors, Acrobat may say, "hey, the embedded font is wrong, but I have a database of metrics I can use to create a faux equivalent".Arborization
C
1

It seems I found the answer, from http://www.stat.duke.edu/~dmm36/tech.php, pasted below. Alas, it appears I have to give up TeXniscope. I like TeXniscope much better than Skim because it's much simpler, has better keyboard shorcuts for paging, and Skim makes you manually refresh the pdf every time there's a latex error (otherwise Skim auto-refreshes).

Quoted from http://www.stat.duke.edu/~dmm36/tech.php:

After recently upgrading to Leopard, something very strange and terrible began happening with pdf files created by latex (MacTeX 2007 distribution). The punchline is that fonts were not being displayed correctly by any application that used Apple's native pdf engine (e.g. preview.app, skim.app, Texniscope.app, LaTeXit.app, but not adobe reader 8). More mysterious was the fact that the same document could render differently on multiple openings.

Much googling ensued, until I found a thread on the mac tex newsgroup which suggested that the problem lay in corrupted font caches. Another search brought about this hint on how to delete all font caches in Leopard. From the terminal, issue the following commands:

sudo rm -rf `lsof | grep com.apple.ATS/annex.aux | grep Finder | cut -c 66-139`

(replace lsof with /usr/sbin/lsof if /usr/sbin is not in your path)

sudo rm -rf /private/var/folders/*/*/-Caches-/com.apple.ATS

And then reboot. This fixed the font problem for me.

NB: part of this problem appears to be the result of TeXniscope.app screwing up the font cache. For example, if you delete the font cache, reboot, and open something in preview it will look fine, but as soon as you open something in TeXniscope again, back to the drawing board. If you are experiencing this problem and using TeXniscope as your pdf previewer, (as in aquamacs), you should switch to Skim as your pdf previewer. It's pretty nice, and the Skim wiki has instructions for how to integrate it with Aquamacs. TeXniscope isn't under active development anyway.

Crossexamine answered 20/12, 2008 at 0:54 Comment(1)
I have occasionally had that kind of problems on Leopard even though I have never used Texniscope. It just seems to happen randomly. I have used OnyX from titanium.free.fr/pgs/english.html to clear my font caches.Comer
G
1

This bug has driven me nuts. Inspired by this hint, here is the best way I found to cope with it, namely executing the following sequence in a shell:

atsutil databases -removeUser
sudo atsutil databases -remove
atsutil server -shutdown
atsutil server -ping

You may add it this sequence in a shell function in your shell config file (mine is .zshrc):

function atsrm()
{
  atsutil databases -removeUser
  sudo atsutil databases -remove
  atsutil server -shutdown
  atsutil server -ping
}

...and simply call atsrm in a terminal to purge the font cache. Be aware that Skim will crash if it was open, and some application may display some characters improperly, so you will have to restart them.

Gladiate answered 9/2, 2010 at 16:10 Comment(0)
A
0

Look at the pdf in Adobe Reader under the document properties. If you have Type 3 (?) bitmap fonts for the math, you need to tell the driver to embed the proper Type 1 vector fonts into the resulting document.

I use latex with dvips then pdf on linux. It used to be I had to tell it to do this, but now it seems at least the package on ubuntu has the proper font setting.

Look on the web to tell you how to embed the proper fonts into the document.

On second thought, maybe you don't have any of the fonts installed on your system or none of your fonts are being embedded into the document.

Aspidistra answered 20/12, 2008 at 0:21 Comment(1)
Smart, although this turned out not to be the problem. See the answer I added.Crossexamine
B
0

I'm a bit surprised by your problem with MacTeX. I recently installed the 2008 version and it is working like a charm, be it pdftex/latex or xetex/latex. Even with the previous teTeX installed I had, fonts were not a problem. Can you put your foo.tex somewhere for us to test?

Bolero answered 20/12, 2008 at 0:46 Comment(2)
It's definitely not the fault of the tex file. See the answer I just added. It seems to be the combination of TeXniscope and Leopard. If anyone can confirm or deny that, please do let me know!Crossexamine
Confirmed. See the answer I added.Crossexamine

© 2022 - 2024 — McMap. All rights reserved.