Installing License, Installing Fonts
Hi there
I can't wait to start trying Prince. We're running it on Red Hat ES 3 on our real server, and White Box Enterprise Linux on our test server.
I'm a pro PHP programmer who has survived in the guts/code of Linux where necessary, but after installing Prince easily (via: "rpm -ivh prince-6.0r2-1.rhel3.i386.rpm") I'm at a total loss for the next steps.
Firstly, obviously the first thing I wanted to do was make a test pdf. But I quickly encountered the fonts issue... and I'm stuck on it. I've downloaded msttcorefonts-2.0-1.spec and tried to build it ("rpmbuild -bb msttcorefonts-2.0-1.spec") however it fails; I get a "RPM Build Errors: Bad exit status from /var/tmp/rpm-tmp.32349 (%prep)"
So... I figured I'd leave that for a moment and just install the license file ("license.dat"). However, I have no idea where Prince was installed!!! My email says to place it in "lib/prince/license", but I don't have a "lib/prince" directory. How do I know where Prince was installed to?
So, I'm flummoxed on two points. I've even successfully installed the Liberation fonts (mentioned in another post: it appears i cannot add a URL to my first forum pierce) which i thought would solve my fonts problem. They seem like they're installed, but I still get a "prince: internal error: no available fonts" when trying to make a (first) PDF.
Any help appreciated!!!
It seems Prince installed to "/usr/lib/prince" and not "/lib/prince"... Not a problem (I presume)...
Still desperately trying to get the fonts installed properly.....
Do you have fontconfig or any other font-management tools installed? There isn't a magic fonts path on Linux like there is Windows. Unless you have X or other font-using programs, none of the font tools are even installed.
Alternatively, you can reference the full paths in your CSS to the .ttf files.
@font-face {
font-family: sans-serif;
font-style: normal;
font-weight: normal;
src: url("/usr/share/fonts/truetype/msttcorefonts/trebuc.ttf")
}
I would install Fontconfig, though. That way you don't have to modify paths every time you move a CSS file between machines.
kmmv wrote:
Do you have fontconfig or any other font-management tools installed? There isn't a magic fonts path on Linux like there is Windows. Unless you have X or other font-using programs, none of the font tools are even installed.
It appears I have "xfs" installed, because I issued a "/sbin/service xfs reload" after installing the Red Hat font package.
kmmv wrote:
Alternatively, you can reference the full paths in your CSS to the .ttf files.
I would install Fontconfig, though. That way you don't have to modify paths every time you move a CSS file between machines.
I'll try googling on how to install Fontconfig. I assume that is different from (yet compatible with) "xfs"? I too would like to avoid referencing the pull paths in the CSS; it would be nice to make PDFs without thinking too much about the font paths!!
I think I have fontconfig installed, on my test server at least:
> locate fontconfig
/usr/lib/libfontconfig.so.1.0.4
/usr/lib/libfontconfig.so.1
As suggested, I defined the font locations explicitly in Prince's "fonts.css" file, and ported the "Microsoft Core Fonts" TTF files directly from my Windows machine to a directory on my Linux box.
... so I can now generate (ugly) PDFs. I think this solves all my problems; getting rpmbuild for "rpmbuild -bb msttcorefonts-2.0-1.spec" to work is no longer necessary since I managed to procure TTF files myself.
Now I'm off to learn how to make pretty PDFs. Thanks for the help (and reading).
For future reference, you can query a list of the files installed by an RPM by running either of these commands:
rpm -qlp prince-6.0r2-1.rhel3.i386.rpm
rpm -ql prince-6.0r2-1
This can be handy for seeing exactly what has been or will be installed by a particular package.
silverRocket wrote:
I think I have fontconfig installed, on my test server at least:
> locate fontconfig
/usr/lib/libfontconfig.so.1.0.4
/usr/lib/libfontconfig.so.1
That may or may not be installed. When you do $> locate fc-cache, does it find anything? (alternatively: $> whereis fc-cache) If fc-cache is found, it may just need to be run, $> fc-cache. fc-cache updates the fontconfig cache. If $> locate fontconfig only found 2 files, fc-cache probably hasn't been run. You should have some directories in /var/cache or /var/db or wherever else your OS happens to store cache/db type files.
We got our Prince installation working using the fonts.css file. This worked well for chinese fonts (though some pages had problems). We weren't quite sure which font family name to add the chinese font urls to, but found sans-serif seemed to work.
However, we'd like to use fontconfig, as it would appear to require less manual maintenance.
Fontconfig is installed on our system, but no fonts were listed with "fc-list". We extended the path listing with the appropriate <dir> tags, and re-ran "fc-list". Now we could see all our fonts, including the chinese fonts. We also ran "fc-cache" to rebuild the fontconfig cache. We then removed the sans-serif family declarations from fonts.css and tried to evaluate a chinese page again.
However, without fonts.css to direct Prince to the fonts on disk, we found all glyphs were substuted with "?" characters.
Is there something further we need to do to get Prince and fontconfig talking?
(We're using Fedora Core 3)
Cheers
Andy
You can see if Prince is picking up system fonts by using the --debug command-line option, which will print a list of fonts that have been detected with fontconfig. However, Prince does not yet automatically choose fonts for every possible character, so for rendering Chinese text you will need to specify a font family like "MingLiU" on Windows or "AR PL KaitiM Big5" on Linux.
In the future we hope to make this process a bit easier, by choosing a font automatically. However, it's difficult for Prince to know which font to choose. For example, whether to choose a simplified or traditional font for Chinese text.
For now we have added some Chinese fonts to both the "serif" and "sans-serif" font family definitions in fonts.css. This works for both chinese sites we tested (
http://www.google.cn &
http://www.zhongsou.com/)
For our own development we will of course have more influence over which font should be used, as we control the stylesheet.
Cheers
Andy