xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbowdi...@apache.org
Subject svn commit: r1422992 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/render/ps/PSTextPainter.java status.xml
Date Mon, 17 Dec 2012 16:03:25 GMT
Author: cbowditch
Date: Mon Dec 17 16:03:24 2012
New Revision: 1422992

URL: http://svn.apache.org/viewvc?rev=1422992&view=rev
Log:
Fix Jira FOP-2173: Invalid Postscript created with SVG and custom fonts
Patch submitted by Simon Steiner (ssteiner.at.thunderhead.com)

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java?rev=1422992&r1=1422991&r2=1422992&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java Mon Dec 17
16:03:24 2012
@@ -269,6 +269,13 @@ public class PSTextPainter extends Nativ
             this.gen = gen;
         }
 
+        public boolean isMultiByte(Font f) {
+            FontMetrics metrics = f.getFontMetrics();
+            boolean multiByte = metrics instanceof MultiByteFont || metrics instanceof LazyFont
+                    && ((LazyFont) metrics).getRealFont() instanceof MultiByteFont;
+            return multiByte;
+        }
+
         public Font selectFontForChar(char ch) {
             for (int i = 0, c = fonts.length; i < c; i++) {
                 if (fonts[i].hasChar(ch)) {
@@ -290,18 +297,21 @@ public class PSTextPainter extends Nativ
         }
 
         public boolean isFontChanging(Font f, char mapped) {
-            if (f != getCurrentFont()) {
-                return true;
-            }
-            if (mapped / 256 != getCurrentFontEncoding()) {
-                return true;
+            // this is only applicable for single byte fonts
+            if (!isMultiByte(f)) {
+                if (f != getCurrentFont()) {
+                    return true;
+                }
+                if (mapped / 256 != getCurrentFontEncoding()) {
+                    return true;
+                }
             }
             return false; //Font is the same
         }
 
         public void selectFont(Font f, char mapped) throws IOException {
             int encoding = mapped / 256;
-            String postfix = (encoding == 0 ? null : Integer.toString(encoding));
+            String postfix = (!isMultiByte(f) && encoding > 0 ? Integer.toString(encoding)
: null);
             PSFontResource res = getResourceForFont(f, postfix);
             gen.useFont("/" + res.getName(), f.getFontSize() / 1000f);
             res.notifyResourceUsageOnPage(gen.getResourceTracker());
@@ -430,10 +440,7 @@ public class PSTextPainter extends Nativ
             textUtil.setCurrentFont(f, mapped);
             applyColor(paint, gen);
 
-            FontMetrics metrics = f.getFontMetrics();
-            boolean multiByte = metrics instanceof MultiByteFont
-                    || metrics instanceof LazyFont
-                            && ((LazyFont) metrics).getRealFont() instanceof MultiByteFont;
+            boolean multiByte = textUtil.isMultiByte(f);
             StringBuffer sb = new StringBuffer();
             sb.append(multiByte ? '<' : '(');
             for (int i = 0, c = this.currentChars.length(); i < c; i++) {
@@ -531,9 +538,9 @@ public class PSTextPainter extends Nativ
                         || metrics instanceof LazyFont
                                 && ((LazyFont) metrics).getRealFont() instanceof
MultiByteFont;
                 if (multiByte) {
-                    gen.write('<');
+                    gen.write("<");
                     gen.write(HexEncoder.encode(mapped));
-                    gen.write('>');
+                    gen.write(">");
                 } else {
                     char codepoint = (char)(mapped % 256);
                     gen.write("(" + codepoint + ")");

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1422992&r1=1422991&r2=1422992&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Mon Dec 17 16:03:24 2012
@@ -59,6 +59,10 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Renderers" dev="CB" type="fix" fixes-bug="FOP-2173" due-to="Simon
Steiner">
+        Invalid Postscript created if more than 255 characters in a custom font are used
within 
+        SVG when generating Postscript
+      </action>
       <action context="Code" dev="PH" type="fix" fixes-bug="37114" due-to="Robert Meyer">
         Implementation of changes necessary to warn of invalid property values.
       </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message