Author: jeremias
Date: Tue Sep 21 16:32:08 2010
New Revision: 999488
URL: http://svn.apache.org/viewvc?rev=999488&view=rev
Log:
Some fine-tuning for the font selection in SVG to better match AWT/GVT fonts to
FOP's fonts.
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/NativeTextPainter.java
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/NativeTextPainter.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/NativeTextPainter.java?rev=999488&r1=999487&r2=999488&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/NativeTextPainter.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/NativeTextPainter.java
Tue Sep 21 16:32:08 2010
@@ -111,9 +111,9 @@ public abstract class NativeTextPainter
String style = ((posture != null) && (posture.floatValue() > 0.0))
? Font.STYLE_ITALIC : Font.STYLE_NORMAL;
- int weight = ((taWeight != null)
- && (taWeight.floatValue() > 1.0)) ? Font.WEIGHT_BOLD
- : Font.WEIGHT_NORMAL;
+ int weight = toCSSWeight(taWeight != null
+ ? taWeight.floatValue()
+ : TextAttribute.WEIGHT_REGULAR.floatValue());
String firstFontFamily = null;
@@ -176,6 +176,28 @@ public abstract class NativeTextPainter
return (Font[])fonts.toArray(new Font[fonts.size()]);
}
+ private int toCSSWeight(float weight) {
+ if (weight <= TextAttribute.WEIGHT_EXTRA_LIGHT.floatValue()) {
+ return 100;
+ } else if (weight <= TextAttribute.WEIGHT_LIGHT.floatValue()) {
+ return 200;
+ } else if (weight <= TextAttribute.WEIGHT_DEMILIGHT.floatValue()) {
+ return 300;
+ } else if (weight <= TextAttribute.WEIGHT_REGULAR.floatValue()) {
+ return 400;
+ } else if (weight <= TextAttribute.WEIGHT_SEMIBOLD.floatValue()) {
+ return 500;
+ } else if (weight <= TextAttribute.WEIGHT_BOLD.floatValue()) {
+ return 600;
+ } else if (weight <= TextAttribute.WEIGHT_HEAVY.floatValue()) {
+ return 700;
+ } else if (weight <= TextAttribute.WEIGHT_EXTRABOLD.floatValue()) {
+ return 800;
+ } else {
+ return 900;
+ }
+ }
+
/**
* Collects all characters from an {...@link AttributedCharacterIterator}.
* @param runaci the character iterator
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]