2015-03-31 73 views
0

我正確的說,使用XSL-FO(Apache FOP)生成時,無法使用Windows 7中的字體c:\ windows \ fonts *一個pdf?XSL-FO:如何添加「helvetica neue」字體並輸出爲pdf

我剛剛安裝了OTF格式的「helvetica neue」字體。

根據 https://xmlgraphics.apache.org/fop/trunk/fonts.html

「系統字體的支持依靠的字體度量信息在Java AWT子系統,通過操作系統註冊,AWT子系統知道哪些字體在系統上可用,並且字體指標

當使用支持系統字體的渲染器(參見上表)並且缺少字體時,可以將其安裝在操作系統中,並且應該可用於這些渲染器。對於只支持自定義字體的輸出格式(例如PDF或PostScript)不適用。「

如果我的理解是正確的,就是說如果我的渲染是PDF(意思是輸出是PDF ??),那麼我不能通過AWT/OS訪問字體,因此我將無法生成在PDF中使用Windows 7字體的這種字體的文本?

------------------------------更新,這隻適用於ttf字體,不適用於otf。 不知道如何讓otf字體工作。

-----------------------------更新:20150402:

使用FOP 1.1:

我下載這個特殊的免費Helvetica Neue字體的字體來源: http://www.ephifonts.com/free-helvetica-font-helvetica-neue.html

我配置FOP使用fop.xconf但我得到一個錯誤處理的ttf文件,我不知道如何來編輯fontforge的字體TTF文件:

fop -c fop.xconf -xml xml.xml -xsl coversheet.xsl -pdf輸出。 PDF

Apr 2, 2015 6:53:55 PM org.apache.fop.fonts.truetype.TTFFile readCMAP 
SEVERE: Unsupported TrueType font: No Unicode or Symbol cmap table not present. Aborting 
Apr 2, 2015 6:53:55 PM org.apache.fop.events.LoggingEventListener processEvent 
WARNING: Unable to load font file: file:/C:/windows/FONTS/HelveticaNeue.ttf. Reason: java.io.IOException: TrueType font is not supported: file:/C:/windows/FONTS/HelveticaNeue.ttf 

Apr 2, 2015 6:53:55 PM org.apache.fop.fonts.truetype.TTFFile getTTCnames 
INFO: This is a TrueType collection file with 4 fonts 

感謝

+0

你已經試過了嗎?但是我會說你的解釋是正確的,在渲染PDF時沒有辦法訪問系統字體。但是,您仍然可以在FOP配置中將Helvetica Neue註冊爲自定義字體。 – 2015-03-31 22:04:43

+0

我試過了,能夠插入ttf格式的字體,但是我不能輸出otf字體文件。我認爲這個文檔已經過時了。 – Derick 2015-03-31 23:37:25

+0

那麼爲什麼不將OTF字體轉換爲TTF,然後將其用作自定義字體呢? – 2015-04-01 08:51:46

回答

0

(初步公開:我是一個FOP開發商)

Am I correct that it's not possible to use fonts from windows 7 c:\windows\fonts* when using XSL-FO (Apache FOP) to generate a pdf?

字體需要,以便被配置爲識別和FOP使用,但配置可以是真的是簡單:您可以告訴FOP查看特定目錄中的所有字體文件(甚至遞歸)或s意味着在「平常」的地方尋找字體。

此配置片段是從你的問題聯同font configuration page採取:

<renderers> 
    <renderer mime="application/pdf"> 
    <fonts> 
     <!-- register all the fonts found in a directory --> 
     <directory>C:\MyFonts1</directory> 

     <!-- register all the fonts found in a directory and all of its sub directories (use with care) --> 
     <directory recursive="true">C:\MyFonts2</directory> 

     <!-- automatically detect operating system installed fonts --> 
     <auto-detect/> 
    </fonts> 
    </renderer> 
</renderers> 

你可以找到關於this answer字體配置的其它詳情。

Update, this works only for ttf font, not otf. Not sure how I can get otf fonts to work.

OpenType字體支持已添加到版本2.0中。

+0

已下載www.ephifonts.com/free-helvetica-font-helvetica-neue.html但出現錯誤:org.apache.fop.fonts.truetype.TTFFile readCMAP SEVERE:不支持的TrueType字體:無Unicode或符號cmap表不存在。正在中止 org.apache.fop.events.LoggingEventListener processEvent 警告:無法加載字體文件:file:/ C:/windows/FONTS/HelveticaNeue.ttf。原因:java.io.IOException:不支持TrueType字體:file:/ C:/windows/FONTS/HelveticaNeue.ttf org.apache.fop.fonts.truetype.TTFFile getTTCnames 請參閱上面的更新。不知道如何使用字體僞造來編輯 – Derick 2015-04-03 02:06:25

+0

免費helvetica neue字體來自http://www.ephifonts.com/free-helvetica-font-helvetica-neue.html,但顯然,它不適用於fop 1.1 – Derick 2015-04-03 02:21:28

+0

lfurini,我只是想和你確認一下,當你說「在FOP-1.1發佈之後添加了OTF支持」時,這意味着fop 1.1將支持otf,無論我是否獲得每晚構建。我下載了最新的穩定版本。 – Derick 2015-04-03 02:28:24

相關問題