Index: trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java
===================================================================
--- trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java	(revision 12995)
+++ trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java	(revision 12996)
@@ -5,4 +5,5 @@
 import static org.junit.Assert.fail;
 
+import java.awt.Color;
 import java.awt.GraphicsEnvironment;
 import java.awt.Point;
@@ -82,5 +83,6 @@
 
                 /** Text for nodes */
-                new TestConfig("node-text", AREA_DEFAULT).usesFont("DejaVu Sans"),
+                new TestConfig("node-text", AREA_DEFAULT).usesFont("DejaVu Sans")
+                        .setThresholdPixels(100).setThresholdTotalColorDiff(100),
 
                 /** Tests that StyledMapRenderer#drawWay respects width */
@@ -103,5 +105,5 @@
 
                 /** Tests area label drawing/placement */
-                new TestConfig("area-text", AREA_DEFAULT),
+                new TestConfig("area-text", AREA_DEFAULT).setThresholdPixels(50).setThresholdTotalColorDiff(50),
 
                 /** Tests area icon drawing/placement */
@@ -117,5 +119,5 @@
 
                 /** Tests text along a way */
-                new TestConfig("way-text", AREA_DEFAULT),
+                new TestConfig("way-text", AREA_DEFAULT).setThresholdPixels(20).setThresholdTotalColorDiff(40),
 
                 /** Another test for node shapes */
@@ -128,5 +130,5 @@
                 new TestConfig("way-dashes2"),
                 /** Tests node text placement */
-                new TestConfig("node-text2"),
+                new TestConfig("node-text2").setThresholdPixels(30).setThresholdTotalColorDiff(50),
                 /** Tests relation link selector */
                 new TestConfig("relation-linkselector"),
@@ -135,5 +137,5 @@
 
                 /** Tests evaluation of expressions */
-                new TestConfig("eval").setImageWidth(600)
+                new TestConfig("eval").setImageWidth(600).setThresholdPixels(100).setThresholdTotalColorDiff(100)
 
                 ).map(e -> new Object[] {e, e.testDirectory})
@@ -204,4 +206,5 @@
         StringBuilder differences = new StringBuilder();
         ArrayList<Point> differencePoints = new ArrayList<>();
+        int colorDiffSum = 0;
 
         for (int y = 0; y < reference.getHeight(); y++) {
@@ -211,4 +214,5 @@
                 if (!colorsAreSame(expected, result)) {
                     differencePoints.add(new Point(x, y));
+                    int colorDiff = colorDiff(new Color(expected, true), new Color(result, true));
                     if (differences.length() < 500) {
                         differences.append("\nDifference at ")
@@ -219,11 +223,15 @@
                         .append(Integer.toHexString(expected))
                         .append(" but got ")
-                        .append(Integer.toHexString(result));
+                        .append(Integer.toHexString(result))
+                        .append(" (color diff is ")
+                        .append(colorDiff)
+                        .append(")");
                     }
+                    colorDiffSum += colorDiff;
                 }
             }
         }
 
-        if (differencePoints.size() > 0) {
+        if (differencePoints.size() > testConfig.thresholdPixels || colorDiffSum > testConfig.thresholdTotalColorDiff) {
             // You can use this to debug:
             ImageIO.write(image, "png", new File(testConfig.getTestDirectory() + "/test-output.png"));
@@ -236,6 +244,11 @@
             ImageIO.write(diffImage, "png", new File(testConfig.getTestDirectory() + "/test-differences.png"));
 
-            fail(MessageFormat.format("Images for test {0} differ at {1} points: {2}",
-                    testConfig.testDirectory, differencePoints.size(), differences.toString()));
+            if (differencePoints.size() > testConfig.thresholdPixels) {
+                fail(MessageFormat.format("Images for test {0} differ at {1} points, threshold is {2}: {3}",
+                        testConfig.testDirectory, differencePoints.size(), testConfig.thresholdPixels, differences.toString()));
+            } else {
+                fail(MessageFormat.format("Images for test {0} differ too much in color, value is {1}, permitted threshold is {2}: {3}",
+                        testConfig.testDirectory, colorDiffSum, testConfig.thresholdTotalColorDiff, differences.toString()));
+            }
         }
     }
@@ -246,4 +259,9 @@
             n.setDisabledState(false);
         }
+    }
+
+    private int colorDiff(Color c1, Color c2) {
+        return Math.abs(c1.getAlpha() - c2.getAlpha()) + Math.abs(c1.getRed() - c2.getRed())
+                + Math.abs(c1.getGreen() - c2.getGreen()) + Math.abs(c1.getBlue() - c2.getBlue());
     }
 
@@ -269,4 +287,6 @@
         private DataSet ds;
         private int imageWidth = IMAGE_SIZE;
+        private int thresholdPixels;
+        private int thresholdTotalColorDiff;
 
         TestConfig(String testDirectory, Bounds testArea) {
@@ -284,4 +304,28 @@
         }
 
+        /**
+         * Set the number of pixels that can differ.
+         *
+         * Needed due to somewhat platform dependent font rendering.
+         * @param thresholdPixels the number of pixels that can differ
+         * @return this object, for convenience
+         */
+        public TestConfig setThresholdPixels(int thresholdPixels) {
+            this.thresholdPixels = thresholdPixels;
+            return this;
+        }
+
+        /**
+         * Set the threshold for total color difference.
+         * Every difference in any color component (and alpha) will be added up and must not exceed this threshold.
+         * Needed due to somewhat platform dependent font rendering.
+         * @param thresholdTotalColorDiff he threshold for total color difference
+         * @return this object, for convenience
+         */
+        public TestConfig setThresholdTotalColorDiff(int thresholdTotalColorDiff) {
+            this.thresholdTotalColorDiff = thresholdTotalColorDiff;
+            return this;
+        }
+
         public TestConfig usesFont(String string) {
             this.fonts.add(string);
