以poppler為後端pdf軟體亂碼解決方案(okular, epdfview, evince...)

來源:互聯網
上載者:User

註:因為okular, epdfview, evince的pdf功能均由xpdf的分支poppler提供,所以這裡以poppler來代稱這些軟體。kpdf下沒有測試過,因為我現在直接用okular。
poppler官方網站:http://poppler.freedesktop.org/
 
和很朋友一樣,poppler的亂碼是我最不願意看到的。
後來我看了軟體依賴情況,認識到okular等都是以poppler為後端。
poppler的官方有如下說明:
 
http://freedesktop.org/wiki/Software/poppler
 
QUOTE:
Suggested Fontconfig font substitutions
Poppler is using fontconfig to do the font searching on the system for fonts that are not embedded into the pdf files. This is a list of recommended font substitutions that distributions/users should have in their fontconfig configuration
也就是說,poppler從fontconfig的設定檔中讀取字型取代pdf裡的字型。於是,我們也只需要配好了字型替代就可以了。這一點和openoffice裡相似,openoffice除了接受他自己的字型替代外,也接受這種fontconfig的字型替代。
 
如果你已經裝了很多windows的字型,基本上你不會有亂碼的情況。如果你沒有裝,就要字型替代了。上文的官方wiki提供了替代的方法,當然前提是你安裝了poppler-data,否則還是無法顯示中文。
 
下面給出我的設定檔。
 
為所有中文指定一個或幾個字型
 
CODE:
<match target="font">
  <test name="lang" equal="any" compare="eq">
    <string>zh</string> <!--指定語言,另外也可以為ja, ko指定-->
  </test>
  <edit name="spacing">
    <const>proportional</const>
  </edit>
  <edit name="globaladvance">
    <bool>false</bool>
  </edit>
  <edit name="family" mode="prepend" binding="strong"><!--這裡用的是strong-->
    <string>AR PL ShanHeiSun Uni</string><!--我的中文字型-->
  </edit>
</match>
單獨為用楷體情況指定
 
CODE:
<match target="pattern">
  <test name="family">
    <string>KaiTi_GB2312</string>
    <string>STXingkai</string>
    <string>STXinwei</string>
  </test>
  <edit name="family" mode="prepend" binding="same">
    <string>AR PL ZenKai Uni</string>
  </edit>
</match>
當然,我還把我中文字型裡的英文換成漂亮的英文字型。
 
更正:kpdf不是以poppler為後端。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.