You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by FOPUser <sr...@gmail.com> on 2015/12/15 05:14:30 UTC

FOP Special characters rendering

We are currently using FOP 1.0 for PDF generation. One of the requirements
for our application is to support  special characters. The special
characters are part of the content that the application receives from a
third party. So, we don’t know where special characters occurs in the
content. The requirement is the render the  special characters in the PDF .
While, testing the special characters we found all, the special characters
from the Symbol fonts are rendered as ‘#’ in the PDF.   From the logs it is
clear  non availability of the glyps are the reason for special characters
rendered as #.  The symbol fonts are part of the  14 base fonts and doesn’t
need any additional configuration. Appreciate any help that will help us
move forward on this.
	I am using the example from the
https://xmlgraphics.apache.org/fop/quickstartguide.html and below are
examples and output from PDF generation.

name.xml:
<name>Ohm unicode - "&#x2126;"    Omega decimal code- "&#937;"</name>

name2fo.xsl:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">
    <fo:root>
      <fo:layout-master-set>
        <fo:simple-page-master master-name="A4-portrait"
              page-height="29.7cm" page-width="21.0cm" margin="2cm">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="A4-portrait">
        <fo:flow flow-name="xsl-region-body">
          <fo:block>
             <xsl:value-of select="name"/>
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>
</xsl:stylesheet>

Output:
C:\fop -xml name.xml -xsl name2fo.xsl -pdf name.pdf

Dec 14, 2015 9:49:55 PM org.apache.fop.events.LoggingEventListener
processEvent
WARNING: Glyph "?" (0x2126, Ohm) not available in font "Helvetica".
Dec 14, 2015 9:49:55 PM org.apache.fop.events.LoggingEventListener
processEvent
WARNING: Glyph "?" (0x3a9, Omegagreek) not available in font "Helvetica".
Dec 14, 2015 9:49:55 PM org.apache.fop.events.LoggingEventListener
processEvent
INFO: Rendered page #1.
name.pdf <http://apache-fop.1065347.n5.nabble.com/file/n43155/name.pdf>  
name.pdf <http://apache-fop.1065347.n5.nabble.com/file/n43155/name.pdf>  



--
View this message in context: http://apache-fop.1065347.n5.nabble.com/FOP-Special-characters-rendering-tp43155.html
Sent from the FOP - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: FOP Special characters rendering

Posted by FOPUser <sr...@gmail.com>.
please see the attachment for name.xml. In the original post, the unicode
characters are replaced by the ohm symbol. name.xml
<http://apache-fop.1065347.n5.nabble.com/file/n43156/name.xml>  



--
View this message in context: http://apache-fop.1065347.n5.nabble.com/FOP-Special-characters-rendering-tp43155p43156.html
Sent from the FOP - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: FOP Special characters rendering

Posted by Klaus Malorny <Kl...@knipp.de>.
On 16/12/15 21:24, Andreas Delmelle wrote:
>
> In the mentioned case for the OP, it seems as if he may be best off
> using a Unicode font that contains glyphs for a very wide range of
> codepoints. [...]
>

Sure, but I thought the use of the built-in fonts was a must. While I 
don't know the licensing status of Arial Unicode, there should be 
various free and visually good fonts be available (DejaVu could be a 
candidate).

Klaus

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: FOP Special characters rendering

Posted by Andreas Delmelle <an...@telenet.be>.
> <snip />
> Haven't used it in a while, but the "font-family" attribute allows multiple fonts to be specified, with the later ones as a fallback if the characters are not available in the former. So maybe you are lucky with specifying "Helvetica, Symbol"... When I used it years ago there was a small catch, namely that FOP stayed in the fallback font as long as it also contained the subsequent characters (which was not exactly what I wanted). So if, for example, your symbol was followed by digits, which are also present in the symbol font, they would have be rendered with this font (looking different to Helvetica's digits). I don't know whether this has been solved in the meantime.

Yeah, and there is another catch I noticed if you stick with the Base14 fonts and switch between Symbol and Helvetica (or Times): the baseline alignment of the symbols seems to be a bit out of whack, unless you use explicit fo:inlines, which somehow automagically corrects this. No such issue with the TrueType Symbol font on my system, though...

In the mentioned case for the OP, it seems as if he may be best off using a Unicode font that contains glyphs for a very wide range of codepoints. Depends a bit on what platform you are on, but if it is Windows, then a font like 'Arial Unicode' should do the job, I think. With font auto-detection, one should be able to use most of the system-installed fonts. (Note - Have a JIRA issue open --FOP-2540-- to improve this on OS X (and possibly also Linux), which has several fonts using different CTABs than Windows; or better: similar CTABs, but simply with a non-supported platform/encoding ID...)



KR

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: FOP Special characters rendering

Posted by Klaus Malorny <Kl...@knipp.de>.
On 15.12.2015 05:33, Glenn Adams wrote:
> You need to use a font that has a glyph for each character. None of the "base
> 14" fonts do so.
>
> Also, FYI, please provide example input in terms of FO content, not XSL input.
>
> On Mon, Dec 14, 2015 at 9:14 PM, FOPUser <srinivas.challa@gmail.com
> <ma...@gmail.com>> wrote:
>
>     We are currently using FOP 1.0 for PDF generation. One of the requirements
>     for our application is to support  special characters. The special
>     characters are part of the content that the application receives from a
>     third party. So, we don’t know where special characters occurs in the
>     content. The requirement is the render the  special characters in the PDF .
>     While, testing the special characters we found all, the special characters
>     from the Symbol fonts are rendered as ‘#’ in the PDF.   From the logs it is
>     clear  non availability of the glyps are the reason for special characters
>     rendered as #.  The symbol fonts are part of the  14 base fonts and doesn’t
>     need any additional configuration. Appreciate any help that will help us
>     move forward on this.
>             I am using the example from the
>     https://xmlgraphics.apache.org/fop/quickstartguide.html and below are
>     examples and output from PDF generation.
>
> [...]

Haven't used it in a while, but the "font-family" attribute allows multiple 
fonts to be specified, with the later ones as a fallback if the characters are 
not available in the former. So maybe you are lucky with specifying "Helvetica, 
Symbol"... When I used it years ago there was a small catch, namely that FOP 
stayed in the fallback font as long as it also contained the subsequent 
characters (which was not exactly what I wanted). So if, for example, your 
symbol was followed by digits, which are also present in the symbol font, they 
would have be rendered with this font (looking different to Helvetica's digits). 
I don't know whether this has been solved in the meantime.

Otherwise, -- as a hack -- I would search and wrap the special characters in the 
XSL/T style sheet. With XSL/T 2, this is quite simple by adding a rule for 
text() nodes and using the <xsl:analyze-string> mechanism. I once used it to 
flip Arabic text when FOP didn't supported RTL text well enough.

Klaus


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: FOP Special characters rendering

Posted by Glenn Adams <gl...@skynav.com>.
You need to use a font that has a glyph for each character. None of the
"base 14" fonts do so.

Also, FYI, please provide example input in terms of FO content, not XSL
input.

On Mon, Dec 14, 2015 at 9:14 PM, FOPUser <sr...@gmail.com> wrote:

> We are currently using FOP 1.0 for PDF generation. One of the requirements
> for our application is to support  special characters. The special
> characters are part of the content that the application receives from a
> third party. So, we don’t know where special characters occurs in the
> content. The requirement is the render the  special characters in the PDF .
> While, testing the special characters we found all, the special characters
> from the Symbol fonts are rendered as ‘#’ in the PDF.   From the logs it is
> clear  non availability of the glyps are the reason for special characters
> rendered as #.  The symbol fonts are part of the  14 base fonts and doesn’t
> need any additional configuration. Appreciate any help that will help us
> move forward on this.
>         I am using the example from the
> https://xmlgraphics.apache.org/fop/quickstartguide.html and below are
> examples and output from PDF generation.
>
> name.xml:
> <name>Ohm unicode - "&#x2126;"    Omega decimal code- "&#937;"</name>
>
> name2fo.xsl:
>
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet version="1.0"
>       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>       xmlns:fo="http://www.w3.org/1999/XSL/Format">
>   <xsl:output method="xml" indent="yes"/>
>   <xsl:template match="/">
>     <fo:root>
>       <fo:layout-master-set>
>         <fo:simple-page-master master-name="A4-portrait"
>               page-height="29.7cm" page-width="21.0cm" margin="2cm">
>           <fo:region-body/>
>         </fo:simple-page-master>
>       </fo:layout-master-set>
>       <fo:page-sequence master-reference="A4-portrait">
>         <fo:flow flow-name="xsl-region-body">
>           <fo:block>
>              <xsl:value-of select="name"/>
>           </fo:block>
>         </fo:flow>
>       </fo:page-sequence>
>     </fo:root>
>   </xsl:template>
> </xsl:stylesheet>
>
> Output:
> C:\fop -xml name.xml -xsl name2fo.xsl -pdf name.pdf
>
> Dec 14, 2015 9:49:55 PM org.apache.fop.events.LoggingEventListener
> processEvent
> WARNING: Glyph "?" (0x2126, Ohm) not available in font "Helvetica".
> Dec 14, 2015 9:49:55 PM org.apache.fop.events.LoggingEventListener
> processEvent
> WARNING: Glyph "?" (0x3a9, Omegagreek) not available in font "Helvetica".
> Dec 14, 2015 9:49:55 PM org.apache.fop.events.LoggingEventListener
> processEvent
> INFO: Rendered page #1.
> name.pdf <http://apache-fop.1065347.n5.nabble.com/file/n43155/name.pdf>
> name.pdf <http://apache-fop.1065347.n5.nabble.com/file/n43155/name.pdf>
>
>
>
> --
> View this message in context:
> http://apache-fop.1065347.n5.nabble.com/FOP-Special-characters-rendering-tp43155.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>