RE: How to translate characters?
Eric Douglas <edouglas <at> blockhouse.com>
2011-09-02 18:44:33 GMT
I see. As I said I saw something in the FOP classes which appeared to be looking for such a code and translating
it, but I just pulled up a .FO file and I see it's already translated to be <fo:inline>□</fo:inline> so
there must be something in the Oracle Transformer.
So it seems FOP just gets the actual square and still has to know what character it maps to in the font.
So I'm trying to pass in this text ("□") and get it to display with Java's Graphics2D.drawText().
So I'm wondering if I translate that the same way I do to create this FO, with an XSL file and a Transformer or if
there's a simpler method.
So I'm looking at the class java.nio.charset.Charset trying to figure out if or how that connects to a
custom font file.
-----Original Message-----
From: Christopher R. Maden [mailto:crism <at> maden.org]
Sent: Friday, September 02, 2011 1:56 PM
To: fop-dev <at> xmlgraphics.apache.org
Subject: Re: How to translate characters?
On 09/02/2011 01:40 PM, Eric Douglas wrote:
> I pass a character into my XML/FO as □ and it shows on the PDF
> as a square.
> I'm trying to figure out what Java has for interpreting such code, and
> it appears FOP just string searches and pulls out the number, in the
> class org.apache.xmlgraphics.fonts.Glyphs.
> Is this all it is, to search text for "&#" and ";" and find the
> character value between, or is there an actual Java class/method for
> translating such values?
By the time FOP gets this information, the XML has been parsed.
□ is just a convenient way of entering the single character with Unicode value 25A1, □, WHITE
SQUARE. Equivalents would be □ or (with common ISO entity declarations) □ - in all cases, FOP
just receives a single character, □.
FOP then attempts to find which of the specified fonts actually has a glyph for that character, and does so
using the numeric Unicode value of the character, but that is independent of how the input XML (which FOP
does not see) specified the character. If you’re looking at altering or overriding the code, you need to
operate in the character domain, not the XML markup domain.
(By analogy, FOP receives elements, root-in-the-FO-namespace etc., not the string “<fo:root ...”.
This is the same kind of thing.)
~Chris
--
Chris Maden, text nerd <URL: http://crism.maden.org/ > “The present tendency and drift towards the
Police State gives all free Americans pause.” - Alabama Supreme Court, 1955 (Pike v. Southern Bell Tel.
& Telegraph, 81 So.2d 254)