embedding fonts in PDF output
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 63
- Joined: Sat Jan 24, 2004 12:10 am
- Location: Oaxaca, Mexico
- Contact:
embedding fonts in PDF output
I would like to create PDF output with embedded fonts (specifically Lucida Grande) Is there any way I can do this with FOP (or XEP)?
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi Ron,
I think we have an article about how to do that with FOP on the documentation page:
http://www.oxygenxml.com/documentation.html
Check the How to Add a Font to the <oXygen/> Built-in FOP article:
http://www.oxygenxml.com/doc/addFontToFOP.pdf
Best Regards,
George
I think we have an article about how to do that with FOP on the documentation page:
http://www.oxygenxml.com/documentation.html
Check the How to Add a Font to the <oXygen/> Built-in FOP article:
http://www.oxygenxml.com/doc/addFontToFOP.pdf
Best Regards,
George
-
- Posts: 63
- Joined: Sat Jan 24, 2004 12:10 am
- Location: Oaxaca, Mexico
- Contact:
-
- Posts: 60
- Joined: Wed Jan 28, 2004 10:51 pm
-
- Posts: 63
- Joined: Sat Jan 24, 2004 12:10 am
- Location: Oaxaca, Mexico
- Contact:
David - thanks for the ref to the XEP manal, I'll try that when I get the fop working
George -back to embedding fonts in fop
I tried following the 'How To' you pointed out and get a fail: (see fail message at bottom)
MacOS X 10.3.9 G4
dainzu:/~ ron$ cd /Library/Fonts
dainzu:/Library/Fonts ron$ ls -l
total 26864
-rwxrwxrwx 1 root admin 534828 17 Sep 2003 AmericanTypewriter.dfont
-rwxrwxrwx 1 root admin 333686 17 Sep 2003 Apple Chancery.dfont
-rwxrwxrwx 1 root admin 190500 17 Sep 2003 Apple Symbols.ttf
.
.
-rwxrwxrwx 1 root admin 1145248 25 Jan 2005 LucidaGrande.ttf
-rwxrwxrwx 1 root admin 1139952 25 Jan 2005 LucidaGrandeBold.ttf
.
.
-rwxrwxrwx 1 root admin 524806 17 Sep 2003 Zapfino.dfont
-rwxrwxrwx 1 root admin 10668 12 Nov 2004 fonts.cache-1
dainzu:/~ ron$ cd /Applications/Utilities/oxygen/oxygen\ 7.0
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 root# ls -l Oxygen.app/Contents/Resources
total 1192
-rw-r--r-- 1 ron admin 49151 11 May 2005 Oxygen.icns
-rw-r--r-- 1 ron admin 51451 20 Dec 03:40 OxygenCSS.icns
-rw-r--r-- 1 ron admin 41434 11 May 2005 OxygenDTD.icns
-rw-r--r-- 1 ron admin 53708 24 Aug 06:11 OxygenNRL.icns
-rw-r--r-- 1 ron admin 53845 24 Aug 06:11 OxygenRNC.icns
-rw-r--r-- 1 ron admin 53925 24 Aug 06:11 OxygenRNG.icns
-rw-r--r-- 1 ron admin 53821 24 Aug 06:11 OxygenSCH.icns
-rw-r--r-- 1 ron admin 52124 11 May 2005 OxygenWSDL.icns
-rw-r--r-- 1 ron admin 41625 11 May 2005 OxygenXML.icns
-rw-r--r-- 1 ron admin 41625 24 Aug 06:11 OxygenXQUERY.icns
-rw-r--r-- 1 ron admin 41611 11 May 2005 OxygenXSD.icns
-rw-r--r-- 1 ron admin 41274 11 May 2005 OxygenXSL.icns
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ mkdir Oxygen.app/Contents/Resources/Java
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 root# ls -ld Oxygen.app/Contents/Resources/Java
drwxr-xr-x 2 root ron 68 27 Jan 08:03 Oxygen.app/Contents/Resources/Java
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ which java
/usr/bin/java
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ cat ttfConvert.sh
#!/bin/sh
export LIB=oxygen.app/Contents/Resources/Java
export CMD="java -cp $LIB/fop.jar:$LIB/avalon-framework.jar:$LIB/xml-apis.jar:"
export CMD="$CMD$LIB/xercesImpl.jar:$LIB/xalanOxygen.zip org.apache.fop.fonts.apps.TTFReader"
export FONT_DIR='/Library/Fonts'
$CMD $FONT_DIR/LucidaGrande.ttf LucidaGrande.xml
$CMD $FONT_DIR/LucidaGrandeBold.ttf LucidaGrandeBold.xml
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ cat fopConfiguration.xml
<configuration>
<fonts>
<font metrics-file="LucidaGrande.xml" kerning="yes" embed-file="file:/Library/Fonts/LucidaGrande.ttf">
<font-triplet name="LucidaGrande" style="normal" weight="normal" />
</font>
<font metrics-file="LucidaGrandeBold.xml" kerning="yes" embed-file="file:/Library/Fonts/LucidaGrandeBold.ttf">
<font-triplet name="LucidaGrandeBold" style="normal" weight="bold" />
</font>
</fonts>
</configuration>
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ sh ttfConvert.sh
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fop/fonts/apps/TTFReader
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fop/fonts/apps/TTFReader
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$
George -back to embedding fonts in fop
I tried following the 'How To' you pointed out and get a fail: (see fail message at bottom)
MacOS X 10.3.9 G4
dainzu:/~ ron$ cd /Library/Fonts
dainzu:/Library/Fonts ron$ ls -l
total 26864
-rwxrwxrwx 1 root admin 534828 17 Sep 2003 AmericanTypewriter.dfont
-rwxrwxrwx 1 root admin 333686 17 Sep 2003 Apple Chancery.dfont
-rwxrwxrwx 1 root admin 190500 17 Sep 2003 Apple Symbols.ttf
.
.
-rwxrwxrwx 1 root admin 1145248 25 Jan 2005 LucidaGrande.ttf
-rwxrwxrwx 1 root admin 1139952 25 Jan 2005 LucidaGrandeBold.ttf
.
.
-rwxrwxrwx 1 root admin 524806 17 Sep 2003 Zapfino.dfont
-rwxrwxrwx 1 root admin 10668 12 Nov 2004 fonts.cache-1
dainzu:/~ ron$ cd /Applications/Utilities/oxygen/oxygen\ 7.0
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 root# ls -l Oxygen.app/Contents/Resources
total 1192
-rw-r--r-- 1 ron admin 49151 11 May 2005 Oxygen.icns
-rw-r--r-- 1 ron admin 51451 20 Dec 03:40 OxygenCSS.icns
-rw-r--r-- 1 ron admin 41434 11 May 2005 OxygenDTD.icns
-rw-r--r-- 1 ron admin 53708 24 Aug 06:11 OxygenNRL.icns
-rw-r--r-- 1 ron admin 53845 24 Aug 06:11 OxygenRNC.icns
-rw-r--r-- 1 ron admin 53925 24 Aug 06:11 OxygenRNG.icns
-rw-r--r-- 1 ron admin 53821 24 Aug 06:11 OxygenSCH.icns
-rw-r--r-- 1 ron admin 52124 11 May 2005 OxygenWSDL.icns
-rw-r--r-- 1 ron admin 41625 11 May 2005 OxygenXML.icns
-rw-r--r-- 1 ron admin 41625 24 Aug 06:11 OxygenXQUERY.icns
-rw-r--r-- 1 ron admin 41611 11 May 2005 OxygenXSD.icns
-rw-r--r-- 1 ron admin 41274 11 May 2005 OxygenXSL.icns
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ mkdir Oxygen.app/Contents/Resources/Java
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 root# ls -ld Oxygen.app/Contents/Resources/Java
drwxr-xr-x 2 root ron 68 27 Jan 08:03 Oxygen.app/Contents/Resources/Java
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ which java
/usr/bin/java
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ cat ttfConvert.sh
#!/bin/sh
export LIB=oxygen.app/Contents/Resources/Java
export CMD="java -cp $LIB/fop.jar:$LIB/avalon-framework.jar:$LIB/xml-apis.jar:"
export CMD="$CMD$LIB/xercesImpl.jar:$LIB/xalanOxygen.zip org.apache.fop.fonts.apps.TTFReader"
export FONT_DIR='/Library/Fonts'
$CMD $FONT_DIR/LucidaGrande.ttf LucidaGrande.xml
$CMD $FONT_DIR/LucidaGrandeBold.ttf LucidaGrandeBold.xml
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ cat fopConfiguration.xml
<configuration>
<fonts>
<font metrics-file="LucidaGrande.xml" kerning="yes" embed-file="file:/Library/Fonts/LucidaGrande.ttf">
<font-triplet name="LucidaGrande" style="normal" weight="normal" />
</font>
<font metrics-file="LucidaGrandeBold.xml" kerning="yes" embed-file="file:/Library/Fonts/LucidaGrandeBold.ttf">
<font-triplet name="LucidaGrandeBold" style="normal" weight="bold" />
</font>
</fonts>
</configuration>
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ sh ttfConvert.sh
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fop/fonts/apps/TTFReader
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fop/fonts/apps/TTFReader
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello Ron,
just like in the Windows and Linux versions of the file. The lib directory was moved out of oxygen.app in a previous version but the LIB variable remained the same in the article. We will correct it.
Regards,
Sorin
The LIB variable must contain the path to the directory containing the files fop.jar, avalon-framework.jar, etc, that is the lib folder sibling of oxygen.app. You should not create it yourself with mkdir. Please use in ttfConvert.sh:catterall wrote:dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ mkdir Oxygen.app/Contents/Resources/Java
...
dainzu:/Applications/Utilities/oxygen/oxygen 7.0 ron$ cat ttfConvert.sh
#!/bin/sh
export LIB=oxygen.app/Contents/Resources/Java
export CMD="java -cp $LIB/fop.jar:$LIB/avalon-framework.jar:$LIB/xml-apis.jar:"
export CMD="$CMD:$LIB/xercesImpl.jar:$LIB/xalanOxygen.zip org.apache.fop.fonts.apps.TTFReader"
Code: Select all
export LIB=lib
Regards,
Sorin
-
- Posts: 63
- Joined: Sat Jan 24, 2004 12:10 am
- Location: Oaxaca, Mexico
- Contact:
Tried that with ttfConvert.sh -
dainzu:/Applications/Utilities/oxygen/6.2/oxygen ron$ cat ttfConvert.sh
#!/bin/sh
export LIB=lib
export CMD="java -cp $LIB/fop.jar:$LIB/avalon-framework.jar:$LIB/xml-apis.jar:"
export CMD="$CMD$LIB/xercesImpl.jar:$LIB/xalanOxygen.zip org.apache.fop.fonts.apps.TTFReader"
export FONT_DIR='/Library/Fonts'
$CMD $FONT_DIR/LucidaGrande.ttf LucidaGrande.xml
$CMD $FONT_DIR/LucidaGrandeBold.ttf LucidaGrandeBold.xml
dainzu:/Applications/Utilities/oxygen/6.2/oxygen ron$
all I get now is -
dainzu:/Applications/Utilities/oxygen/6.2/oxygen ron$ sh ttfConvert.sh
TTF Reader v1.1.1
Reading /Library/Fonts/LucidaGrande.ttf...
Number of glyphs in font: 2826
Unicode cmap table not present
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:507)
at java.util.ArrayList.get(ArrayList.java:324)
at org.apache.fop.fonts.TTFFile.createCMaps(TTFFile.java:449)
at org.apache.fop.fonts.TTFFile.readFont(TTFFile.java:439)
at org.apache.fop.fonts.apps.TTFReader.loadTTF(TTFReader.java:222)
at org.apache.fop.fonts.apps.TTFReader.main(TTFReader.java:184)
TTF Reader v1.1.1
Reading /Library/Fonts/LucidaGrandeBold.ttf...
Number of glyphs in font: 2826
Unicode cmap table not present
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:507)
at java.util.ArrayList.get(ArrayList.java:324)
at org.apache.fop.fonts.TTFFile.createCMaps(TTFFile.java:449)
at org.apache.fop.fonts.TTFFile.readFont(TTFFile.java:439)
at org.apache.fop.fonts.apps.TTFReader.loadTTF(TTFReader.java:222)
at org.apache.fop.fonts.apps.TTFReader.main(TTFReader.java:184)
dainzu:/Applications/Utilities/oxygen/6.2/oxygen ron$
and the files LucidaGrande.xml and LucidaGrandeBold.xml are not created
dainzu:/Applications/Utilities/oxygen/6.2/oxygen ron$ cat ttfConvert.sh
#!/bin/sh
export LIB=lib
export CMD="java -cp $LIB/fop.jar:$LIB/avalon-framework.jar:$LIB/xml-apis.jar:"
export CMD="$CMD$LIB/xercesImpl.jar:$LIB/xalanOxygen.zip org.apache.fop.fonts.apps.TTFReader"
export FONT_DIR='/Library/Fonts'
$CMD $FONT_DIR/LucidaGrande.ttf LucidaGrande.xml
$CMD $FONT_DIR/LucidaGrandeBold.ttf LucidaGrandeBold.xml
dainzu:/Applications/Utilities/oxygen/6.2/oxygen ron$
all I get now is -
dainzu:/Applications/Utilities/oxygen/6.2/oxygen ron$ sh ttfConvert.sh
TTF Reader v1.1.1
Reading /Library/Fonts/LucidaGrande.ttf...
Number of glyphs in font: 2826
Unicode cmap table not present
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:507)
at java.util.ArrayList.get(ArrayList.java:324)
at org.apache.fop.fonts.TTFFile.createCMaps(TTFFile.java:449)
at org.apache.fop.fonts.TTFFile.readFont(TTFFile.java:439)
at org.apache.fop.fonts.apps.TTFReader.loadTTF(TTFReader.java:222)
at org.apache.fop.fonts.apps.TTFReader.main(TTFReader.java:184)
TTF Reader v1.1.1
Reading /Library/Fonts/LucidaGrandeBold.ttf...
Number of glyphs in font: 2826
Unicode cmap table not present
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:507)
at java.util.ArrayList.get(ArrayList.java:324)
at org.apache.fop.fonts.TTFFile.createCMaps(TTFFile.java:449)
at org.apache.fop.fonts.TTFFile.readFont(TTFFile.java:439)
at org.apache.fop.fonts.apps.TTFReader.loadTTF(TTFReader.java:222)
at org.apache.fop.fonts.apps.TTFReader.main(TTFReader.java:184)
dainzu:/Applications/Utilities/oxygen/6.2/oxygen ron$
and the files LucidaGrande.xml and LucidaGrandeBold.xml are not created
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello Ron,
I cannot find the files LucidaGrande.ttf and LucidaGrandeBold.ttf in the font directory of Windows or Mac OS. I think they are not standard fonts. In order to try to see what is wrong please send the two .ttf files to support at oxygenxml dot com.
Regards,
Sorin
I cannot find the files LucidaGrande.ttf and LucidaGrandeBold.ttf in the font directory of Windows or Mac OS. I think they are not standard fonts. In order to try to see what is wrong please send the two .ttf files to support at oxygenxml dot com.
Regards,
Sorin
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
Thank you for the files. As you discovered and told us in an email the TrueType font files that you are trying to configure to Apache FOP for inclusion into a generated PDF document don't include a character map for mapping the characters of the font to Unicode, which the TTF reader embedded in FOP requires. The same script works fine for Unicode enabled TrueType fonts, for example Arial Unicode. There are tools for converting an existing character map table but not for creating such a table. I think you will have to use Unicode enabled fonts with Apache FOP.
I hope that helps,
Sorin
Thank you for the files. As you discovered and told us in an email the TrueType font files that you are trying to configure to Apache FOP for inclusion into a generated PDF document don't include a character map for mapping the characters of the font to Unicode, which the TTF reader embedded in FOP requires. The same script works fine for Unicode enabled TrueType fonts, for example Arial Unicode. There are tools for converting an existing character map table but not for creating such a table. I think you will have to use Unicode enabled fonts with Apache FOP.
I hope that helps,
Sorin
-
- Posts: 3
- Joined: Thu Mar 01, 2007 8:59 pm
- Location: Hannover, Germany
Converting Mac fonts
I found a way to "fix" Mac fonts, that often are bundled in resource or .dfont files or don't have the correct encoding. You need two programs: Fondu and FontForge, both can be installed via Fink (http://fink.sourceforge.net). And this is how it works:
Extract the Font on the command line with fondu (Fonts that are .dfont bundles or resource bundles need extraction, fonts with the .ttf suffix don't need this step):
Fondu will extract the ttf files from the font
Try extracting the metrics. if you get the following error messages: you must reencode the font with fontforge:
Start x11 and fontforge. Open the ttf file.
Select "Encoding -> Reencode -> Windows Latin (ANSI)".
Select "File -> Generate Fonts" and save the font as ttf or type1 font.
Extract the Font on the command line with fondu (Fonts that are .dfont bundles or resource bundles need extraction, fonts with the .ttf suffix don't need this step):
Code: Select all
fondu path/to/font
Fondu will extract the ttf files from the font
Try extracting the metrics. if you get the following error messages:
Code: Select all
Unicode cmap table not present
Unsupported format: Aborting
Start x11 and fontforge. Open the ttf file.
Select "Encoding -> Reencode -> Windows Latin (ANSI)".
Select "File -> Generate Fonts" and save the font as ttf or type1 font.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Converting Mac fonts
Post by sorin_ristache »
What happens with the characters that are not included in the Windows Latin (that is CP-1252) encoding if the font contains such characters?thesaint wrote:Select "Encoding -> Reencode -> Windows Latin (ANSI)".
Regards,
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service