]> source.dussan.org Git - poi.git/commitdiff
font rendering - handle a few system dependent textbox sizes
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 9 Jul 2017 23:28:41 +0000 (23:28 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 9 Jul 2017 23:28:41 +0000 (23:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1801401 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/sl/TestFonts.java

index ef0df8e8ce6d54c8d0c5d31890bde46367f545f1..a34b007009045ed6dd732aebc395019cfd863199 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.sl;
 
 import static org.apache.poi.sl.SLCommonUtils.xslfOnly;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assume.assumeFalse;
 
 import java.awt.Color;
@@ -32,6 +33,7 @@ import java.awt.RenderingHints;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -71,6 +73,9 @@ public class TestFonts {
 
     private static final String INIT_FONTS[] = { "mona.ttf" };
     
+    // currently linux and mac return quite different values
+    private static final int[] expected_sizes = { 311, 312, 313, 399 };
+    
     @BeforeClass
     public static void initGE() throws FontFormatException, IOException {
         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
@@ -87,7 +92,8 @@ public class TestFonts {
         TextBox<?,?> tb = resizeToFitText(ppt);
         Rectangle2D anc = tb.getAnchor();
         // ignore font metrics differences on windows / linux (... hopefully ...)
-//        assertEquals(anc.getHeight(), 312d, 5);
+        boolean found = Arrays.binarySearch(expected_sizes, (int)anc.getHeight()) > -1;
+        assertTrue(found);
 //        setFont(tb, "Mona");
 //        FileOutputStream fos = new FileOutputStream("bla-hslf.ppt");
 //        ppt.write(fos);
@@ -101,7 +107,8 @@ public class TestFonts {
         TextBox<?,?> tb = resizeToFitText(ppt);
         Rectangle2D anc = tb.getAnchor();
         // ignore font metrics differences on windows / linux (... hopefully ...)
-//        assertEquals(anc.getHeight(), 312d, 5);
+        boolean found = Arrays.binarySearch(expected_sizes, (int)anc.getHeight()) > -1;
+        assertTrue(found);
 //        setFont(tb, "Mona");
 //        FileOutputStream fos = new FileOutputStream("bla-xslf.ppt");
 //        ppt.write(fos);