This answer might be a bit late, but I just ran into the same problem; the only way I found to embed non-standard fonts (to display greek and other languages) is to modify the xslfoTransformPipelineStage in order to point to the right userconfig.xml; apparently fop ignores changes to userconfig.xml in the fop.jar file.
Jan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1 create ex c:\babeldoc\build\conf with userconfig.xml
<!--<!DOCTYPE configuration SYSTEM "config.dtd">-->
<!--
this file contains templates which allow an user easy
configuration of Fop. Actually normally you don't need this configuration
file, but if you need to change configuration, you should
always use this file and *not* config.xml.
Usage: java org.apache.fop.apps.Fop -c userconfig.xml -fo fo-file -pdf pdf-file
-->
<configuration>
<!--
baseDir: normally the base directory is the directory where the fo file is
located. if you want to specify your own, uncomment this entry.
This value can also be a URL. Actually, the value is converted to
a URL.
-->
<!--
hyphenation directory
if you want to specify your own directory with hyphenation pattern
then uncomment the next entry and add the directory name
-->
hi,
howto to use userconfig.xml for using external font in xslfotransform stage.
dom.
Hi,
This answer might be a bit late, but I just ran into the same problem; the only way I found to embed non-standard fonts (to display greek and other languages) is to modify the xslfoTransformPipelineStage in order to point to the right userconfig.xml; apparently fop ignores changes to userconfig.xml in the fop.jar file.
Jan
hello
the solution which I use :
1 create ex c:\babeldoc\build\conf with userconfig.xml
<!--<!DOCTYPE configuration SYSTEM "config.dtd">-->
<!--
this file contains templates which allow an user easy
configuration of Fop. Actually normally you don't need this configuration
file, but if you need to change configuration, you should
always use this file and *not* config.xml.
Usage: java org.apache.fop.apps.Fop -c userconfig.xml -fo fo-file -pdf pdf-file
-->
<configuration>
<!--
baseDir: normally the base directory is the directory where the fo file is
located. if you want to specify your own, uncomment this entry.
This value can also be a URL. Actually, the value is converted to
a URL.
-->
<entry>
<key>baseDir</key>
<value>c:\\babeldoc\\build\\conf</value>
</entry>
<!--
fontBaseDir: Similar to baseDir, except that this value is used for fonts. If
it isn't specified, the value from baseDir is used.
-->
<!--
<entry>
<key>fontBaseDir</key>
<value>C:\\WINDOWS\\Fonts</value>
</entry>
-->
<!--
************************************************************************
HYPHENATION
************************************************************************
-->
<!--
hyphenation directory
if you want to specify your own directory with hyphenation pattern
then uncomment the next entry and add the directory name
-->
<!--
<entry>
<key>hyphenation-dir</key>
<value>/java/xml-fop/hyph</value>
</entry>
-->
<!--
************************************************************************
Add fonts here
************************************************************************
-->
<fonts>
<font metrics-file="bc3of92.xml" kerning="yes" embed-file="C:\WINDOWS\Fonts\BC3of92.ttf">
<font-triplet name="BC3of92" style="normal" weight="normal"/>
</font>
<!-- example -->
<!--
<font metrics-file="arial.xml" kerning="yes" embed-file="arial.ttf">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>
<font metrics-file="arialb.xml" kerning="yes" embed-file="arialb.ttf">
<font-triplet name="Arial" style="normal" weight="bold"/>
<font-triplet name="ArialMT" style="normal" weight="bold"/>
</font>
<font metrics-file="ariali.xml" kerning="yes" embed-file="ariali.ttf">
<font-triplet name="Arial" style="italic" weight="normal"/>
<font-triplet name="ArialMT" style="italic" weight="normal"/>
</font>
<font metrics-file="arialbi.xml" kerning="yes" embed-file="arialbi.ttf">
<font-triplet name="Arial" style="italic" weight="bold"/>
<font-triplet name="ArialMT" style="italic" weight="bold"/>
</font>
-->
<!-- Example Japanese fonts
<font metrics-file="msgothic.xml" embed-file="D:\winnt\font\msgothic.ttc" kerning="yes">
<font-triplet name="Gothic" style="normal" weight="normal"/>
<font-triplet name="Gothic" style="normal" weight="bold"/>
<font-triplet name="Gothic" style="italic" weight="normal"/>
<font-triplet name="Gothic" style="italic" weight="bold"/>
</font>
<font metrics-file="msmincho.xml" embed-file="Cyberbit.ttf" kerning="yes">
<font-triplet name="Mincho" style="normal" weight="normal"/>
<font-triplet name="Mincho" style="normal" weight="bold"/>
<font-triplet name="Mincho" style="italic" weight="normal"/>
<font-triplet name="Mincho" style="italic" weight="bold"/>
</font>
-->
</fonts>
</configuration>
and in xslfoTransformPipelineStage
try {
InputSource xmlSource = new InputSource(new ByteArrayInputStream(
this.getDocument().getBytes()));
ByteArrayOutputStream baos = new ByteArrayOutputStream(bufsize);
//Driver driver = new Driver(xmlSource, baos);
Driver driver = new Driver();
org.apache.fop.configuration.Configuration.put("baseDir","/babeldoc/build/conf");
File userConfigFile = new File("/babeldoc/build/conf/userconfig.xml");
//org.apache.fop.configuration.Configuration.put("baseDir","E:\\babeldoc\\build\\conf");
//File userConfigFile = new File("E:\\babeldoc\\build\\conf\\userconfig.xml");
//org.apache.fop.configuration.Configuration.put("baseDir", properties.getProperty("basedir"));
//File userConfigFile = new File( properties.getProperty("userConfig"));
Options options = new Options(userConfigFile);
//Options options = new Options();
options.loadUserconfiguration(userConfigFile);
driver.setLogger(new MyLogger());
driver.setRenderer(outputType);
driver.setInputSource(xmlSource);
driver.setOutputStream(baos);
driver.run();
dom.
Helllo,
That's exactly what I am doing; I have put some more abstraction by putting all the properties as options in the pipeline stage.
Jan