Getting special characters in PDF output.

Having trouble installing Oxygen? Got a bug to report? Post it all here.
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Getting special characters in PDF output.

Post by PeterRobertson »

I need to get some special characters in my PDF output.

In particular, I need to generate a line that starts with a solid right-pointing triangle. I have tried the following in my xml file:

Code: Select all

<screen>
&#x25B8;
</screen>
and

Code: Select all

<screen>
&rtrif;
<\screen>
both of which generate PDF output that gives a line starting with #.

How do I get the correct character?
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Peter,

You need to use a font that knows how to render that character. You may find helpful the following article:
http://www.oxygenxml.com/doc/addFontToFOP.pdf

Best Regards,
George
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

I have two problems when trying to follow your suggestion:

1: It seems to be replacing the font for the whole document.
All I want to do is to be able to use ONE character from a different
font. The actual character is unicode &#x25BA; (a solid, right-pointing
triangle).

2: I have used "impact.ttf" as a font that includes the character I want.
When trying to display the output PDF, Acrobat gives the errors:
"A font required for font substitution is missing" and then "Cannot find or
create the font '1Ef314Impact'". I have no idea where this strange name
is being generated.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

The procedure explained in the article replaces the font for the whole document. To use a font only for a character in the PDF output you have to manually enclose that character alone in a <fo:block> element with the desired font-family in the intermediate FO document generated by the DocBook XSL stylesheet for FO output and received as input by the FOP processor. This manual modification is necessary because the DocBook stylesheet does not allow such a level of output control. In <oXygen/> you can do that by disabling FO processing in the transformation scenario - the FO Processor tab of the Edit scenario dialog, applying the scenario, modifying the generated FO document, then creating and applying a new transformation scenario on the FO document. In this scenario FO processing must be enabled and the radio button Edited document as input must be selected.

Best Regards,
Sorin
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

If I understand what you have said, I would have to change each appearance of the character manually whenever I wish to generate the PDF file. The character appears over 200 times! This would render Docbook useless for any large project.

I hope I have misunderstood.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

PeterRobertson wrote:When trying to display the output PDF, Acrobat gives the errors: "A font required for font substitution is missing" and then "Cannot find or create the font '1Ef314Impact'". I have no idea where this strange name is being generated.
Finally I reproduced the error. You can see the error message

Code: Select all


[ERROR] Failed to embed font [19] Impact: etc.
in the <oXygen/> message panel if you enable FOP output in <oXygen/> - see the section Enable the output of the built-in FOP in the User Guide:

http://www.oxygenxml.com/doc/ug-oxygen/ ... arted.html

The path to the file impact.ttf is wrong in your FOP configuration file. This path must be specified relative to the source DocBook XML document. For example if docbook.xml is located in C:\Program Files\Oxygen 5.1\test\ and impact.ttf is located in C:\Windows\Fonts then you must specify in the FOP configuration file

Code: Select all

embed-file="../../../Windows/Fonts/impact.ttf"
Best Regards,
Sorin
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

PeterRobertson wrote:I would have to change each appearance of the character manually whenever I wish to generate the PDF file. The character appears over 200 times! This would render Docbook useless for any large project.
Probably enclosing the special character in a <para> tag with a role attribute and providing special handling for all these para elements in a DocBook customization layer is enough and no manual modification of the FO document is needed.

I hope this helps,
Sorin
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

Thanks. That sounds more like it. I shall look into using "role".

On the question of finding the ttf files, if the path is relative to the original
Docbook document, (i.e., the one containing "<!DOCTYPE book ...") it
implies that I must have separate copies of the fonts for every different
document I am creating, either that, or I can only put my documents in
one directory, neither of which is very pleasant.
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Characters from different fonts

Post by PeterRobertson »

Thanks to your help I have now managed to get the character from a different font into my document.

To do this I have added the new font to my FOP configuration:

Code: Select all

<configuration>
<fonts>
<font metrics-file="impact.xml" kerning="yes"
embed-file="../../Windows/fonts/impact.TTF">
<font-triplet name="impact" style="normal" weight="normal"/>
</font>
</fonts>
</configuration>
I now define a 'special' role for a para:

Code: Select all

<xsl:template match="para[@role = 'special']">
<fo:inline>
<xsl:attribute name="font-family">impact</xsl:attribute>
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
and then create an entity:

Code: Select all

<!ENTITY THING '<para role = "special">&#9658;</para>'>
I can now include the special character in text using:

Code: Select all

<para> The special character &THING; is used for ...</para>
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

PeterRobertson wrote:On the question of finding the ttf files, if the path is relative to the original Docbook document, (i.e., the one containing "<!DOCTYPE book ...") it implies that I must have separate copies of the fonts for every different document I am creating, either that, or I can only put my documents in one directory, neither of which is very pleasant.
Or you can specify an absolute path in the embed-file attribute so you don't have to put your documents in one directory or have copies of the fonts:

Code: Select all


embed-file="file:/C:/Windows/Fonts/impact.ttf"
Best Regards,
Sorin
Post Reply