From 814707bcb841e02727b4bdbbf3e16941e68b30ae Mon Sep 17 00:00:00 2001 From: Finn Bock Date: Tue, 19 Oct 2004 20:13:23 +0000 Subject: [PATCH] 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 --- src/java/org/apache/fop/traits/SpaceVal.java | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) 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 -- 2.39.5