aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-03-07 22:52:11 +0000
committerKeiron Liddle <keiron@apache.org>2001-03-07 22:52:11 +0000
commit0b0f4324805c42e7e5abec21e284f87ca0231d37 (patch)
tree1da5ad072029df18837581ddda5a96c6c36b72b7 /src/org/apache/fop
parentfa5369f89e36714d35565b0197849b38a1450088 (diff)
downloadxmlgraphics-fop-0b0f4324805c42e7e5abec21e284f87ca0231d37.tar.gz
xmlgraphics-fop-0b0f4324805c42e7e5abec21e284f87ca0231d37.zip
adds CID Font support to svg text
Submitted by: Claud Yu git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194143 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop')
-rw-r--r--src/org/apache/fop/render/pdf/SVGRenderer.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/org/apache/fop/render/pdf/SVGRenderer.java b/src/org/apache/fop/render/pdf/SVGRenderer.java
index d79013287..721d0526c 100644
--- a/src/org/apache/fop/render/pdf/SVGRenderer.java
+++ b/src/org/apache/fop/render/pdf/SVGRenderer.java
@@ -2187,14 +2187,34 @@ public class SVGRenderer {
* This handles the escaping of special pdf chars and deals with
* whitespace.
*/
- protected float addSVGStr(FontState fs, float currentX, String str,
- boolean spacing) {
+ protected float addSVGStr(FontState fs, float currentX, String str, boolean spacing) {
boolean inbetween = false;
boolean addedspace = false;
StringBuffer pdf = new StringBuffer();
+ Font f = (Font) fs.getFontInfo().getFonts().get(fs.getFontName());
+ boolean useMultiByte = false;
+ if (f instanceof CIDFont)
+ useMultiByte=true;
+ String startText = useMultiByte ? "<" : "(";
+ String endText = useMultiByte ? ">" : ")";
+
+ pdf.append(startText);
+
+ if ( useMultiByte ) {
+ String enc = ((CIDFont)f).getCharEncoding();
+ try {
+ str = new String(str.getBytes(enc), "8859_1");
+ } catch (java.io.UnsupportedEncodingException ex) { }
+ }
+
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
- if (ch > 127) {
+ if ( useMultiByte ) {
+ pdf = pdf.append(Integer.toHexString((int) ch));
+ currentX += fs.width(ch) / 1000f;
+ inbetween = true;
+ addedspace = false;
+ } else if (ch > 127) {
pdf = pdf.append("\\");
pdf = pdf.append(Integer.toOctalString((int) ch));
currentX += fs.width(ch) / 1000f;
@@ -2249,6 +2269,7 @@ public class SVGRenderer {
}
}
}
+ pdf.append(endText);
currentStream.write(pdf.toString());
return currentX;
}
@@ -2379,10 +2400,10 @@ public class SVGRenderer {
String str = ((CharacterData) o).getData();
currentStream.write(transstr +
(currentX + matrix.getE()) + " " +
- (baseY + matrix.getF()) + " Tm " + "(");
+ (baseY + matrix.getF()) + " Tm " );
boolean spacing = "preserve".equals(te.getXMLspace());
currentX = addSVGStr(fs, currentX, str, spacing);
- currentStream.write(") Tj\n");
+ currentStream.write(" Tj\n");
} else if (o instanceof SVGTextPathElementImpl) {
SVGTextPathElementImpl tpg = (SVGTextPathElementImpl) o;
String ref = tpg.str;