GitHub user monejava opened a pull request:
FOP-1969: Surrogate pairs not treated as single unicode codepoint for…
Implemented correct handling of surrogate pairs in ApacheFOP. The supported Renderes are PDF, PS and PNG. Tests implemented when it was possible.
Here a brief explanation of the design choice that I have made to modify the public API:
`mapChar(char)`/`hasChar(char)`: are defined in `Typeface` which means that they have more then 20 implementations. Modify this interface would require lot of work and might introduce lot of bugs. That's why Glenn Adams (our contact in ApacheFOP project) asked us to create new methods rather the existing ones. In some of these implementations, such as `SingleByteFont`, is semantically correct to have a character represented by a single UTF-16 character. In some other implementation such as `CIDFont` (http://www.adobe.com/products/postscript/pdfs/cid.pdf) is not since they are meant to cover a wider range then 2^16 characters.
`mapCodePoint(int)`/`hasCodePoint(int)`: I have added these 2 methods to the `CIDFont` class that uses int (code points) instead of char so that we can cover the full Unicode range. As you can see from the `Typeface` hierarchy this change affect only 2 classes.
`getUnicode()`: is defined in `CIDSet` (is not a property of the `Typeface` class or one of its subclasses). I changed the firm of this method to handle int instead of char because it is semantically incorrect to represent unicode with a single UTF-16 char. As you can see from the `CIDSet` hierarchy the change affect only 3 classes.
`getUnicodeFromGID()`: this method is defined in `CustomFont` and `CIDSet`. It never get called from the `MultiByteFont` path, probably becuase getUnicode is used instead. That is why I'm down casting the return value from int to char in `CIDFull` and `CIDSubset`. Probably the best thing to do would be to get rid of this method or make it handle int, but again the change would affect more classes then the ones in our scope.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/monejava/fop surrogate_pairs
Alternatively you can review and apply these changes as the patch at:
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #3
Author: Rondelli <email@example.com>
FOP-1969: Surrogate pairs not treated as single unicode codepoint for display purposes