Ran across a bug in toCSSWeight() today in trunk. The code erroneously maps
TextAttribute.WEIGHT_BOLD to 600 instead of 700 as required by CSS and
XSL-FO.

The problem is there are 8 defined TextAttribute weights, but 9 defined CSS
weights. Also, CSS requires NORMAL and BOLD be mapped to 400 and 700
respectively. Following is a patch I've put in place in my dev branch.

diff --git a/src/java/org/apache/fop/svg/NativeTextPainter.java
b/src/java/org/apache/fop/svg/NativeTextPainter.java
index 94d4263..7ad2fbd 100644
--- a/src/java/org/apache/fop/svg/NativeTextPainter.java
+++ b/src/java/org/apache/fop/svg/NativeTextPainter.java
@@ -187,12 +187,14 @@ public abstract class NativeTextPainter extends
StrokingTextPainter {
             return 400;
         } else if (weight <= TextAttribute.WEIGHT_SEMIBOLD.floatValue()) {
             return 500;
-        } else if (weight <= TextAttribute.WEIGHT_BOLD.floatValue()) {
+        } else if (weight <  TextAttribute.WEIGHT_BOLD.floatValue()) {
             return 600;
-        } else if (weight <= TextAttribute.WEIGHT_HEAVY.floatValue()) {
+        } else if (weight ==  TextAttribute.WEIGHT_BOLD.floatValue()) {
             return 700;
-        } else if (weight <= TextAttribute.WEIGHT_EXTRABOLD.floatValue()) {
+        } else if (weight <= TextAttribute.WEIGHT_HEAVY.floatValue()) {
             return 800;
+        } else if (weight <= TextAttribute.WEIGHT_EXTRABOLD.floatValue()) {
+            return 900;
         } else {
             return 900;
         }

Reply via email to