在mac osx上使用latex(特别是pdflatex)生成时,pdf文档中的字体搞砸了

时间:2022-12-08 21:10:56

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!

我的同事认为texniscope是某种原因,我应该尝试从我的系统中清除它。我真的希望不要诉诸于此!

Possible clues:

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

    在升级到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.

    当我说字体搞砸了,我的意思是主文本看起来可能是默认的mac系统字体,并且所有数学都是完全不可读的。基本上所有特殊符号都是完全乱码。

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

    我从这里安装了乳胶:http://www.tug.org/mactex/。我已经安装了texniscope。

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

    当我运行/ usr / texbin / pdflatex foo.tex时,它似乎工作:

     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.

但是由此产生的pdf文件搞砸了字体。

  • The same thing happens both with pdflatex on the command line, or using TeXShop.
  • 在命令行上使用pdflatex或使用TeXShop都会发生同样的事情。

6 个解决方案

#1


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.

Apple知道这个问题,并没有计划修复它(我有一个教员花了很多时间测试并向Apple提交一个bug)。他们声称PDFTeX正在错误地嵌入字体,并且他们修复了Apple PDF库以更加严格地接受它将会接受的内容,这意味着您将继续看到在预览中使用PDFTeX创建的PDF文档的问题,TeXShop或其他使用Apple的PDF引擎显示PDF的工具。不幸的是,他们并不清楚PDFTeX究竟出错了什么,这使得修复它甚至向PDFTeX开发人员报告错误是有问题的。请注意,Adobe的Acrobat或Reader应用程序通常可以毫无问题地显示这些文档;据推测,Adobe的错误检查比Apple更为宽松。

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.

这将杀死Apple Type Services服务器守护程序(ATSServer)并生成一个新实例,巧合地重建其缓存文件。

#2


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

TUG最近发布了更新的二进制文件来修复触发字体缓存损坏的错误:http://www.tug.org/mactex/fontcache/

#3


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).

我似乎找到了答案,来自http://www.stat.duke.edu/~dmm36/tech.php,粘贴在下面。唉,似乎我不得不放弃TeXniscope。我喜欢TeXniscope比Skim好得多,因为它更简单,有更好的键盘分页用于分页,Skim让你每次出现乳胶错误时手动刷新pdf(否则Skim自动刷新)。

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

引用自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.

在最近升级到Leopard之后,乳胶(MacTeX 2007发行版)创建的pdf文件开始发生了一些非常奇怪和可怕的事情。重点是任何使用Apple的原生pdf引擎的应用程序都没有正确显示字体(例如preview.app,skim.app,Texniscope.app,LaTeXit.app,但不是adobe reader 8)。更神秘的是,同一文件可能在多个开口上呈现不同的事实。

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:

随后发生了大量的谷歌搜索,直到我在mac tex新闻组上发现了一个线程,表明问题在于损坏的字体缓存。另一个搜索带来了关于如何删除Leopard中所有字体缓存的提示。从终端发出以下命令:

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)

(如果/ usr / sbin不在你的路径中,用/ usr / sbin / lsof替换lsof)

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.

注意:这个问题的一部分似乎是TeXniscope.app搞砸了字体缓存的结果。例如,如果删除字体缓存,重新启动并在预览中打开某些内容,它看起来会很好,但只要再次在TeXniscope中打开某些内容,就会返回到绘图板。如果您遇到此问题并使用TeXniscope作为您的pdf预览器(如在aquamacs中),您应该切换到Skim作为您的pdf预览器。它非常好,Skim wiki有关于如何将它与Aquamacs集成的说明。无论如何,TeXniscope还没有得到积极的开发。

#4


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:

这个错误让我疯了。受这个提示的启发,这是我发现应对它的最好方法,即在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):

你可以在shell配置文件的shell函数中添加这个序列(我的是.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.

...只需在终端中调用atsrm以清除字体缓存。请注意,如果Skim打开,Skim会崩溃,某些应用程序可能会显示某些字符不正确,因此您必须重新启动它们。

#5


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.

在文档属性下查看Adobe Reader中的pdf。如果您有数学的类型3(?)位图字体,您需要告诉驱动程序将正确的类型1矢量字体嵌入到结果文档中。

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.

我使用乳胶与dvips然后pdf在Linux上。过去我不得不告诉它这样做,但现在看来至少ubuntu上的包有正确的字体设置。

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

在Web上查看如何将正确的字体嵌入到文档中。

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.

第二个想法,也许你没有在你的系统上安装任何字体,或者没有任何字体嵌入到文档中。

#6


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?

我对你的MacTeX问题感到有些惊讶。我最近安装了2008版本,它的工作方式就像魅力一样,无论是pdftex / latex还是xetex / latex。即使安装了以前的teTeX,字体也不成问题。你能把你的foo.tex放在某处供我们测试吗?

#1


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.

Apple知道这个问题,并没有计划修复它(我有一个教员花了很多时间测试并向Apple提交一个bug)。他们声称PDFTeX正在错误地嵌入字体,并且他们修复了Apple PDF库以更加严格地接受它将会接受的内容,这意味着您将继续看到在预览中使用PDFTeX创建的PDF文档的问题,TeXShop或其他使用Apple的PDF引擎显示PDF的工具。不幸的是,他们并不清楚PDFTeX究竟出错了什么,这使得修复它甚至向PDFTeX开发人员报告错误是有问题的。请注意,Adobe的Acrobat或Reader应用程序通常可以毫无问题地显示这些文档;据推测,Adobe的错误检查比Apple更为宽松。

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.

这将杀死Apple Type Services服务器守护程序(ATSServer)并生成一个新实例,巧合地重建其缓存文件。

#2


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

TUG最近发布了更新的二进制文件来修复触发字体缓存损坏的错误:http://www.tug.org/mactex/fontcache/

#3


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).

我似乎找到了答案,来自http://www.stat.duke.edu/~dmm36/tech.php,粘贴在下面。唉,似乎我不得不放弃TeXniscope。我喜欢TeXniscope比Skim好得多,因为它更简单,有更好的键盘分页用于分页,Skim让你每次出现乳胶错误时手动刷新pdf(否则Skim自动刷新)。

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

引用自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.

在最近升级到Leopard之后,乳胶(MacTeX 2007发行版)创建的pdf文件开始发生了一些非常奇怪和可怕的事情。重点是任何使用Apple的原生pdf引擎的应用程序都没有正确显示字体(例如preview.app,skim.app,Texniscope.app,LaTeXit.app,但不是adobe reader 8)。更神秘的是,同一文件可能在多个开口上呈现不同的事实。

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:

随后发生了大量的谷歌搜索,直到我在mac tex新闻组上发现了一个线程,表明问题在于损坏的字体缓存。另一个搜索带来了关于如何删除Leopard中所有字体缓存的提示。从终端发出以下命令:

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)

(如果/ usr / sbin不在你的路径中,用/ usr / sbin / lsof替换lsof)

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.

注意:这个问题的一部分似乎是TeXniscope.app搞砸了字体缓存的结果。例如,如果删除字体缓存,重新启动并在预览中打开某些内容,它看起来会很好,但只要再次在TeXniscope中打开某些内容,就会返回到绘图板。如果您遇到此问题并使用TeXniscope作为您的pdf预览器(如在aquamacs中),您应该切换到Skim作为您的pdf预览器。它非常好,Skim wiki有关于如何将它与Aquamacs集成的说明。无论如何,TeXniscope还没有得到积极的开发。

#4


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:

这个错误让我疯了。受这个提示的启发,这是我发现应对它的最好方法,即在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):

你可以在shell配置文件的shell函数中添加这个序列(我的是.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.

...只需在终端中调用atsrm以清除字体缓存。请注意,如果Skim打开,Skim会崩溃,某些应用程序可能会显示某些字符不正确,因此您必须重新启动它们。

#5


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.

在文档属性下查看Adobe Reader中的pdf。如果您有数学的类型3(?)位图字体,您需要告诉驱动程序将正确的类型1矢量字体嵌入到结果文档中。

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.

我使用乳胶与dvips然后pdf在Linux上。过去我不得不告诉它这样做,但现在看来至少ubuntu上的包有正确的字体设置。

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

在Web上查看如何将正确的字体嵌入到文档中。

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.

第二个想法,也许你没有在你的系统上安装任何字体,或者没有任何字体嵌入到文档中。

#6


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?

我对你的MacTeX问题感到有些惊讶。我最近安装了2008版本,它的工作方式就像魅力一样,无论是pdftex / latex还是xetex / latex。即使安装了以前的teTeX,字体也不成问题。你能把你的foo.tex放在某处供我们测试吗?