Discussion:
[Exist-open] FOP fonts configuration in 3.0 stable
Welblaud
2017-02-21 12:49:42 UTC
Permalink
Hi all,

I am in a stage of testing the new 3.0 stable release before full move to it
from 3.0RC1.

One of the most disturbing problems is the one associated with resolving
paths to fonts from inside the app.

I have found (thanks to Joe!) a couple of very useful hints (like this one
<http://gitlab.exist-db.org/tei-publisher/tei-publisher-app/blob/master/modules/config.xqm#L89-93>
) but another error is thrown. Since the beginning, the app was complaining
about /URI scheme is not "file"/, which I solved with /file:/ prefix in
FOP's config (/embed-url="file:{$something}/arial.ttf"/).

However, now it throws /URI is not hierarchical/ and I am not able to solve
that just with playing with file locations.

I tried to set the base for fonts:
/exist://localhost:8083/exist/apps/my-app/modules/resources/fonts/microsoft//

or

/http://xx.xx.xx.xx:8083/exist/apps/my-app/modules/resources/fonts/microsoft//

Nothing worked. Fonts are perfectly reachable over HTTP.

let $font-base :=
'exist://localhost:8083/exist/apps/my-app/modules/resources/fonts/microsoft/'
let $hyph-base :=
'exist://localhost:8083/exist/apps/my-app/modules/resources/hyph/'

FOP config sample:

<fop version="1.0">
<strict-configuration>true</strict-configuration>
<strict-validation>false</strict-validation>
<hyphenation-base>{$hyph-base}</hyphenation-base>
<font-base>{$font-base}</font-base>
<use-cache>false</use-cache>
<renderers>
<renderer mime="application/pdf">
{
switch ($layout)
case 'auc-geographica' return $microsoftFonts
default return ()
}
</renderer>
</renderers>
</fop>

Greetings from Prague,

Honza Hejzl



--
View this message in context: http://exist.2174344.n4.nabble.com/FOP-fonts-configuration-in-3-0-stable-tp4671447.html
Sent from the exist-open mailing list archive at Nabble.com.
Hungerburg
2017-02-22 09:15:44 UTC
Permalink
Hello Welblaud,

all I can tell is, that exist-db switched to fop2 in the new release.
Similar problems did arise in RC time and got fixed.

Did your stuff work before? Where do you configure FOP?

"Not hierarchical" means "opaque", so no path part; read RFC on what
that means.

Some have reported https://www.oxygenxml.com/forum/topic13129.html
disabling font-cache helps

Peter
Post by Welblaud
Hi all,
I am in a stage of testing the new 3.0 stable release before full move to it
from 3.0RC1.
One of the most disturbing problems is the one associated with resolving
paths to fonts from inside the app.
I have found (thanks to Joe!) a couple of very useful hints (like this one
<http://gitlab.exist-db.org/tei-publisher/tei-publisher-app/blob/master/modules/config.xqm#L89-93>
) but another error is thrown. Since the beginning, the app was complaining
about /URI scheme is not "file"/, which I solved with /file:/ prefix in
FOP's config (/embed-url="file:{$something}/arial.ttf"/).
However, now it throws /URI is not hierarchical/ and I am not able to solve
that just with playing with file locations.
/exist://localhost:8083/exist/apps/my-app/modules/resources/fonts/microsoft//
or
/http://xx.xx.xx.xx:8083/exist/apps/my-app/modules/resources/fonts/microsoft//
Nothing worked. Fonts are perfectly reachable over HTTP.
let $font-base :=
'exist://localhost:8083/exist/apps/my-app/modules/resources/fonts/microsoft/'
let $hyph-base :=
'exist://localhost:8083/exist/apps/my-app/modules/resources/hyph/'
<fop version="1.0">
<strict-configuration>true</strict-configuration>
<strict-validation>false</strict-validation>
<hyphenation-base>{$hyph-base}</hyphenation-base>
<font-base>{$font-base}</font-base>
<use-cache>false</use-cache>
<renderers>
<renderer mime="application/pdf">
{
switch ($layout)
case 'auc-geographica' return $microsoftFonts
default return ()
}
</renderer>
</renderers>
</fop>
Greetings from Prague,
Honza Hejzl
--
View this message in context: http://exist.2174344.n4.nabble.com/FOP-fonts-configuration-in-3-0-stable-tp4671447.html
Sent from the exist-open mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
https://lists.sourceforge.net/lists/listinfo/exist-open
Welblaud
2017-02-22 09:55:55 UTC
Permalink
Hello Peter,

Thank you for the tips. I tried to disable the cache but it didn't helped.

As for 'opaque' URI, am I right the problem is the URI has not a form of,
lets say, /home/user/.fonts ? If so, it makes sense. I wonder what could
solve the FOP's need to use fonts from a local filesystem or what scheme it
needs (it seems exist:// and http:// don't work).

Regarding your questions, it perfectly worked in 3.0RC1 with older FOP. I
use three broader sets of fonts there and my stylesheet scenario is rather
complex. I tried to somehow mimic the scenario in the short code I posted in
a reply to my original question. Interesting is there is no problem with
/URI scheme is not "file:"/, the font is simply not loaded at all.

Regards, Honza



--
View this message in context: http://exist.2174344.n4.nabble.com/FOP-fonts-configuration-in-3-0-stable-tp4671447p4671462.html
Sent from the exist-open mailing list archive at Nabble.com.
Welblaud
2017-02-22 10:28:15 UTC
Permalink
Peter,

I am rather disturbed by this thread
<http://apache-fop.1065347.n5.nabble.com/font-base-is-ignored-in-2-1-td43690.html>
.

If devs somehow merged <base/> and <font-base/>, it could be quite a
catastrophe for my case. In the older version I used <base/> for resolving
images (urls relative to the document) and <font-base/> for resolving uris
leading to an external directory of the app. The information in the thread
is a bit confusing.

Honza



--
View this message in context: http://exist.2174344.n4.nabble.com/FOP-fonts-configuration-in-3-0-stable-tp4671447p4671464.html
Sent from the exist-open mailing list archive at Nabble.com.
Welblaud
2017-02-22 09:29:12 UTC
Permalink
Ok, here something for testing.

It is sufficient to load that into some collection, the test file should be
stored aside the query code. Fonts in a fonts subcollection.

Fonts for testing purposes:
ftp://46.28.111.241/ariali.ttf <ftp://46.28.111.241/ariali.ttf>
ftp://46.28.111.241/arial.ttf <ftp://46.28.111.241/arial.ttf>

Code:
ftp://46.28.111.241/fop-test.xq <ftp://46.28.111.241/fop-test.xq>

This test does not reproduce the error from my app but it is also not able
to load the files. Hence I guess it could be associated with the /URI is not
hierarchical/ issue:

Greetings from Prague, H. Hejzl



--
View this message in context: http://exist.2174344.n4.nabble.com/FOP-fonts-configuration-in-3-0-stable-tp4671447p4671458.html
Sent from the exist-open mailing list archive at Nabble.com.
Joe Wicentowski
2017-02-22 17:59:38 UTC
Permalink
Hi Honza,
Post by Welblaud
I have found (thanks to Joe!) a couple of very useful hints (like this one
<http://gitlab.exist-db.org/tei-publisher/tei-publisher-app/blob/master/modules/config.xqm#L89-93>
) but another error is thrown.
I'd suggest that you try to adopt the trick shown here - loading the
fonts from their location inside
$EXIST_HOME/webapp/WEB-INF/data/expathrepo - where eXist stores the
contents of installed .xar packages on disk. The
config:get-fonts-dir() function detects that the app has been
installed as a .xar package and constructs the path to the appropriate
location for the fonts on disk (as opposed to from the database). If
it detects that the app wasn't installed via .xar, it doesn't even try
to load these fonts. You've set up your app as an .xar package, so I
think this should work for you. I wouldn't expect to a "file:" URI to
ever peek inside the eXist database (over HTTP), unless you mounted it
as a WebDAV device so it looked like a disk to the system.

Joe
Welblaud
2017-02-23 11:57:32 UTC
Permalink
This post might be inappropriate. Click to display it.
Joe Wicentowski
2017-02-23 15:03:12 UTC
Permalink
Hi Honza,
Post by Welblaud
/home/honza/eXist-db-3.0/webapp/WEB-INF/data/fs/db/system/repo/karolinum-x-0.5.xar
Can you unzip that .xar file and confirm expath-pkg.xml is there in
the top level of the unzipped directory?

It looks like this error is related to not finding expath-pkg.xml -
though I can't really tell what is being checked for (java-illiterate
here). The error is thrown here:

https://github.com/eXist-db/exist/blob/develop/src/org/exist/repo/Deployment.java#L177-L179

getDescriptor() is defined here:

https://github.com/eXist-db/exist/blob/develop/src/org/exist/repo/Deployment.java#L909-L923

Joe
Welblaud
2017-02-23 15:28:07 UTC
Permalink
Joe,

I solved the issue with package descriptor easily with uploading a bit older
package.

According to the tip (TEI PM solution), I have put together this:

module namespace fop =
'http://localhost:8081/exist/db/apps/my-app/modules/fop';

import module namespace http = 'http://expath.org/ns/http-client' at
'java:org.exist.xquery.modules.httpclient.HTTPClientModule';

declare namespace expath = "http://expath.org/ns/pkg";
declare namespace jmx = "http://exist-db.org/jmx";

declare variable $fop:app-root :=
let $rawPath := system:get-module-load-path()
let $modulePath :=
(: strip the xmldb: part :)
if (starts-with($rawPath, "xmldb:exist://")) then
if (starts-with($rawPath,
"xmldb:exist://embedded-eXist-server")) then
substring($rawPath, 36)
else
substring($rawPath, 15)
else
$rawPath
return
substring-before($modulePath, "/modules")
;

declare variable $fop:expath-descriptor := doc(concat($fop:app-root,
"/expath-pkg.xml"))/expath:package;

declare function fop:get-data-dir() as xs:string? {
try {
let $request := <http:request method="GET"
href="http://localhost:{request:get-server-port()}/{request:get-context-path()}/status?c=disk"/>
let $response := http:send-request($request)
return
if ($response[1]/@status = "200") then
let $dir := $response[2]//jmx:DataDirectory/string()
return
if (matches($dir, "^\w:")) then
(: windows path? :)
"/" || translate($dir, "\", "/")
else
$dir
else
()
} catch * {
()
}
};

declare function fop:get-repo-dir() {
let $dataDir := fop:get-data-dir()
let $pkgRoot := $fop:expath-descriptor/@abbrev || "-" ||
$fop:expath-descriptor/@version
return
if ($dataDir) then
$dataDir || "/expathrepo/" || $pkgRoot
else ()
};
declare function fop:get-fonts-dir() as xs:string? {
let $repoDir := fop:get-repo-dir()
return
if ($repoDir) then
$repoDir || "/modules/resources/fonts/microsoft"
else ()
};

Here is the code of the test itself:

xquery version "3.1";

import module namespace fop =
'http://localhost:8081/exist/db/apps/my-app/modules/fop' at
'../modules/create-pdf.xqm';

let $fontsDir := fop:get-fonts-dir()

let $doc :=
(
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-height="297mm"
page-width="210mm" margin="1in">
<fo:region-body margin-bottom="10mm"/>
<fo:region-after extent="5mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block font-family="Arial" font-weight="normal"
font-size="18pt">Some sample text I</fo:block>
<fo:block font-family="Arial" font-weight="normal"
font-style="italic">{$fontsDir}</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
)
let $fopConf :=
(
<fop version="1.0">
<strict-configuration>true</strict-configuration>
<strict-validation>false</strict-validation>
<renderers>
<renderer mime="application/pdf">
<fonts>
{
if ($fontsDir) then (

<font-triplet name="Arial"
style="normal" weight="normal"/>
,

<font-triplet name="Arial"
style="italic" weight="normal"/>
)
else ()
}
</fonts>
</renderer>
</renderers>
</fop>
)
return
xmldb:store('/db/apps/karolinum-x/', 'test.pdf', xslfo:render($doc,
'application/pdf', $fopConf))


With this, the $fontsDir path is properly pushed to the pdf result and seems
reasonably. However, there are still used only generic fonts in the result.





--
View this message in context: http://exist.2174344.n4.nabble.com/FOP-fonts-configuration-in-3-0-stable-tp4671447p4671474.html
Sent from the exist-open mailing list archive at Nabble.com.
Joe Wicentowski
2017-02-23 16:03:40 UTC
Permalink
Hi Honza,
Post by Welblaud
With this, the $fontsDir path is properly pushed to the pdf result and seems
reasonably. However, there are still used only generic fonts in the result.
Good, that's progress. What's missing in your code sample here is the
@embed-url attribute seen in the tei-publisher-app code. See:

http://gitlab.exist-db.org/tei-publisher/tei-publisher-app/blob/master/modules/config.xqm#L110-130

Without this, you're not actually providing FOP with the location of the fonts.

Joe

p.s. Some general troubleshooting techniques I found helpful when
working with XSL-FO and eXist: save the .fo source to disk, open
it in oXygen where validation issues were easily apparent, and use
fop command line tools to generate the PDF with verbose error reporting.
Here are the notes I gathered in this process:


# New strategy to be able to see fop debug messages:

- install fop via homebrew

$ brew install fop

- set fop memory by creating a ~/.foprc file:

FOP_OPTS="-Xmx1000m"
FOP_HOME="/usr/local/bin/fop"

- save fop-config.xml in working directory:

<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<auto-detect/>
</fonts>
</renderer>
</renderers>
</fop>

- run fop from command line (-d means debug, -c sets config file, -fo
precedes fo file, -pdf precedes output name):

$ fop -d -c fop-config.xml -fo frus1969-76v02.fo -pdf frus1969-76v02.pdf

# New font strategy: instead of using "autodetect", supply the precise
names and locations of my Palatino font in fop-config.xml. use the
TTFReader tool was helpful for finding out the correct names of the
contents of these files:

$ java -cp build/fop.jar:lib/avalon-framework-4.2.0.jar:lib/commons-logging-1.0.4.jar:lib/commons-io-1.3.1.jar:lib/xmlgraphics-commons-svn-trunk.jar
org.apache.fop.fonts.apps.TTFReader ~/Downloads/Palatino.ttc
~/Downloads/Palatino.xml

Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader main
INFO: TTF Reader for Apache FOP svn-trunk

Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader main
INFO: Parsing font...
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Reading /Users/joe/Downloads/Palatino.ttc...
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: This is a TrueType collection file with 4 fonts
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Containing the following fonts:
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Italic
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold Italic
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader main
SEVERE: Error while building XML font metrics file.
java.lang.IllegalArgumentException: For TrueType collection you must
specify which font to select (-ttcname)
at org.apache.fop.fonts.truetype.OpenFont.readFont(OpenFont.java:708)
at org.apache.fop.fonts.apps.TTFReader.loadTTF(TTFReader.java:217)
at org.apache.fop.fonts.apps.TTFReader.main(TTFReader.java:168)


$ java -cp build/fop.jar:lib/avalon-framework-4.2.0.jar:lib/commons-logging-1.0.4.jar:lib/commons-io-1.3.1.jar:lib/xmlgraphics-commons-svn-trunk.jar
org.apache.fop.fonts.apps.TTFReader -ttcname "Palatino Italic"
~/Downloads/Palatino.ttc ~/Downloads/Palatino.xml

Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader main
INFO: TTF Reader for Apache FOP svn-trunk

Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader main
INFO: Parsing font...
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Reading /Users/joe/Downloads/Palatino.ttc...
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: This is a TrueType collection file with 4 fonts
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Containing the following fonts:
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Italic <-- selected
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold Italic
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Font Family: [Palatino]
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader constructFontXML
INFO: Creating xml font file...
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
INFO: Creating CID encoded metrics...
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.AbstractFontReader
writeFontXML
INFO: Writing xml font file /Users/joe/Downloads/Palatino.xml...
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
INFO: This font contains no embedding license restrictions.
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
INFO:
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
INFO: XML font metrics file successfully created.

final fop-config.xml:

<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino">
<font-triplet name="Palatino" style="normal"
weight="normal"/>
</font>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino Bold">
<font-triplet name="Palatino Bold" style="normal"
weight="bold"/>
</font>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino Italic">
<font-triplet name="Palatino Italic"
style="italic" weight="normal"/>
</font>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino Bold Italic">
<font-triplet name="Palatino Bold Italic"
style="italic" weight="bold"/>
</font>
</fonts>
</renderer>
</renderers>
</fop>
Welblaud
2017-02-23 16:04:03 UTC
Permalink
Yay, Joe, it is there but nabble somehow replaced it with empty lines.

I have there:
<font kerning="yes" embed-url="file:{$fontsDir}/arial.ttf"
embedding-mode="subset">
<font-triplet name="Arial" style="normal" weight="normal"/>
</font>

Hope it won't be replaced again here.

Thanks for the tip with Oxygen!

H.

2017-02-23 17:01 GMT+01:00 Joe Wicentowski [via eXist] <
Post by Joe Wicentowski
Hi Honza,
Post by Welblaud
With this, the $fontsDir path is properly pushed to the pdf result and
seems
Post by Welblaud
reasonably. However, there are still used only generic fonts in the
result.
Good, that's progress. What's missing in your code sample here is the
http://gitlab.exist-db.org/tei-publisher/tei-publisher-
app/blob/master/modules/config.xqm#L110-130
Without this, you're not actually providing FOP with the location of the fonts.
Joe
p.s. Some general troubleshooting techniques I found helpful when
working with XSL-FO and eXist: save the .fo source to disk, open
it in oXygen where validation issues were easily apparent, and use
fop command line tools to generate the PDF with verbose error reporting.
- install fop via homebrew
$ brew install fop
FOP_OPTS="-Xmx1000m"
FOP_HOME="/usr/local/bin/fop"
<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<auto-detect/>
</fonts>
</renderer>
</renderers>
</fop>
- run fop from command line (-d means debug, -c sets config file, -fo
$ fop -d -c fop-config.xml -fo frus1969-76v02.fo -pdf frus1969-76v02.pdf
# New font strategy: instead of using "autodetect", supply the precise
names and locations of my Palatino font in fop-config.xml. use the
TTFReader tool was helpful for finding out the correct names of the
$ java -cp build/fop.jar:lib/avalon-framework-4.2.0.jar:lib/
commons-logging-1.0.4.jar:lib/commons-io-1.3.1.jar:lib/
xmlgraphics-commons-svn-trunk.jar
org.apache.fop.fonts.apps.TTFReader ~/Downloads/Palatino.ttc
~/Downloads/Palatino.xml
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader main
INFO: TTF Reader for Apache FOP svn-trunk
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader main
INFO: Parsing font...
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Reading /Users/joe/Downloads/Palatino.ttc...
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: This is a TrueType collection file with 4 fonts
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Italic
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold Italic
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader main
SEVERE: Error while building XML font metrics file.
java.lang.IllegalArgumentException: For TrueType collection you must
specify which font to select (-ttcname)
at org.apache.fop.fonts.truetype.OpenFont.readFont(OpenFont.java:708)
at org.apache.fop.fonts.apps.TTFReader.loadTTF(TTFReader.java:217)
at org.apache.fop.fonts.apps.TTFReader.main(TTFReader.java:168)
$ java -cp build/fop.jar:lib/avalon-framework-4.2.0.jar:lib/
commons-logging-1.0.4.jar:lib/commons-io-1.3.1.jar:lib/
xmlgraphics-commons-svn-trunk.jar
org.apache.fop.fonts.apps.TTFReader -ttcname "Palatino Italic"
~/Downloads/Palatino.ttc ~/Downloads/Palatino.xml
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader main
INFO: TTF Reader for Apache FOP svn-trunk
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader main
INFO: Parsing font...
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Reading /Users/joe/Downloads/Palatino.ttc...
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: This is a TrueType collection file with 4 fonts
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Italic <-- selected
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold Italic
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Font Family: [Palatino]
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader
constructFontXML
INFO: Creating xml font file...
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
INFO: Creating CID encoded metrics...
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.AbstractFontReader
writeFontXML
INFO: Writing xml font file /Users/joe/Downloads/Palatino.xml...
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
INFO: This font contains no embedding license restrictions.
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
INFO: XML font metrics file successfully created.
<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino">
<font-triplet name="Palatino" style="normal"
weight="normal"/>
</font>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino Bold">
<font-triplet name="Palatino Bold" style="normal"
weight="bold"/>
</font>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino Italic">
<font-triplet name="Palatino Italic"
style="italic" weight="normal"/>
</font>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino Bold Italic">
<font-triplet name="Palatino Bold Italic"
style="italic" weight="bold"/>
</font>
</fonts>
</renderer>
</renderers>
</fop>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email] <http:///user/SendEmail.jtp?type=node&node=4671476&i=0>
https://lists.sourceforge.net/lists/listinfo/exist-open
------------------------------
If you reply to this email, your message will be added to the discussion
http://exist.2174344.n4.nabble.com/FOP-fonts-configuration-in-3-0-stable-
tp4671447p4671476.html
n4.nabble.com
To unsubscribe from FOP fonts configuration in 3.0 stable, click here
<http://exist.2174344.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4671447&code=aG9uemEuaGVqemxAZ21haWwuY29tfDQ2NzE0NDd8LTE2MTc3NDk0Mjg=>
.
NAML
<http://exist.2174344.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
View this message in context: http://exist.2174344.n4.nabble.com/FOP-fonts-configuration-in-3-0-stable-tp4671447p4671477.html
Sent from the exist-open mailing list archive at Nabble.com.
Joe Wicentowski
2017-02-23 23:23:12 UTC
Permalink
Hi Honza,

I'm not sure where your latest update leaves you in terms of this
problem, but I'd really suggest - before trying to debug via eXist any
further, save the FO generated by your application, and use the
command line fop tool to generate your PDF, with the debug flags set
as in the notes in my previous email. You get many more hints about
problems when doing that. I wouldn't be surprised if there are
specific warnings about fonts there. It's possible your @embed-url or
font-triplet/@* attributes do not match the actual font - in which
case the fop.fonts.apps.TTFReader utility (also in my notes) can help
you probe the font files to find out what values to use for these.

Once you get the command line fop to produce the PDF as expected, then
take it back into eXist, and then you know you're dealing only with
the eXist problems. Debugging PDFs produced by fop in eXist is like
doing surgery blindfolded.

Also, an off topic: why do so many people use nabble on this list? It
messes with your text, inserts links and junk into your posts.
Subscribing to the email list and posting via email seems like the
better option to me - but maybe there's some benefit to nabble I'm not
seeing?

Joe
Post by Welblaud
Yay, Joe, it is there but nabble somehow replaced it with empty lines.
<font kerning="yes" embed-url="file:{$fontsDir}/arial.ttf"
embedding-mode="subset">
<font-triplet name="Arial" style="normal" weight="normal"/>
</font>
Hope it won't be replaced again here.
Thanks for the tip with Oxygen!
H.
Post by Joe Wicentowski
Hi Honza,
Post by Welblaud
With this, the $fontsDir path is properly pushed to the pdf result and seems
reasonably. However, there are still used only generic fonts in the result.
Good, that's progress. What's missing in your code sample here is the
http://gitlab.exist-db.org/tei-publisher/tei-publisher-app/blob/master/modules/config.xqm#L110-130
Without this, you're not actually providing FOP with the location of the fonts.
Joe
p.s. Some general troubleshooting techniques I found helpful when
working with XSL-FO and eXist: save the .fo source to disk, open
it in oXygen where validation issues were easily apparent, and use
fop command line tools to generate the PDF with verbose error reporting.
- install fop via homebrew
$ brew install fop
FOP_OPTS="-Xmx1000m"
FOP_HOME="/usr/local/bin/fop"
<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<auto-detect/>
</fonts>
</renderer>
</renderers>
</fop>
- run fop from command line (-d means debug, -c sets config file, -fo
$ fop -d -c fop-config.xml -fo frus1969-76v02.fo -pdf frus1969-76v02.pdf
# New font strategy: instead of using "autodetect", supply the precise
names and locations of my Palatino font in fop-config.xml. use the
TTFReader tool was helpful for finding out the correct names of the
$ java -cp
build/fop.jar:lib/avalon-framework-4.2.0.jar:lib/commons-logging-1.0.4.jar:lib/commons-io-1.3.1.jar:lib/xmlgraphics-commons-svn-trunk.jar
org.apache.fop.fonts.apps.TTFReader ~/Downloads/Palatino.ttc
~/Downloads/Palatino.xml
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader main
INFO: TTF Reader for Apache FOP svn-trunk
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader main
INFO: Parsing font...
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Reading /Users/joe/Downloads/Palatino.ttc...
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: This is a TrueType collection file with 4 fonts
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Italic
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold Italic
Dec 18, 2013 6:10:30 PM org.apache.fop.fonts.apps.TTFReader main
SEVERE: Error while building XML font metrics file.
java.lang.IllegalArgumentException: For TrueType collection you must
specify which font to select (-ttcname)
at org.apache.fop.fonts.truetype.OpenFont.readFont(OpenFont.java:708)
at org.apache.fop.fonts.apps.TTFReader.loadTTF(TTFReader.java:217)
at org.apache.fop.fonts.apps.TTFReader.main(TTFReader.java:168)
$ java -cp
build/fop.jar:lib/avalon-framework-4.2.0.jar:lib/commons-logging-1.0.4.jar:lib/commons-io-1.3.1.jar:lib/xmlgraphics-commons-svn-trunk.jar
org.apache.fop.fonts.apps.TTFReader -ttcname "Palatino Italic"
~/Downloads/Palatino.ttc ~/Downloads/Palatino.xml
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader main
INFO: TTF Reader for Apache FOP svn-trunk
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader main
INFO: Parsing font...
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Reading /Users/joe/Downloads/Palatino.ttc...
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: This is a TrueType collection file with 4 fonts
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Italic <-- selected
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.truetype.OpenFont checkTTC
INFO: Palatino Bold Italic
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Font Family: [Palatino]
Dec 18, 2013 5:18:34 PM org.apache.fop.fonts.apps.TTFReader
constructFontXML
INFO: Creating xml font file...
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
INFO: Creating CID encoded metrics...
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.AbstractFontReader
writeFontXML
INFO: Writing xml font file /Users/joe/Downloads/Palatino.xml...
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
INFO: This font contains no embedding license restrictions.
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
Dec 18, 2013 5:18:35 PM org.apache.fop.fonts.apps.TTFReader main
INFO: XML font metrics file successfully created.
<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino">
<font-triplet name="Palatino" style="normal"
weight="normal"/>
</font>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino Bold">
<font-triplet name="Palatino Bold" style="normal"
weight="bold"/>
</font>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino Italic">
<font-triplet name="Palatino Italic"
style="italic" weight="normal"/>
</font>
<font kerning="yes"
embed-url="file:/System/Library/Fonts/Palatino.ttc"
sub-font="Palatino Bold Italic">
<font-triplet name="Palatino Bold Italic"
style="italic" weight="bold"/>
</font>
</fonts>
</renderer>
</renderers>
</fop>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
________________________________
If you reply to this email, your message will be added to the discussion
http://exist.2174344.n4.nabble.com/FOP-fonts-configuration-in-3-0-stable-tp4671447p4671476.html
To start a new topic under exist-open, email [hidden email]
To unsubscribe from FOP fonts configuration in 3.0 stable, click here.
NAML
________________________________
View this message in context: Re: FOP fonts configuration in 3.0 stable
Sent from the exist-open mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
https://lists.sourceforge.net/lists/listinfo/exist-open
Loading...