You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@apache.org on 2001/03/07 23:52:15 UTC
cvs commit: xml-fop/src/org/apache/fop/render/pdf SVGRenderer.java
keiron 01/03/07 14:52:14
Modified: src/org/apache/fop/render/pdf SVGRenderer.java
Log:
adds CID Font support to svg text
Submitted by: Claud Yu
Revision Changes Path
1.9 +27 -6 xml-fop/src/org/apache/fop/render/pdf/SVGRenderer.java
Index: SVGRenderer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/pdf/SVGRenderer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SVGRenderer.java 2001/02/27 00:05:52 1.8
+++ SVGRenderer.java 2001/03/07 22:52:11 1.9
@@ -1,4 +1,4 @@
-/*-- $Id: SVGRenderer.java,v 1.8 2001/02/27 00:05:52 keiron Exp $ --
+/*-- $Id: SVGRenderer.java,v 1.9 2001/03/07 22:52:11 keiron Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -2187,14 +2187,34 @@
* 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 @@
}
}
}
+ pdf.append(endText);
currentStream.write(pdf.toString());
return currentX;
}
@@ -2379,10 +2400,10 @@
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;