You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Glenn Adams <gl...@skynav.com> on 2011/03/06 05:42:56 UTC

org.apache.fop.svg.NativeTextPainter.toCSSWeight() bug

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;
         }

Re: org.apache.fop.svg.NativeTextPainter.toCSSWeight() bug

Posted by Chris Bowditch <bo...@hotmail.com>.
On 06/03/2011 04:42, Glenn Adams wrote:

Hi Glenn,

I was just catching up on old e-mails and noticed no one replied to 
this. I have added your patch to the patch queue so its not lost:

https://issues.apache.org/bugzilla/show_bug.cgi?id=50899

Thanks for the suggestion.

Thanks,

Chris

> --- 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;
>          }
>