Author: kiwiwings
Date: Wed Sep 26 22:51:03 2018
New Revision: 1842059

URL: http://svn.apache.org/viewvc?rev=1842059&view=rev
Log:
#60656 - Support export file that contains emf and render it correctly

Modified:
    
poi/branches/hemf/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java

Modified: 
poi/branches/hemf/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java
URL: 
http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java?rev=1842059&r1=1842058&r2=1842059&view=diff
==============================================================================
--- 
poi/branches/hemf/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java 
(original)
+++ 
poi/branches/hemf/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java 
Wed Sep 26 22:51:03 2018
@@ -351,7 +351,7 @@ public class HwmfGraphics {
             }
         }
 
-        String textString = new String(text, charset);
+        String textString = new String(text, charset).trim();
         AttributedString as = new AttributedString(textString);
         if (dx == null || dx.isEmpty()) {
             addAttributes(as, font);
@@ -388,7 +388,9 @@ public class HwmfGraphics {
                     offset += Character.charCount(chars[0]);
                 }
             }
-            for (int i = 0; i < dxNormed.size(); i++) {
+
+            int cps = textString.codePointCount(0, textString.length());
+            for (int i = 0; i < Math.min(dxNormed.size(),cps-1); i++) {
                 addAttributes(as, font);
                 // Tracking works as a prefix/advance space on characters 
whereas
                 // dx[...] is the complete width of the current char



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to