]> source.dussan.org Git - poi.git/commitdiff
#60656 - Support export file that contains emf and render it correctly
authorAndreas Beeker <kiwiwings@apache.org>
Wed, 26 Sep 2018 22:51:03 +0000 (22:51 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Wed, 26 Sep 2018 22:51:03 +0000 (22:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/hemf@1842059 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java

index c5873e02a60ee81e5d18812552f8de436e5bc81e..23ccd1c70fb8588d1af3c2215cf835f1f978a908 100644 (file)
@@ -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