You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by je...@apache.org on 2011/06/30 15:32:09 UTC
svn commit: r1141532 -
/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/TextUtilities.java
Author: jeremias
Date: Thu Jun 30 13:32:08 2011
New Revision: 1141532
URL: http://svn.apache.org/viewvc?rev=1141532&view=rev
Log:
Bugfix: font-weight:bold (700) was not mapped to TextAttribute.BOLD, possibly resulting in too bold a font.
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/TextUtilities.java
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/TextUtilities.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/TextUtilities.java?rev=1141532&r1=1141531&r2=1141532&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/TextUtilities.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/TextUtilities.java Thu Jun 30 13:32:08 2011
@@ -206,8 +206,10 @@ public abstract class TextUtilities impl
public static Float convertFontWeight(Element e) {
Value v = CSSUtilities.getComputedStyle
(e, SVGCSSEngine.FONT_WEIGHT_INDEX);
- float f = v.getFloatValue();
- switch ((int)f) {
+ int weight = (int)v.getFloatValue();
+ //Note: the mapping from CSS2 to TextAttribute's weights is somewhat arbitrary.
+ //Important is to map 400/normal to REGULAR and 700/bold to BOLD.
+ switch (weight) {
case 100:
return TextAttribute.WEIGHT_EXTRA_LIGHT;
case 200:
@@ -228,15 +230,17 @@ public abstract class TextUtilities impl
// if there is not a match.
return TextAttribute.WEIGHT_BOLD;
}
- switch ((int)f) {
+ switch (weight) {
+ case 600:
+ return TextAttribute.WEIGHT_MEDIUM;
case 700:
- return TextAttribute.WEIGHT_HEAVY;
+ return TextAttribute.WEIGHT_BOLD;
case 800:
- return TextAttribute.WEIGHT_EXTRABOLD;
+ return TextAttribute.WEIGHT_HEAVY;
case 900:
return TextAttribute.WEIGHT_ULTRABOLD;
default:
- return TextAttribute.WEIGHT_BOLD;
+ return TextAttribute.WEIGHT_REGULAR; //No matching CSS value (probably illegal)
}
}
}