This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [docbook-apps] want to add extra fonts to docbook -> fo processing


On Sun, Jul 27, 2003 at 06:05:34PM -0400, Robert P. J. Day wrote:
> 
>   my current project consists of a sizable manual written in docbook, run
> through xsltproc to generate .fo, and finally through FOP to generate PDF.  
> so far, so good, although i'd really like to replace the default monospace
> font.
> 
>   at the moment, the default monospace courier just looks too wide and
> takes up too much space, so i'd like to replace it with the monospace font
> that o'reilly is using in their newer books -- they list it as
> "LucasFont's TheSans Mono Condensed."  although it appears that that's a
> commercial font, so i'll take anything resaonably close i don't have to
> pay for. :-)  i just want a monospace font that's noticeably narrower,
> that's all.  so how to go about this?
> 
>   first, if i want all monospaced environments to use whatever replacement
> font i come up with, i assume all i need to do is set the parameter
> 
> <xsl:param name='monospace.font.family' select="'whatever','monospace'"/>
> 
>   (at the moment, it's set to just 'monospace', so if i want to add a
> higher-priority selection, is that how i'd do it?)
> 
>   once i do the above, i assume i can redefine whatever elements i want
> using "inline.monoseq", "inline.boldmonoseq" and so on.
> 
>   so the questions:
> 
>   1) any recommendations for decent narrow monospaced fonts?
> 
>   2) what would i need to put in place of "whatever" above?  from what
>      i read, i can name the font any way i want since all i have to do
>      is use the same name in the FOP step.
> 
>   3) anyone successfully added additional fonts to FOP, based on the 
>      web page http://xml.apache.org/fop/fonts.html ??  

I don't have a narrow monospace font for you, but I
have successfully added a Truetype font to FOP.  I did
this on a Windows box, adding Arial Black.

1.  I copied c:\Windows\fonts\ariblk.ttf to my test directory.

2.  I generated the font xml file ariblk.ttf that FOP
wants using this transformation:

java -cp "../fop-0.20.5/build/fop.jar;\
../fop-0.20.5/lib/avalon-framework.jar;\
../fop-0.20.5/lib/xml-apis.jar;\
../fop-0.20.5/lib/xercesImpl.jar;\
../fop-0.20.5/lib/xalan.jar" \
org.apache.fop.fonts.apps.TTFReader \
-enc ansi \
ariblk.ttf ariblk.xml

I used fop-0.20.5, as you can see.

3.  I created a FOP config file userconfig.xml
in the test directory:

<configuration>

<fonts>
 <font metrics-file="ariblk.xml" kerning="yes" embed-file="ariblk.ttf">
    <font-triplet name="ArialBlack" style="normal" weight="normal"/>
 </font>
</fonts>

</configuration>

4.  I changed the inline.boldseq docbook template
in a customization layer to use the new font:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:fo="http://www.w3.org/1999/XSL/Format";
                version='1.0'>

<xsl:import href="../docbook-xsl-1.61.3/fo/docbook.xsl"/>

<xsl:template name="inline.boldseq">
  <xsl:param name="content">
    <xsl:apply-templates/>
  </xsl:param>
  <fo:inline font-family="ArialBlack">
    <xsl:copy-of select="$content"/>
  </fo:inline>
</xsl:template>

</xsl:stylesheet>

5.  I processed my file containing <emphasis role="bold">
with xsltproc to generate a .fo file, then 
I ran FOP 0.20.5 on the fo file with this command
(note the -c option to specify the config file):

JAVA_HOME="/c/progra~1/Java/j2re1.4.0_01" \
../fop-0.20.5/fop.sh -c userconfig.xml booktest.fo booktest.pdf

And it worked!  My emphasis was clearly a very bold
Arial Black font.

-- 

Bob Stayton                                 400 Encinal Street
Publications Architect                      Santa Cruz, CA  95060
Technical Publications                      voice: (831) 427-7796
The SCO Group                               fax:   (831) 429-1887
                                            email: bobs@sco.com

---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]