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 ga...@apache.org on 2014/11/04 08:04:58 UTC
svn commit: r1636514 - in
/xmlgraphics/batik/branches/text-background/sources/org/apache/batik:
bridge/ css/engine/ css/engine/value/css2/ css/engine/value/svg12/
gvt/renderer/ util/
Author: gadams
Date: Tue Nov 4 07:04:57 2014
New Revision: 1636514
URL: http://svn.apache.org/r1636514
Log:
Enable line-height property at CSS2 layer, applying to both SVG and SVG12 engines.
Added:
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/css2/LineHeightManager.java
- copied, changed from r1636251, xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/css2/LineHeightValue.java
- copied, changed from r1636251, xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightValue.java
Modified:
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/bridge/SVGTextElementBridge.java
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/SVG12CSSEngine.java
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/SVGCSSEngine.java
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightValue.java
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/util/SVG12CSSConstants.java
Modified: xmlgraphics/batik/branches/text-background/sources/org/apache/batik/bridge/SVGTextElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/text-background/sources/org/apache/batik/bridge/SVGTextElementBridge.java?rev=1636514&r1=1636513&r2=1636514&view=diff
==============================================================================
--- xmlgraphics/batik/branches/text-background/sources/org/apache/batik/bridge/SVGTextElementBridge.java (original)
+++ xmlgraphics/batik/branches/text-background/sources/org/apache/batik/bridge/SVGTextElementBridge.java Tue Nov 4 07:04:57 2014
@@ -139,6 +139,10 @@ public class SVGTextElementBridge extend
AttributedCharacterIterator.Attribute BASELINE_SHIFT
= GVTAttributedCharacterIterator.TextAttribute.BASELINE_SHIFT;
+ public static final
+ AttributedCharacterIterator.Attribute LINE_HEIGHT
+ = GVTAttributedCharacterIterator.TextAttribute.LINE_HEIGHT;
+
protected AttributedString laidoutText;
// This is used to track the TextPainterInfo for each element
@@ -1568,6 +1572,11 @@ public class SVGTextElementBridge extend
// holds hard ref to DOM.
result.put(GVT_FONT_FAMILIES, fontFamilyList);
+ // Line height
+ result.put(LINE_HEIGHT,
+ TextUtilities.convertLineHeight(element,
+ SVGCSSEngine.LINE_HEIGHT_INDEX, fontSize));
+
if (!ctx.isDynamic()) {
// Only leave this in the map for dynamic documents.
// Otherwise it will cause the whole DOM to stay when
Modified: xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/SVG12CSSEngine.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/SVG12CSSEngine.java?rev=1636514&r1=1636513&r2=1636514&view=diff
==============================================================================
--- xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/SVG12CSSEngine.java (original)
+++ xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/SVG12CSSEngine.java Tue Nov 4 07:04:57 2014
@@ -55,7 +55,6 @@ public class SVG12CSSEngine extends SVGC
SVG_VALUE_MANAGERS,
SVG_SHORTHAND_MANAGERS,
ctx);
- lineHeightIndex = LINE_HEIGHT_INDEX;
}
/**
@@ -77,14 +76,12 @@ public class SVG12CSSEngine extends SVGC
mergeArrays(SVG_VALUE_MANAGERS, vms),
mergeArrays(SVG_SHORTHAND_MANAGERS, sms),
ctx);
- lineHeightIndex = LINE_HEIGHT_INDEX;
}
/**
* The value managers for SVG.
*/
public static final ValueManager[] SVG_VALUE_MANAGERS = {
- new LineHeightManager (),
new MarginLengthManager(SVG12CSSConstants.CSS_INDENT_PROPERTY),
new MarginLengthManager(SVG12CSSConstants.CSS_MARGIN_BOTTOM_PROPERTY),
new MarginLengthManager(SVG12CSSConstants.CSS_MARGIN_LEFT_PROPERTY),
@@ -106,8 +103,7 @@ public class SVG12CSSEngine extends SVGC
//
// The property indexes.
//
- public static final int LINE_HEIGHT_INDEX = SVGCSSEngine.FINAL_INDEX+1;
- public static final int INDENT_INDEX = LINE_HEIGHT_INDEX+1;
+ public static final int INDENT_INDEX = SVGCSSEngine.FINAL_INDEX+1;
public static final int MARGIN_BOTTOM_INDEX = INDENT_INDEX+1;
public static final int MARGIN_LEFT_INDEX = MARGIN_BOTTOM_INDEX+1;
public static final int MARGIN_RIGHT_INDEX = MARGIN_LEFT_INDEX+1;
Modified: xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/SVGCSSEngine.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/SVGCSSEngine.java?rev=1636514&r1=1636513&r2=1636514&view=diff
==============================================================================
--- xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/SVGCSSEngine.java (original)
+++ xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/SVGCSSEngine.java Tue Nov 4 07:04:57 2014
@@ -34,6 +34,7 @@ import org.apache.batik.css.engine.value
import org.apache.batik.css.engine.value.css2.FontStyleManager;
import org.apache.batik.css.engine.value.css2.FontVariantManager;
import org.apache.batik.css.engine.value.css2.FontWeightManager;
+import org.apache.batik.css.engine.value.css2.LineHeightManager;
import org.apache.batik.css.engine.value.css2.OverflowManager;
import org.apache.batik.css.engine.value.css2.SrcManager;
import org.apache.batik.css.engine.value.css2.TextDecorationManager;
@@ -111,8 +112,6 @@ public class SVGCSSEngine extends CSSEng
true,
null,
ctx);
- // SVG defines line-height to be font-size.
- lineHeightIndex = fontSizeIndex;
}
/**
@@ -141,8 +140,6 @@ public class SVGCSSEngine extends CSSEng
true,
null,
ctx);
- // SVG defines line-height to be font-size.
- lineHeightIndex = fontSizeIndex;
}
protected SVGCSSEngine(Document doc,
@@ -162,8 +159,6 @@ public class SVGCSSEngine extends CSSEng
mergeArrays(SVG_VALUE_MANAGERS, vms),
mergeArrays(SVG_SHORTHAND_MANAGERS, sms),
pe, sns, sln, cns, cln, hints, hintsNS, ctx);
- // SVG defines line-height to be font-size.
- lineHeightIndex = fontSizeIndex;
}
@@ -237,6 +232,7 @@ public class SVGCSSEngine extends CSSEng
new SpacingManager(CSSConstants.CSS_LETTER_SPACING_PROPERTY),
new SVGColorManager(CSSConstants.CSS_LIGHTING_COLOR_PROPERTY,
ValueConstants.WHITE_RGB_VALUE),
+ new LineHeightManager(),
new MarkerManager(CSSConstants.CSS_MARKER_END_PROPERTY),
new MarkerManager(CSSConstants.CSS_MARKER_MID_PROPERTY),
@@ -335,7 +331,8 @@ public class SVGCSSEngine extends CSSEng
public static final int KERNING_INDEX = IMAGE_RENDERING_INDEX + 1;
public static final int LETTER_SPACING_INDEX = KERNING_INDEX + 1;
public static final int LIGHTING_COLOR_INDEX = LETTER_SPACING_INDEX + 1;
- public static final int MARKER_END_INDEX = LIGHTING_COLOR_INDEX + 1;
+ public static final int LINE_HEIGHT_INDEX = LIGHTING_COLOR_INDEX + 1;
+ public static final int MARKER_END_INDEX = LINE_HEIGHT_INDEX + 1;
public static final int MARKER_MID_INDEX = MARKER_END_INDEX + 1;
Copied: xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/css2/LineHeightManager.java (from r1636251, xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/css2/LineHeightManager.java?p2=xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/css2/LineHeightManager.java&p1=xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java&r1=1636251&r2=1636514&rev=1636514&view=diff
==============================================================================
--- xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java (original)
+++ xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/css2/LineHeightManager.java Tue Nov 4 07:04:57 2014
@@ -17,7 +17,7 @@
*/
-package org.apache.batik.css.engine.value.svg12;
+package org.apache.batik.css.engine.value.css2;
import org.apache.batik.css.engine.CSSEngine;
import org.apache.batik.css.engine.CSSStylableElement;
@@ -25,8 +25,9 @@ import org.apache.batik.css.engine.Style
import org.apache.batik.css.engine.value.LengthManager;
import org.apache.batik.css.engine.value.FloatValue;
import org.apache.batik.css.engine.value.Value;
+import org.apache.batik.css.engine.value.ValueConstants;
import org.apache.batik.css.engine.value.ValueManager;
-import org.apache.batik.util.SVG12CSSConstants;
+import org.apache.batik.util.CSSConstants;
import org.apache.batik.util.SVGTypes;
import org.w3c.css.sac.LexicalUnit;
@@ -76,14 +77,14 @@ public class LineHeightManager extends L
* Implements {@link ValueManager#getPropertyName()}.
*/
public String getPropertyName() {
- return SVG12CSSConstants.CSS_LINE_HEIGHT_PROPERTY;
+ return CSSConstants.CSS_LINE_HEIGHT_PROPERTY;
}
/**
* Implements {@link ValueManager#getDefaultValue()}.
*/
public Value getDefaultValue() {
- return SVG12ValueConstants.NORMAL_VALUE;
+ return ValueConstants.NORMAL_VALUE;
}
/**
@@ -94,11 +95,11 @@ public class LineHeightManager extends L
switch (lu.getLexicalUnitType()) {
case LexicalUnit.SAC_INHERIT:
- return SVG12ValueConstants.INHERIT_VALUE;
+ return ValueConstants.INHERIT_VALUE;
case LexicalUnit.SAC_IDENT: {
String s = lu.getStringValue().toLowerCase();
- if (SVG12CSSConstants.CSS_NORMAL_VALUE.equals(s))
- return SVG12ValueConstants.NORMAL_VALUE;
+ if (CSSConstants.CSS_NORMAL_VALUE.equals(s))
+ return ValueConstants.NORMAL_VALUE;
throw createInvalidIdentifierDOMException(lu.getStringValue());
}
default:
Copied: xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/css2/LineHeightValue.java (from r1636251, xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightValue.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/css2/LineHeightValue.java?p2=xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/css2/LineHeightValue.java&p1=xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightValue.java&r1=1636251&r2=1636514&rev=1636514&view=diff
==============================================================================
--- xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightValue.java (original)
+++ xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/css2/LineHeightValue.java Tue Nov 4 07:04:57 2014
@@ -16,7 +16,7 @@
limitations under the License.
*/
-package org.apache.batik.css.engine.value.svg12;
+package org.apache.batik.css.engine.value.css2;
import org.apache.batik.css.engine.value.FloatValue;
Modified: xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java?rev=1636514&r1=1636513&r2=1636514&view=diff
==============================================================================
--- xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java (original)
+++ xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java Tue Nov 4 07:04:57 2014
@@ -19,157 +19,11 @@
package org.apache.batik.css.engine.value.svg12;
-import org.apache.batik.css.engine.CSSEngine;
-import org.apache.batik.css.engine.CSSStylableElement;
-import org.apache.batik.css.engine.StyleMap;
-import org.apache.batik.css.engine.value.LengthManager;
-import org.apache.batik.css.engine.value.FloatValue;
-import org.apache.batik.css.engine.value.Value;
-import org.apache.batik.css.engine.value.ValueManager;
-import org.apache.batik.util.SVG12CSSConstants;
-import org.apache.batik.util.SVGTypes;
-
-import org.w3c.css.sac.LexicalUnit;
-import org.w3c.dom.css.CSSPrimitiveValue;
-import org.w3c.dom.css.CSSValue;
-import org.w3c.dom.DOMException;
-
/**
* This class provides a factory for the 'margin-*' properties values.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
* @version $Id$
*/
-public class LineHeightManager extends LengthManager {
-
- public LineHeightManager() { }
-
- /**
- * Implements {@link ValueManager#isInheritedProperty()}.
- */
- public boolean isInheritedProperty() {
- return true;
- }
-
- /**
- * Implements {@link ValueManager#isAnimatableProperty()}.
- */
- public boolean isAnimatableProperty() {
- return true;
- }
-
- /**
- * Implements {@link ValueManager#isAdditiveProperty()}.
- */
- public boolean isAdditiveProperty() {
- return true;
- }
-
- /**
- * Implements {@link ValueManager#getPropertyType()}.
- */
- public int getPropertyType() {
- return SVGTypes.TYPE_LINE_HEIGHT_VALUE;
- }
-
- /**
- * Implements {@link ValueManager#getPropertyName()}.
- */
- public String getPropertyName() {
- return SVG12CSSConstants.CSS_LINE_HEIGHT_PROPERTY;
- }
-
- /**
- * Implements {@link ValueManager#getDefaultValue()}.
- */
- public Value getDefaultValue() {
- return SVG12ValueConstants.NORMAL_VALUE;
- }
-
- /**
- * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
- */
- public Value createValue(LexicalUnit lu, CSSEngine engine)
- throws DOMException {
-
- switch (lu.getLexicalUnitType()) {
- case LexicalUnit.SAC_INHERIT:
- return SVG12ValueConstants.INHERIT_VALUE;
- case LexicalUnit.SAC_IDENT: {
- String s = lu.getStringValue().toLowerCase();
- if (SVG12CSSConstants.CSS_NORMAL_VALUE.equals(s))
- return SVG12ValueConstants.NORMAL_VALUE;
- throw createInvalidIdentifierDOMException(lu.getStringValue());
- }
- default:
- return super.createValue(lu, engine);
- }
- }
-
-
- /**
- * Indicates the orientation of the property associated with
- * this manager.
- */
- protected int getOrientation() {
- // Not really used.
- return VERTICAL_ORIENTATION;
- }
-
-
- /**
- * Implements {@link
- * ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}.
- */
- public Value computeValue(CSSStylableElement elt,
- String pseudo,
- CSSEngine engine,
- int idx,
- StyleMap sm,
- Value value) {
- if (value.getCssValueType() != CSSValue.CSS_PRIMITIVE_VALUE)
- return value;
-
- switch (value.getPrimitiveType()) {
- case CSSPrimitiveValue.CSS_NUMBER:
- return new LineHeightValue(CSSPrimitiveValue.CSS_NUMBER,
- value.getFloatValue(), true);
-
- case CSSPrimitiveValue.CSS_PERCENTAGE: {
- float v = value.getFloatValue();
- int fsidx = engine.getFontSizeIndex();
- float fs = engine.getComputedStyle
- (elt, pseudo, fsidx).getFloatValue();
- return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, v * fs * 0.01f);
- }
-
- default:
- return super.computeValue(elt, pseudo, engine, idx, sm, value);
- }
- }
+public class LineHeightManager extends org.apache.batik.css.engine.value.css2.LineHeightManager {
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Modified: xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightValue.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightValue.java?rev=1636514&r1=1636513&r2=1636514&view=diff
==============================================================================
--- xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightValue.java (original)
+++ xmlgraphics/batik/branches/text-background/sources/org/apache/batik/css/engine/value/svg12/LineHeightValue.java Tue Nov 4 07:04:57 2014
@@ -18,8 +18,6 @@
*/
package org.apache.batik.css.engine.value.svg12;
-import org.apache.batik.css.engine.value.FloatValue;
-
/**
* This class represents line-height values. These are basically
* FloatValues except that it may be 'font-size' relative.
@@ -27,26 +25,8 @@ import org.apache.batik.css.engine.value
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
* @version $Id$
*/
-public class LineHeightValue extends FloatValue {
-
- /**
- * True if the line-height is relative to the font-size
- */
- protected boolean fontSizeRelative;
-
- /**
- * Creates a new value.
- */
- public LineHeightValue(short unitType, float floatValue,
- boolean fontSizeRelative) {
- super(unitType, floatValue);
- this.fontSizeRelative = fontSizeRelative;
- }
-
- /**
- * The type of the value.
- */
- public boolean getFontSizeRelative() {
- return fontSizeRelative;
+public class LineHeightValue extends org.apache.batik.css.engine.value.css2.LineHeightValue {
+ public LineHeightValue(short unitType, float floatValue, boolean fontSizeRelative) {
+ super(unitType, floatValue, fontSizeRelative);
}
}
Modified: xmlgraphics/batik/branches/text-background/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/text-background/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java?rev=1636514&r1=1636513&r2=1636514&view=diff
==============================================================================
--- xmlgraphics/batik/branches/text-background/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java (original)
+++ xmlgraphics/batik/branches/text-background/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java Tue Nov 4 07:04:57 2014
@@ -135,13 +135,16 @@ public class StrokingTextPainter extends
public static final GVTAttributedCharacterIterator.TextAttribute ALT_GLYPH_HANDLER =
GVTAttributedCharacterIterator.TextAttribute.ALT_GLYPH_HANDLER;
+ public static final
+ AttributedCharacterIterator.Attribute LINE_HEIGHT
+ = GVTAttributedCharacterIterator.TextAttribute.LINE_HEIGHT;
+
static Set extendedAtts = new HashSet();
static {
extendedAtts.add(FLOW_PARAGRAPH);
extendedAtts.add(TEXT_COMPOUND_ID);
extendedAtts.add(GVT_FONT);
- // extendedAtts.add(BIDI_LEVEL);
}
/**
@@ -904,7 +907,7 @@ public class StrokingTextPainter extends
Point2D firstPosition = gv.getGlyphPosition(0);
Map textAttributes = node.getTextAttributes();
double fontSize = (textAttributes != null) ? ((Float) textAttributes.get(TextAttribute.SIZE)).doubleValue() : 0d;
- double lineHeight = fontSize * 1.25f;
+ double lineHeight = (textAttributes != null) ? ((Float) textAttributes.get(LINE_HEIGHT)).doubleValue() : fontSize * 1.1f;
return computeLineHeightBounds(firstPosition, ascent, emHeight, lineHeight, node.getPrimitiveBounds().getWidth());
} else {
return new Rectangle2D.Double();
@@ -952,7 +955,7 @@ public class StrokingTextPainter extends
Point2D firstPosition = new Point2D.Double(bbox.getX(), gv.getGlyphPosition(0).getY());
AttributedCharacterIterator aci = run.getACI();
double fontSize = (aci != null) ? ((Float) aci.getAttribute(TextAttribute.SIZE)).doubleValue() : 0d;
- double lineHeight = fontSize * 1.25f;
+ double lineHeight = (aci != null) ? ((Float) aci.getAttribute(LINE_HEIGHT)).doubleValue() : fontSize * 1.1f;
return computeLineHeightBounds(firstPosition, ascent, emHeight, lineHeight, bbox.getWidth());
} else {
return new Rectangle2D.Double();
Modified: xmlgraphics/batik/branches/text-background/sources/org/apache/batik/util/SVG12CSSConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/text-background/sources/org/apache/batik/util/SVG12CSSConstants.java?rev=1636514&r1=1636513&r2=1636514&view=diff
==============================================================================
--- xmlgraphics/batik/branches/text-background/sources/org/apache/batik/util/SVG12CSSConstants.java (original)
+++ xmlgraphics/batik/branches/text-background/sources/org/apache/batik/util/SVG12CSSConstants.java Tue Nov 4 07:04:57 2014
@@ -56,7 +56,5 @@ public interface SVG12CSSConstants exten
String CSS_END_VALUE = "end";
/** Value for text-align to both edges of region */
String CSS_FULL_VALUE = "full";
- /** Value for line-height for 'normal' line height */
- String CSS_NORMAL_VALUE = "normal";
}