diff options
author | Finn Bock <bckfnn@apache.org> | 2004-10-19 20:13:23 +0000 |
---|---|---|
committer | Finn Bock <bckfnn@apache.org> | 2004-10-19 20:13:23 +0000 |
commit | 814707bcb841e02727b4bdbbf3e16941e68b30ae (patch) | |
tree | 36937c55c8e55a3b0df4a07afc8e0b894f540ea4 /src/java/org/apache/fop/traits | |
parent | 99602d2f4ad5926b0b3c2ffa3bb7c9c8f88373d2 (diff) | |
download | xmlgraphics-fop-814707bcb841e02727b4bdbbf3e16941e68b30ae.tar.gz xmlgraphics-fop-814707bcb841e02727b4bdbbf3e16941e68b30ae.zip |
Third phase of performance improvement.
- Added factory methods to create letter and word SpaceVal.
PR: 31699
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198067 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/traits')
-rw-r--r-- | src/java/org/apache/fop/traits/SpaceVal.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/traits/SpaceVal.java b/src/java/org/apache/fop/traits/SpaceVal.java index a9c869d67..3b1557d42 100644 --- a/src/java/org/apache/fop/traits/SpaceVal.java +++ b/src/java/org/apache/fop/traits/SpaceVal.java @@ -21,6 +21,7 @@ package org.apache.fop.traits; import org.apache.fop.fo.Constants; import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.SpaceProperty; +import org.apache.fop.fonts.Font; /** * Store a single Space property value in simplified form, with all @@ -68,6 +69,30 @@ public class SpaceVal { this.iPrecedence = iPrecedence; } + static public SpaceVal makeWordSpacing(Property wordSpacing, SpaceVal letterSpacing, Font fs) { + if (wordSpacing.getEnum() == Constants.NORMAL) { + // give word spaces the possibility to shrink by a third, + // and stretch by a half; + int spaceCharIPD = fs.getCharWidth(' '); + MinOptMax space = new MinOptMax(-spaceCharIPD / 3, 0, spaceCharIPD / 2); + return new SpaceVal( + MinOptMax.add + (space, MinOptMax.multiply(letterSpacing.getSpace(), 2)), + true, true, 0); + } else { + return new SpaceVal(wordSpacing.getSpace()); + } + } + + static public SpaceVal makeLetterSpacing(Property letterSpacing) { + if (letterSpacing.getEnum() == Constants.NORMAL) { + // letter spaces are set to zero (or use different values?) + return new SpaceVal(new MinOptMax(0), true, true, 0); + } else { + return new SpaceVal(letterSpacing.getSpace()); + } + } + /** * Returns the Conditionality value. * @return the Conditionality value |