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 "patrick@openbase.com" <pa...@openbase.com> on 2005/03/09 10:21:11 UTC
How to handle special characters?
Hi,
I need to display in a pdf file some text that contains different type
of characters: some are ascii type but other are special ones like the
'star' or 'square' characters. I understand from what I have read that
those special characters are not available in the default Helvetica or
Courier base font and that I need to use the ZapfDingbats font.
So what I need to achieve is transform the following XML content:
"Some text ★ More text"
Into:
<fo:inline font-family="Helvetica"> Some text <fo:inline
font-family="ZapfDingbats">★</fo:inline> More text </fo:inline>
How can this be done using XSL to create the proper FO document knowing
that I don't know in advance what the text to translate looks like and
how many 'special' characters it contains (ex 'asdf★as■df★as▲d●◆fasd★')
Thanks for any tips!
Patrick
Re: How to handle special characters?
Posted by Jeremias Maerki <de...@greenmail.ch>.
On 09.03.2005 17:07:21 patrick@openbase.com wrote:
> Ok so I think the only way out it to pre process my xml file to mark
> special characters so that I can them easily find them in my xsl
> document.
Good idea if that's possible.
> Could another option be to find a font that contains all
> unicode characters?
Sure, if such a beast exists.
> How difficult is it to embed a special font that
> would work both on Mac and PC? Do you have any pointers on how to do
> this?
Simply get a PC-compatible font. It should also work on the Mac since
FOP doesn't use the Mac's font system in case of PDFs. If you have such
a font simply follow the instruction for custom fonts. HTH
> Thanks,
>
> Patrick
>
>
> On 9 mars 05, at 17:01, Jeremias Maerki wrote:
>
> > Oops, sorry. Hmm, you've got a problem there. That's actually something
> > that would (in theory) be handled like this:
> >
> > <fo:inline font-family="Helvetica, ZapfDingbats">Some text â
More
> > text</fo:inline>
> >
> > FOP should (again in theory) automatically switch to ZapfDingbats if
> > Helvetica doesn't contain a character. The problem is that FOP doesn't
> > do that, yet.
> >
> > Working around this in XSLT is next to impossible (I think), which
> > leaves a special preprocessor that inserts special fo:inlines as
> > necessary but in this case you could just as well try to implement that
> > directly in FOP. It'll not be so simple.
> >
> > <fx type="head-scratching"/>
> >
> > On 09.03.2005 16:49:19 patrick@openbase.com wrote:
> >> Hi,
> >>
> >> This is not really what I am trying to achieve. I know that I can
> >> handle special characters using the ZapfDingbats font. However what I
> >> don't know to do is parse a text content to encapsulate <fo:inline>
> >> element each time such a special character is found.
> >>
> >> So tranforming:
> >>
> >> "Some text â
More text"
> >>
> >> To:
> >>
> >> <fo:inline font-family="Helvetica"> Some text <fo:inline
> >> font-family="ZapfDingbats">â
</fo:inline> More text </fo:inline>
> >>
> >>
> >> Patrick
> >>
> >> On 9 mars 05, at 16:41, Jeremias Maerki wrote:
> >>
> >>> Lots of examples in the distribution, for example:
> >>> http://cvs.apache.org/viewcvs.cgi/xml-fop/examples/fo/basic/fonts.fo?
> >>> rev=1.3&view=markup
> >>>
> >>> ...and in the documentation:
> >>> http://xml.apache.org/fop/fo.html#xml-special-chars
> >>>
> >>>
> >>> On 09.03.2005 10:21:11 patrick@openbase.com wrote:
> >>>> Hi,
> >>>>
> >>>> I need to display in a pdf file some text that contains different
> >>>> type
> >>>> of characters: some are ascii type but other are special ones like
> >>>> the
> >>>> 'star' or 'square' characters. I understand from what I have read
> >>>> that
> >>>> those special characters are not available in the default Helvetica
> >>>> or
> >>>> Courier base font and that I need to use the ZapfDingbats font.
> >>>>
> >>>> So what I need to achieve is transform the following XML content:
> >>>>
> >>>> "Some text â¢Ë More text"
> >>>>
> >>>> Into:
> >>>>
> >>>> <fo:inline font-family="Helvetica"> Some text <fo:inline
> >>>> font-family="ZapfDingbats">â¢Ë</fo:inline> More text </fo:inline>
> >>>>
> >>>>
> >>>> How can this be done using XSL to create the proper FO document
> >>>> knowing
> >>>> that I don't know in advance what the text to translate looks like
> >>>> and
> >>>> how many 'special' characters it contains (ex
> >>>> 'asdfâ¢Ëasâ¢Â¡dfâ¢Ëasâ¢Â£dâ¢Ëâ¢Æfasdâ¢Ë')
> >>>>
> >>>> Thanks for any tips!
> >>>>
> >>>>
> >>>> Patrick
> >>>
> >>>
> >>>
> >>> Jeremias Maerki
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> >>> For additional commands, e-mail: fop-user-help@xml.apache.org
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> >> For additional commands, e-mail: fop-user-help@xml.apache.org
> >
> >
> >
> > Jeremias Maerki
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: fop-user-help@xml.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: fop-user-help@xml.apache.org
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: How to handle special characters?
Posted by "patrick@openbase.com" <pa...@openbase.com>.
Ok so I think the only way out it to pre process my xml file to mark
special characters so that I can them easily find them in my xsl
document. Could another option be to find a font that contains all
unicode characters? How difficult is it to embed a special font that
would work both on Mac and PC? Do you have any pointers on how to do
this?
Thanks,
Patrick
On 9 mars 05, at 17:01, Jeremias Maerki wrote:
> Oops, sorry. Hmm, you've got a problem there. That's actually something
> that would (in theory) be handled like this:
>
> <fo:inline font-family="Helvetica, ZapfDingbats">Some text ★ More
> text</fo:inline>
>
> FOP should (again in theory) automatically switch to ZapfDingbats if
> Helvetica doesn't contain a character. The problem is that FOP doesn't
> do that, yet.
>
> Working around this in XSLT is next to impossible (I think), which
> leaves a special preprocessor that inserts special fo:inlines as
> necessary but in this case you could just as well try to implement that
> directly in FOP. It'll not be so simple.
>
> <fx type="head-scratching"/>
>
> On 09.03.2005 16:49:19 patrick@openbase.com wrote:
>> Hi,
>>
>> This is not really what I am trying to achieve. I know that I can
>> handle special characters using the ZapfDingbats font. However what I
>> don't know to do is parse a text content to encapsulate <fo:inline>
>> element each time such a special character is found.
>>
>> So tranforming:
>>
>> "Some text ★ More text"
>>
>> To:
>>
>> <fo:inline font-family="Helvetica"> Some text <fo:inline
>> font-family="ZapfDingbats">★</fo:inline> More text </fo:inline>
>>
>>
>> Patrick
>>
>> On 9 mars 05, at 16:41, Jeremias Maerki wrote:
>>
>>> Lots of examples in the distribution, for example:
>>> http://cvs.apache.org/viewcvs.cgi/xml-fop/examples/fo/basic/fonts.fo?
>>> rev=1.3&view=markup
>>>
>>> ...and in the documentation:
>>> http://xml.apache.org/fop/fo.html#xml-special-chars
>>>
>>>
>>> On 09.03.2005 10:21:11 patrick@openbase.com wrote:
>>>> Hi,
>>>>
>>>> I need to display in a pdf file some text that contains different
>>>> type
>>>> of characters: some are ascii type but other are special ones like
>>>> the
>>>> 'star' or 'square' characters. I understand from what I have read
>>>> that
>>>> those special characters are not available in the default Helvetica
>>>> or
>>>> Courier base font and that I need to use the ZapfDingbats font.
>>>>
>>>> So what I need to achieve is transform the following XML content:
>>>>
>>>> "Some text ™˚ More text"
>>>>
>>>> Into:
>>>>
>>>> <fo:inline font-family="Helvetica"> Some text <fo:inline
>>>> font-family="ZapfDingbats">™˚</fo:inline> More text </fo:inline>
>>>>
>>>>
>>>> How can this be done using XSL to create the proper FO document
>>>> knowing
>>>> that I don't know in advance what the text to translate looks like
>>>> and
>>>> how many 'special' characters it contains (ex
>>>> 'asdf™˚as™¡df™˚as™£d™˛™ƒfasd™˚')
>>>>
>>>> Thanks for any tips!
>>>>
>>>>
>>>> Patrick
>>>
>>>
>>>
>>> Jeremias Maerki
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
>>> For additional commands, e-mail: fop-user-help@xml.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
>> For additional commands, e-mail: fop-user-help@xml.apache.org
>
>
>
> Jeremias Maerki
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: fop-user-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: How to handle special characters?
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Jeremias Maerki wrote:
> Working around this in XSLT is next to impossible (I think),
It is possible even with XSLT 1.0. The XSLT FAQ has examples
for various use cases:
http://www.dpawson.co.uk/xsl/sect2/replace.html
It is, however, tedious, and also likely to be somewhat slow.
XSLT 2 provides much better text processing capabilities (regular
expression matching).
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: How to handle special characters?
Posted by Jeremias Maerki <de...@greenmail.ch>.
Oops, sorry. Hmm, you've got a problem there. That's actually something
that would (in theory) be handled like this:
<fo:inline font-family="Helvetica, ZapfDingbats">Some text â
More
text</fo:inline>
FOP should (again in theory) automatically switch to ZapfDingbats if
Helvetica doesn't contain a character. The problem is that FOP doesn't
do that, yet.
Working around this in XSLT is next to impossible (I think), which
leaves a special preprocessor that inserts special fo:inlines as
necessary but in this case you could just as well try to implement that
directly in FOP. It'll not be so simple.
<fx type="head-scratching"/>
On 09.03.2005 16:49:19 patrick@openbase.com wrote:
> Hi,
>
> This is not really what I am trying to achieve. I know that I can
> handle special characters using the ZapfDingbats font. However what I
> don't know to do is parse a text content to encapsulate <fo:inline>
> element each time such a special character is found.
>
> So tranforming:
>
> "Some text â
More text"
>
> To:
>
> <fo:inline font-family="Helvetica"> Some text <fo:inline
> font-family="ZapfDingbats">â
</fo:inline> More text </fo:inline>
>
>
> Patrick
>
> On 9 mars 05, at 16:41, Jeremias Maerki wrote:
>
> > Lots of examples in the distribution, for example:
> > http://cvs.apache.org/viewcvs.cgi/xml-fop/examples/fo/basic/fonts.fo?
> > rev=1.3&view=markup
> >
> > ...and in the documentation:
> > http://xml.apache.org/fop/fo.html#xml-special-chars
> >
> >
> > On 09.03.2005 10:21:11 patrick@openbase.com wrote:
> >> Hi,
> >>
> >> I need to display in a pdf file some text that contains different type
> >> of characters: some are ascii type but other are special ones like the
> >> 'star' or 'square' characters. I understand from what I have read that
> >> those special characters are not available in the default Helvetica or
> >> Courier base font and that I need to use the ZapfDingbats font.
> >>
> >> So what I need to achieve is transform the following XML content:
> >>
> >> "Some text â¢Ë More text"
> >>
> >> Into:
> >>
> >> <fo:inline font-family="Helvetica"> Some text <fo:inline
> >> font-family="ZapfDingbats">â¢Ë</fo:inline> More text </fo:inline>
> >>
> >>
> >> How can this be done using XSL to create the proper FO document
> >> knowing
> >> that I don't know in advance what the text to translate looks like and
> >> how many 'special' characters it contains (ex
> >> 'asdfâ¢Ëasâ¢Â¡dfâ¢Ëasâ¢Â£dâ¢Ëâ¢Æfasdâ¢Ë')
> >>
> >> Thanks for any tips!
> >>
> >>
> >> Patrick
> >
> >
> >
> > Jeremias Maerki
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: fop-user-help@xml.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: fop-user-help@xml.apache.org
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: How to handle special characters?
Posted by "patrick@openbase.com" <pa...@openbase.com>.
Hi,
This is not really what I am trying to achieve. I know that I can
handle special characters using the ZapfDingbats font. However what I
don't know to do is parse a text content to encapsulate <fo:inline>
element each time such a special character is found.
So tranforming:
"Some text ★ More text"
To:
<fo:inline font-family="Helvetica"> Some text <fo:inline
font-family="ZapfDingbats">★</fo:inline> More text </fo:inline>
Patrick
On 9 mars 05, at 16:41, Jeremias Maerki wrote:
> Lots of examples in the distribution, for example:
> http://cvs.apache.org/viewcvs.cgi/xml-fop/examples/fo/basic/fonts.fo?
> rev=1.3&view=markup
>
> ...and in the documentation:
> http://xml.apache.org/fop/fo.html#xml-special-chars
>
>
> On 09.03.2005 10:21:11 patrick@openbase.com wrote:
>> Hi,
>>
>> I need to display in a pdf file some text that contains different type
>> of characters: some are ascii type but other are special ones like the
>> 'star' or 'square' characters. I understand from what I have read that
>> those special characters are not available in the default Helvetica or
>> Courier base font and that I need to use the ZapfDingbats font.
>>
>> So what I need to achieve is transform the following XML content:
>>
>> "Some text ™˚ More text"
>>
>> Into:
>>
>> <fo:inline font-family="Helvetica"> Some text <fo:inline
>> font-family="ZapfDingbats">™˚</fo:inline> More text </fo:inline>
>>
>>
>> How can this be done using XSL to create the proper FO document
>> knowing
>> that I don't know in advance what the text to translate looks like and
>> how many 'special' characters it contains (ex
>> 'asdf™˚as™¡df™˚as™£d™˛™ƒfasd™˚')
>>
>> Thanks for any tips!
>>
>>
>> Patrick
>
>
>
> Jeremias Maerki
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: fop-user-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: How to handle special characters?
Posted by Jeremias Maerki <de...@greenmail.ch>.
Lots of examples in the distribution, for example:
http://cvs.apache.org/viewcvs.cgi/xml-fop/examples/fo/basic/fonts.fo?rev=1.3&view=markup
...and in the documentation:
http://xml.apache.org/fop/fo.html#xml-special-chars
On 09.03.2005 10:21:11 patrick@openbase.com wrote:
> Hi,
>
> I need to display in a pdf file some text that contains different type
> of characters: some are ascii type but other are special ones like the
> 'star' or 'square' characters. I understand from what I have read that
> those special characters are not available in the default Helvetica or
> Courier base font and that I need to use the ZapfDingbats font.
>
> So what I need to achieve is transform the following XML content:
>
> "Some text More text"
>
> Into:
>
> <fo:inline font-family="Helvetica"> Some text <fo:inline
> font-family="ZapfDingbats"></fo:inline> More text </fo:inline>
>
>
> How can this be done using XSL to create the proper FO document knowing
> that I don't know in advance what the text to translate looks like and
> how many 'special' characters it contains (ex 'asdfas¡dfas£dfasd')
>
> Thanks for any tips!
>
>
> Patrick
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org