You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ga...@apache.org on 2012/02/26 03:29:29 UTC
svn commit: r1293736 [17/38] - in /xmlgraphics/fop/trunk: ./
src/codegen/java/org/apache/fop/tools/
src/codegen/unicode/java/org/apache/fop/complexscripts/
src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/
src/documentation/content/xdocs/tru...
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ListItem.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ListItem.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ListItem.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ListItem.java Sun Feb 26 02:29:01 2012
@@ -19,9 +19,12 @@
package org.apache.fop.fo.flow;
+import java.util.Stack;
+
import org.xml.sax.Locator;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.complexscripts.bidi.DelimitedTextRange;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
@@ -201,5 +204,19 @@ public class ListItem extends FObj imple
public int getNameId() {
return FO_LIST_ITEM;
}
+
+ @Override
+ protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) {
+ ListItemLabel label = getLabel();
+ if ( label != null ) {
+ ranges = label.collectDelimitedTextRanges ( ranges );
+ }
+ ListItemBody body = getBody();
+ if ( body != null ) {
+ ranges = body.collectDelimitedTextRanges ( ranges );
+ }
+ return ranges;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/PageNumber.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/PageNumber.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/PageNumber.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/PageNumber.java Sun Feb 26 02:29:01 2012
@@ -199,4 +199,10 @@ public class PageNumber extends FObj
public int getNameId() {
return FO_PAGE_NUMBER;
}
+
+ @Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Wrapper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Wrapper.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Wrapper.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Wrapper.java Sun Feb 26 02:29:01 2012
@@ -135,5 +135,11 @@ public class Wrapper extends FObjMixed {
public int getNameId() {
return FO_WRAPPER;
}
+
+ @Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/Table.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/Table.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/Table.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/Table.java Sun Feb 26 02:29:01 2012
@@ -48,7 +48,7 @@ import org.apache.fop.fo.properties.Tabl
public class Table extends TableFObj implements ColumnNumberManagerHolder, BreakPropertySet,
CommonAccessibilityHolder {
- /** properties */
+ // The value of FO traits (refined properties) that apply to fo:table.
private CommonAccessibility commonAccessibility;
private CommonBorderPaddingBackground commonBorderPaddingBackground;
private CommonMarginBlock commonMarginBlock;
@@ -64,11 +64,12 @@ public class Table extends TableFObj imp
private int tableLayout;
private int tableOmitFooterAtBreak;
private int tableOmitHeaderAtBreak;
+ private int writingMode;
// Unused but valid items, commented out for performance:
// private CommonAural commonAural;
// private CommonRelativePosition commonRelativePosition;
// private int intrusionDisplace;
- // private int writingMode;
+ // End of FO trait values
/** extension properties */
private Length widowContentLimit;
@@ -130,6 +131,7 @@ public class Table extends TableFObj imp
tableLayout = pList.get(PR_TABLE_LAYOUT).getEnum();
tableOmitFooterAtBreak = pList.get(PR_TABLE_OMIT_FOOTER_AT_BREAK).getEnum();
tableOmitHeaderAtBreak = pList.get(PR_TABLE_OMIT_HEADER_AT_BREAK).getEnum();
+ writingMode = pList.get(PR_WRITING_MODE).getEnum();
//Bind extension properties
widowContentLimit = pList.get(PR_X_WIDOW_CONTENT_LIMIT).getLength();
@@ -336,7 +338,6 @@ public class Table extends TableFObj imp
TableColumn implicitColumn = new TableColumn(this, true);
PropertyList pList = new StaticPropertyList(
implicitColumn, this.propList);
- pList.setWritingMode();
implicitColumn.bind(pList);
implicitColumn.setColumnWidth(new TableColLength(1.0, implicitColumn));
implicitColumn.setColumnNumber(colNumber);
@@ -433,14 +434,14 @@ public class Table extends TableFObj imp
}
/**
- * @return the "inline-progression-dimension" property.
+ * @return the "inline-progression-dimension" FO trait.
*/
public LengthRangeProperty getInlineProgressionDimension() {
return inlineProgressionDimension;
}
/**
- * @return the "block-progression-dimension" property.
+ * @return the "block-progression-dimension" FO trait.
*/
public LengthRangeProperty getBlockProgressionDimension() {
return blockProgressionDimension;
@@ -460,27 +461,27 @@ public class Table extends TableFObj imp
return commonBorderPaddingBackground;
}
- /** @return the "break-after" property. */
+ /** @return the "break-after" FO trait. */
public int getBreakAfter() {
return breakAfter;
}
- /** @return the "break-before" property. */
+ /** @return the "break-before" FO trait. */
public int getBreakBefore() {
return breakBefore;
}
- /** @return the "keep-with-next" property. */
+ /** @return the "keep-with-next" FO trait. */
public KeepProperty getKeepWithNext() {
return keepWithNext;
}
- /** @return the "keep-with-previous" property. */
+ /** @return the "keep-with-previous" FO trait. */
public KeepProperty getKeepWithPrevious() {
return keepWithPrevious;
}
- /** @return the "keep-together" property. */
+ /** @return the "keep-together" FO trait. */
public KeepProperty getKeepTogether() {
return keepTogether;
}
@@ -494,7 +495,7 @@ public class Table extends TableFObj imp
|| !getKeepTogether().getWithinColumn().isAuto();
}
- /** @return the "border-collapse" property. */
+ /** @return the "border-collapse" FO trait. */
public int getBorderCollapse() {
return borderCollapse;
}
@@ -504,17 +505,22 @@ public class Table extends TableFObj imp
return (getBorderCollapse() == EN_SEPARATE);
}
- /** @return the "border-separation" property. */
+ /** @return the "border-separation" FO trait. */
public LengthPairProperty getBorderSeparation() {
return borderSeparation;
}
- /** @return the "fox:widow-content-limit" extension property */
+ /** @return the "writing-mode" FO trait */
+ public int getWritingMode() {
+ return writingMode;
+ }
+
+ /** @return the "fox:widow-content-limit" extension FO trait */
public Length getWidowContentLimit() {
return widowContentLimit;
}
- /** @return the "fox:orphan-content-limit" extension property */
+ /** @return the "fox:orphan-content-limit" extension FO trait */
public Length getOrphanContentLimit() {
return orphanContentLimit;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java Sun Feb 26 02:29:01 2012
@@ -43,6 +43,9 @@ public abstract class AbstractPageSequen
private char groupingSeparator;
private int groupingSize;
private Numeric referenceOrientation; //XSL 1.1
+ private String language;
+ private String country;
+ private String numberConversionFeatures;
// End of property values
private PageNumberGenerator pageNumberGenerator;
@@ -70,12 +73,16 @@ public abstract class AbstractPageSequen
groupingSeparator = pList.get(PR_GROUPING_SEPARATOR).getCharacter();
groupingSize = pList.get(PR_GROUPING_SIZE).getNumber().intValue();
referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
+ language = pList.get(PR_LANGUAGE).getString();
+ country = pList.get(PR_COUNTRY).getString();
+ numberConversionFeatures = pList.get(PR_X_NUMBER_CONVERSION_FEATURES).getString();
}
/** {@inheritDoc} */
protected void startOfNode() throws FOPException {
this.pageNumberGenerator = new PageNumberGenerator(
- format, groupingSeparator, groupingSize, letterValue);
+ format, groupingSeparator, groupingSize, letterValue,
+ numberConversionFeatures, language, country);
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java Sun Feb 26 02:29:01 2012
@@ -19,84 +19,37 @@
package org.apache.fop.fo.pagination;
+import org.apache.fop.complexscripts.util.NumberConverter;
+
+// CSOFF: LineLengthCheck
+
/**
* This class uses the 'format', 'groupingSeparator', 'groupingSize',
* and 'letterValue' properties on fo:page-sequence to return a String
* corresponding to the supplied integer page number.
+ *
+ * In addition, (now) uses 'language' parameter and new 'fox:page-number-features'
+ * parameter to express applicable language and number conversion features.
+ *
+ * @author Glenn Adams (rewrite to use new NumberConverter utility)
+ * @see NumberConverter
*/
public class PageNumberGenerator {
- private String format;
- private char groupingSeparator;
- private int groupingSize;
- private int letterValue;
-
- // constants
- private static final int DECIMAL = 1; // '0*1'
- private static final int LOWERALPHA = 2; // 'a'
- private static final int UPPERALPHA = 3; // 'A'
- private static final int LOWERROMAN = 4; // 'i'
- private static final int UPPERROMAN = 5; // 'I'
-
- // flags
- private int formatType = DECIMAL;
- private int minPadding = 0; // for decimal formats
-
- // preloaded strings of zeros
- private String[] zeros = {
- "", "0", "00", "000", "0000", "00000"
- };
+ private NumberConverter converter;
/**
- * Main constructor. For further information on the parameters see the XSLT
- * specs (Number to String Conversion Attributes).
- * @param format format for the page number
- * @param groupingSeparator grouping separator
- * @param groupingSize grouping size
+ * Main constructor. For further information on the parameters see {@link NumberConverter}.
+ * @param format format for the page number (may be null or empty, which is treated as null)
+ * @param groupingSeparator grouping separator (if zero, then no grouping separator applies)
+ * @param groupingSize grouping size (if zero or negative, then no grouping size applies)
* @param letterValue letter value
+ * @param features features (feature sub-parameters)
+ * @param language (may be null or empty, which is treated as null)
+ * @param country (may be null or empty, which is treated as null)
*/
- public PageNumberGenerator(String format, char groupingSeparator,
- int groupingSize, int letterValue) {
- this.format = format;
- this.groupingSeparator = groupingSeparator;
- this.groupingSize = groupingSize;
- this.letterValue = letterValue;
-
- // the only accepted format strings are currently '0*1' 'a', 'A', 'i'
- // and 'I'
- int fmtLen = format.length();
- if (fmtLen == 1) {
- if (format.equals("1")) {
- formatType = DECIMAL;
- minPadding = 0;
- } else if (format.equals("a")) {
- formatType = LOWERALPHA;
- } else if (format.equals("A")) {
- formatType = UPPERALPHA;
- } else if (format.equals("i")) {
- formatType = LOWERROMAN;
- } else if (format.equals("I")) {
- formatType = UPPERROMAN;
- } else {
- // token not handled
- //getLogger().debug("'format' token not recognized; using '1'");
- formatType = DECIMAL;
- minPadding = 0;
- }
- } else {
- // only accepted token is '0+1'at this stage. Because of the
- // wonderful regular expression support in Java, we will resort to a
- // loop
- for (int i = 0; i < fmtLen - 1; i++) {
- if (format.charAt(i) != '0') {
- //getLogger().debug("'format' token not recognized; using '1'");
- formatType = DECIMAL;
- minPadding = 0;
- } else {
- minPadding = fmtLen - 1;
- }
- }
- }
+ public PageNumberGenerator ( String format, int groupingSeparator, int groupingSize, int letterValue, String features, String language, String country ) {
+ this.converter = new NumberConverter ( format, groupingSeparator, groupingSize, letterValue, features, language, country );
}
/**
@@ -104,70 +57,9 @@ public class PageNumberGenerator {
* @param number page number to format
* @return the formatted page number as a String
*/
- public String makeFormattedPageNumber(int number) {
- String pn = null;
- if (formatType == DECIMAL) {
- pn = Integer.toString(number);
- if (minPadding >= pn.length()) {
- int nz = minPadding - pn.length() + 1;
- pn = zeros[nz] + pn;
- }
- } else if ((formatType == LOWERROMAN) || (formatType == UPPERROMAN)) {
- pn = makeRoman(number);
- if (formatType == UPPERROMAN) {
- pn = pn.toUpperCase();
- }
- } else {
- // alphabetic
- pn = makeAlpha(number);
- if (formatType == UPPERALPHA) {
- pn = pn.toUpperCase();
- }
- }
- return pn;
+ public String makeFormattedPageNumber ( int number ) {
+ return converter.convert ( number );
}
- private String makeRoman(int num) {
- int[] arabic = {
- 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1
- };
- String[] roman = {
- "m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv",
- "i"
- };
-
- int i = 0;
- StringBuffer romanNumber = new StringBuffer();
-
- while (num > 0) {
- while (num >= arabic[i]) {
- num = num - arabic[i];
- romanNumber.append(roman[i]);
- }
- i = i + 1;
- }
- return romanNumber.toString();
- }
-
- private String makeAlpha(int num) {
- String letters = "abcdefghijklmnopqrstuvwxyz";
- StringBuffer alphaNumber = new StringBuffer();
-
- int base = 26;
- int rem = 0;
-
- num--;
- if (num < base) {
- alphaNumber.append(letters.charAt(num));
- } else {
- while (num >= base) {
- rem = num % base;
- alphaNumber.append(letters.charAt(rem));
- num = num / base;
- }
- alphaNumber.append(letters.charAt(num - 1));
- }
- return alphaNumber.reverse().toString();
- }
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java Sun Feb 26 02:29:01 2012
@@ -19,28 +19,35 @@
package org.apache.fop.fo.pagination;
-// Java
import java.util.Map;
+import java.util.Stack;
import org.xml.sax.Locator;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.complexscripts.bidi.DelimitedTextRange;
+import org.apache.fop.datatypes.Numeric;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
+import org.apache.fop.traits.Direction;
+import org.apache.fop.traits.WritingMode;
+import org.apache.fop.traits.WritingModeTraits;
+import org.apache.fop.traits.WritingModeTraitsGetter;
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_page-sequence">
* <code>fo:page-sequence</code></a> object.
*/
-public class PageSequence extends AbstractPageSequence {
+public class PageSequence extends AbstractPageSequence implements WritingModeTraitsGetter {
- // The value of properties relevant for fo:page-sequence.
+ // The value of FO traits (refined properties) that apply to fo:page-sequence.
private String country;
private String language;
private String masterReference;
- //private int writingMode; //XSL 1.1
- // End of property values
+ private Numeric referenceOrientation;
+ private WritingModeTraits writingModeTraits;
+ // End of trait values
// There doesn't seem to be anything in the spec requiring flows
// to be in the order given, only that they map to the regions
@@ -86,8 +93,9 @@ public class PageSequence extends Abstra
country = pList.get(PR_COUNTRY).getString();
language = pList.get(PR_LANGUAGE).getString();
masterReference = pList.get(PR_MASTER_REFERENCE).getString();
- //writingMode = pList.getWritingMode();
-
+ referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
+ writingModeTraits = new WritingModeTraits
+ ( WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum()) );
if (masterReference == null || masterReference.equals("")) {
missingPropertyError("master-reference");
}
@@ -292,8 +300,8 @@ public class PageSequence extends Abstra
}
/**
- * Get the value of the <code>master-reference</code> property.
- * @return the "master-reference" property
+ * Get the value of the <code>master-reference</code> trait.
+ * @return the "master-reference" trait
*/
public String getMasterReference() {
return masterReference;
@@ -313,22 +321,120 @@ public class PageSequence extends Abstra
}
/**
- * Get the value of the <code>country</code> property.
- * @return the country property value
+ * Get the value of the <code>country</code> trait.
+ * @return the country trait value
*/
public String getCountry() {
return this.country;
}
/**
- * Get the value of the <code>language</code> property.
- * @return the language property value
+ * Get the value of the <code>language</code> trait.
+ * @return the language trait value
*/
public String getLanguage() {
return this.language;
}
/**
+ * Get the value of the <code>reference-orientation</code> trait.
+ * @return the reference orientation trait value
+ */
+ public int getReferenceOrientation() {
+ if ( referenceOrientation != null ) {
+ return referenceOrientation.getValue();
+ } else {
+ return 0;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Direction getInlineProgressionDirection() {
+ if ( writingModeTraits != null ) {
+ return writingModeTraits.getInlineProgressionDirection();
+ } else {
+ return Direction.LR;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Direction getBlockProgressionDirection() {
+ if ( writingModeTraits != null ) {
+ return writingModeTraits.getBlockProgressionDirection();
+ } else {
+ return Direction.TB;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Direction getColumnProgressionDirection() {
+ if ( writingModeTraits != null ) {
+ return writingModeTraits.getColumnProgressionDirection();
+ } else {
+ return Direction.LR;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Direction getRowProgressionDirection() {
+ if ( writingModeTraits != null ) {
+ return writingModeTraits.getRowProgressionDirection();
+ } else {
+ return Direction.TB;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Direction getShiftDirection() {
+ if ( writingModeTraits != null ) {
+ return writingModeTraits.getShiftDirection();
+ } else {
+ return Direction.TB;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WritingMode getWritingMode() {
+ if ( writingModeTraits != null ) {
+ return writingModeTraits.getWritingMode();
+ } else {
+ return WritingMode.LR_TB;
+ }
+ }
+
+
+ @Override
+ protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) {
+ // collect ranges from static content flows
+ Map<String, FONode> flows = getFlowMap();
+ if ( flows != null ) {
+ for ( FONode fn : flows.values() ) {
+ if ( fn instanceof StaticContent ) {
+ ranges = ( (StaticContent) fn ).collectDelimitedTextRanges ( ranges );
+ }
+ }
+ }
+ // collect ranges in main flow
+ Flow main = getMainFlow();
+ if ( main != null ) {
+ ranges = main.collectDelimitedTextRanges ( ranges );
+ }
+ return ranges;
+ }
+
+ /**
* Releases a page-sequence's children after the page-sequence has been fully processed.
*/
public void releasePageSequence() {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java Sun Feb 26 02:29:01 2012
@@ -32,20 +32,21 @@ import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.traits.WritingMode;
/**
* This is an abstract base class for pagination regions.
*/
public abstract class Region extends FObj {
- // The value of properties relevant for fo:region
+ // The value of FO traits (refined properties) that apply to fo:region
private CommonBorderPaddingBackground commonBorderPaddingBackground;
// private ToBeImplementedProperty clip
private int displayAlign;
private int overflow;
private String regionName;
private Numeric referenceOrientation;
- private int writingMode;
- // End of property values
+ private WritingMode writingMode;
+ // End of FO trait values
/** the parent {@link SimplePageMaster} */
protected final SimplePageMaster layoutMaster;
@@ -68,7 +69,7 @@ public abstract class Region extends FOb
overflow = pList.get(PR_OVERFLOW).getEnum();
regionName = pList.get(PR_REGION_NAME).getString();
referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
- writingMode = pList.getWritingMode();
+ writingMode = WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum());
// regions may have name, or default
if (regionName.equals("")) {
@@ -169,28 +170,28 @@ public abstract class Region extends FOb
return commonBorderPaddingBackground;
}
- /** @return the "region-name" property. */
+ /** @return the "region-name" FO trait. */
public String getRegionName() {
return regionName;
}
- /** @return the "writing-mode" property. */
- public int getWritingMode() {
- return writingMode;
- }
-
- /** @return the "overflow" property. */
+ /** @return the "overflow" FO trait. */
public int getOverflow() {
return overflow;
}
- /** @return the display-align property. */
+ /** @return the display-align FO trait. */
public int getDisplayAlign() {
return displayAlign;
}
- /** @return the "reference-orientation" property. */
+ /** @return the "reference-orientation" FO trait. */
public int getReferenceOrientation() {
return referenceOrientation.getValue();
}
+
+ /** @return the "writing-mode" FO trait. */
+ public WritingMode getWritingMode() {
+ return writingMode;
+ }
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java Sun Feb 26 02:29:01 2012
@@ -23,6 +23,7 @@ package org.apache.fop.fo.pagination;
import java.awt.Rectangle;
// FOP
+import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.LengthBase;
@@ -52,15 +53,22 @@ public class RegionAfter extends RegionB
PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
PercentBaseContext neighbourContext;
Rectangle vpRect;
- if (layoutMaster.getWritingMode() == EN_LR_TB
- || layoutMaster.getWritingMode() == EN_RL_TB) {
+
+ // [TBD] WRITING MODE ALERT
+ switch ( getWritingMode().getEnumValue() ) {
+ default:
+ case Constants.EN_LR_TB:
+ case Constants.EN_RL_TB:
neighbourContext = pageWidthContext;
vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageHeightContext)
, reldims.ipd, getExtent().getValue(pageHeightContext));
- } else {
+ break;
+ case Constants.EN_TB_LR:
+ case Constants.EN_TB_RL:
neighbourContext = pageHeightContext;
vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageWidthContext)
, getExtent().getValue(pageWidthContext), reldims.ipd);
+ break;
}
if (getPrecedence() == EN_FALSE) {
adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBA.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBA.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBA.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBA.java Sun Feb 26 02:29:01 2012
@@ -26,6 +26,7 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
+import org.apache.fop.traits.WritingMode;
/**
* Abstract base class for <a href="http://www.w3.org/TR/xsl/#fo_region-before">
@@ -70,7 +71,8 @@ public abstract class RegionBA extends S
* @param wm writing mode
* @param siblingContext the context to use to resolve extent on siblings
*/
- protected void adjustIPD(Rectangle vpRefRect, int wm, PercentBaseContext siblingContext) {
+ protected void adjustIPD
+ ( Rectangle vpRefRect, WritingMode wm, PercentBaseContext siblingContext ) {
int offset = 0;
RegionStart start = (RegionStart) getSiblingRegion(FO_REGION_START);
if (start != null) {
@@ -81,8 +83,9 @@ public abstract class RegionBA extends S
if (end != null) {
offset += end.getExtent().getValue(siblingContext);
}
+ // [TBD] WRITING MODE ALERT
if (offset > 0) {
- if (wm == EN_LR_TB || wm == EN_RL_TB) {
+ if (wm == WritingMode.LR_TB || wm == WritingMode.RL_TB) {
vpRefRect.width -= offset;
} else {
vpRefRect.height -= offset;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java Sun Feb 26 02:29:01 2012
@@ -23,6 +23,7 @@ package org.apache.fop.fo.pagination;
import java.awt.Rectangle;
// FOP
+import org.apache.fop.fo.Constants;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.LengthBase;
import org.apache.fop.datatypes.PercentBaseContext;
@@ -57,13 +58,19 @@ public class RegionBefore extends Region
PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
PercentBaseContext neighbourContext;
Rectangle vpRect;
- if (layoutMaster.getWritingMode() == EN_LR_TB
- || layoutMaster.getWritingMode() == EN_RL_TB) {
+ // [TBD] WRITING MODE ALERT
+ switch ( getWritingMode().getEnumValue() ) {
+ default:
+ case Constants.EN_LR_TB:
+ case Constants.EN_RL_TB:
neighbourContext = pageWidthContext;
vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue(pageHeightContext));
- } else {
+ break;
+ case Constants.EN_TB_LR:
+ case Constants.EN_TB_RL:
neighbourContext = pageHeightContext;
vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.ipd);
+ break;
}
if (getPrecedence() == EN_FALSE) {
adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java Sun Feb 26 02:29:01 2012
@@ -28,9 +28,11 @@ import org.apache.fop.datatypes.Length;
import org.apache.fop.datatypes.LengthBase;
import org.apache.fop.datatypes.Numeric;
import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.properties.CommonMarginBlock;
+import org.apache.fop.traits.WritingMode;
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_region-body">
@@ -113,12 +115,22 @@ public class RegionBody extends Region {
int start;
int end;
- if (layoutMaster.getWritingMode() == EN_LR_TB) { // Left-to-right
+ // [TBD] WRITING MODE ALERT
+ switch ( getWritingMode().getEnumValue() ) {
+ default:
+ case Constants.EN_LR_TB:
start = commonMarginBlock.marginLeft.getValue(pageWidthContext);
end = commonMarginBlock.marginRight.getValue(pageWidthContext);
- } else { // all other supported modes are right-to-left
+ break;
+ case Constants.EN_RL_TB:
start = commonMarginBlock.marginRight.getValue(pageWidthContext);
end = commonMarginBlock.marginLeft.getValue(pageWidthContext);
+ break;
+ case Constants.EN_TB_LR:
+ case Constants.EN_TB_RL:
+ start = commonMarginBlock.marginTop.getValue(pageWidthContext);
+ end = commonMarginBlock.marginBottom.getValue(pageWidthContext);
+ break;
}
int before = commonMarginBlock.spaceBefore.getOptimum(pageHeightContext)
.getLength().getValue(pageHeightContext);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java Sun Feb 26 02:29:01 2012
@@ -23,6 +23,7 @@ package org.apache.fop.fo.pagination;
import java.awt.Rectangle;
// FOP
+import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.LengthBase;
@@ -52,18 +53,27 @@ public class RegionEnd extends RegionSE
PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
PercentBaseContext neighbourContext;
Rectangle vpRect;
- if (layoutMaster.getWritingMode() == EN_LR_TB
- || layoutMaster.getWritingMode() == EN_RL_TB) {
+ // [TBD] WRITING MODE ALERT
+ switch ( getWritingMode().getEnumValue() ) {
+ default:
+ case Constants.EN_LR_TB:
neighbourContext = pageHeightContext;
vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageWidthContext), 0,
getExtent().getValue(pageWidthContext), reldims.bpd);
- } else {
+ break;
+ case Constants.EN_RL_TB:
+ neighbourContext = pageHeightContext;
+ vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.bpd);
+ break;
+ case Constants.EN_TB_LR:
+ case Constants.EN_TB_RL:
// Rectangle: x , y (of top left point), width, height
neighbourContext = pageWidthContext;
vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageHeightContext), 0,
reldims.bpd, getExtent().getValue(pageHeightContext));
+ break;
}
- adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext);
+ adjustIPD(vpRect, getWritingMode(), neighbourContext);
return vpRect;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionSE.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionSE.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionSE.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionSE.java Sun Feb 26 02:29:01 2012
@@ -26,6 +26,7 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
+import org.apache.fop.traits.WritingMode;
/**
* Abstract base class for <a href="http://www.w3.org/TR/xsl/#fo_region-start">
@@ -61,7 +62,8 @@ public abstract class RegionSE extends S
* @param wm writing mode
* @param siblingContext the context to use to resolve extent on siblings
*/
- protected void adjustIPD(Rectangle vpRefRect, int wm, PercentBaseContext siblingContext) {
+ protected void adjustIPD
+ ( Rectangle vpRefRect, WritingMode wm, PercentBaseContext siblingContext ) {
int offset = 0;
RegionBefore before = (RegionBefore) getSiblingRegion(FO_REGION_BEFORE);
if (before != null && before.getPrecedence() == EN_TRUE) {
@@ -72,8 +74,9 @@ public abstract class RegionSE extends S
if (after != null && after.getPrecedence() == EN_TRUE) {
offset += after.getExtent().getValue(siblingContext);
}
+ // [TBD] WRITING MODE ALERT
if (offset > 0) {
- if (wm == EN_LR_TB || wm == EN_RL_TB) {
+ if (wm == WritingMode.LR_TB || wm == WritingMode.RL_TB) {
vpRefRect.height -= offset;
} else {
vpRefRect.width -= offset;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java Sun Feb 26 02:29:01 2012
@@ -23,6 +23,7 @@ package org.apache.fop.fo.pagination;
import java.awt.Rectangle;
// FOP
+import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.LengthBase;
@@ -52,13 +53,23 @@ public class RegionStart extends RegionS
PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
PercentBaseContext neighbourContext;
Rectangle vpRect;
- if (layoutMaster.getWritingMode() == EN_LR_TB
- || layoutMaster.getWritingMode() == EN_RL_TB) {
+ // [TBD] WRITING MODE ALERT
+ switch ( getWritingMode().getEnumValue() ) {
+ default:
+ case Constants.EN_LR_TB:
neighbourContext = pageHeightContext;
vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.bpd);
- } else {
+ break;
+ case Constants.EN_RL_TB:
+ neighbourContext = pageHeightContext;
+ vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageWidthContext), 0,
+ getExtent().getValue(pageWidthContext), reldims.bpd);
+ break;
+ case Constants.EN_TB_LR:
+ case Constants.EN_TB_RL:
neighbourContext = pageWidthContext;
vpRect = new Rectangle(0, 0, reldims.bpd, getExtent().getValue(pageHeightContext));
+ break;
}
adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext);
return vpRect;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java Sun Feb 26 02:29:01 2012
@@ -35,6 +35,7 @@ import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.properties.CommonMarginBlock;
+import org.apache.fop.traits.WritingMode;
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_simple-page-master">
@@ -43,14 +44,14 @@ import org.apache.fop.fo.properties.Comm
* and attributes.
*/
public class SimplePageMaster extends FObj {
- // The value of properties relevant for fo:simple-page-master.
+ // The value of FO traits (refined properties) that apply to fo:simple-page-master.
private CommonMarginBlock commonMarginBlock;
private String masterName;
private Length pageHeight;
private Length pageWidth;
private Numeric referenceOrientation;
- private int writingMode;
- // End of property values
+ private WritingMode writingMode;
+ // End of FO trait values
/**
* Page regions (regionClass, Region)
@@ -80,7 +81,7 @@ public class SimplePageMaster extends FO
pageHeight = pList.get(PR_PAGE_HEIGHT).getLength();
pageWidth = pList.get(PR_PAGE_WIDTH).getLength();
referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
- writingMode = pList.getWritingMode();
+ writingMode = WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum());
if (masterName == null || masterName.equals("")) {
missingPropertyError("master-name");
@@ -269,31 +270,31 @@ public class SimplePageMaster extends FO
return commonMarginBlock;
}
- /** @return "master-name" property. */
+ /** @return "master-name" FO trait. */
public String getMasterName() {
return masterName;
}
- /** @return the "page-width" property. */
+ /** @return the "page-width" FO trait. */
public Length getPageWidth() {
return pageWidth;
}
- /** @return the "page-height" property. */
+ /** @return the "page-height" FO trait. */
public Length getPageHeight() {
return pageHeight;
}
- /** @return the "writing-mode" property. */
- public int getWritingMode() {
- return writingMode;
- }
-
- /** @return the "reference-orientation" property. */
+ /** @return the "reference-orientation" FO trait. */
public int getReferenceOrientation() {
return referenceOrientation.getValue();
}
+ /** @return the "writing-mode" FO trait. */
+ public WritingMode getWritingMode() {
+ return writingMode;
+ }
+
/** {@inheritDoc} */
public String getLocalName() {
return "simple-page-master";
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java Sun Feb 26 02:29:01 2012
@@ -35,6 +35,8 @@ public class CorrespondingPropertyMaker
protected int rltb;
/** corresponding property for tb-rl writing mode */
protected int tbrl;
+ /** corresponding property for tb-lr writing mode */
+ protected int tblr;
/** user parent property list */
protected boolean useParent;
private boolean relative;
@@ -48,17 +50,26 @@ public class CorrespondingPropertyMaker
baseMaker.setCorresponding(this);
}
+ /**
+ * Set corresponding property values.
+ * @param lrtb a corresponding value
+ * @param rltb a corresponding value
+ * @param tbrl a corresponding value
+ * @param tblr a corresponding value
+ */
/**
* Set corresponding property identifiers.
* @param lrtb the property that corresponds with lr-tb writing mode
* @param rltb the property that corresponds with rl-tb writing mode
* @param tbrl the property that corresponds with tb-lr writing mode
+ * @param tblr the property that corresponds with tb-lr writing mode
*/
- public void setCorresponding(int lrtb, int rltb, int tbrl) {
+ public void setCorresponding(int lrtb, int rltb, int tbrl, int tblr) {
this.lrtb = lrtb;
this.rltb = rltb;
this.tbrl = tbrl;
+ this.tblr = tblr;
}
/**
@@ -72,7 +83,7 @@ public class CorrespondingPropertyMaker
/**
* Set relative flag.
- * @param relative true if relative direction
+ * @param relative true if properties operate on a relative direction
*/
public void setRelative(boolean relative) {
this.relative = relative;
@@ -102,7 +113,7 @@ public class CorrespondingPropertyMaker
PropertyList pList = getWMPropertyList(propertyList);
if (pList != null) {
- int correspondingId = pList.getWritingMode(lrtb, rltb, tbrl);
+ int correspondingId = pList.selectFromWritingMode(lrtb, rltb, tbrl, tblr);
if (pList.getExplicit(correspondingId) != null) {
return true;
@@ -126,7 +137,7 @@ public class CorrespondingPropertyMaker
if (pList == null) {
return null;
}
- int correspondingId = pList.getWritingMode(lrtb, rltb, tbrl);
+ int correspondingId = pList.selectFromWritingMode(lrtb, rltb, tbrl, tblr);
Property p = propertyList.getExplicitOrShorthand(correspondingId);
if (p != null) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java Sun Feb 26 02:29:01 2012
@@ -34,7 +34,7 @@ public class DimensionPropertyMaker exte
private int[][] extraCorresponding = null;
/**
- * Construct a dimension property maker.
+ * Instantiate a dimension property maker.
* @param baseMaker the base property maker
*/
public DimensionPropertyMaker(PropertyMaker baseMaker) {
@@ -43,9 +43,18 @@ public class DimensionPropertyMaker exte
/**
* Set extra correspondences.
- * @param extraCorresponding the extra correspondences
+ * @param extraCorresponding an array of four element integer arrays
*/
public void setExtraCorresponding(int[][] extraCorresponding) {
+ if ( extraCorresponding == null ) {
+ throw new NullPointerException();
+ }
+ for ( int i = 0; i < extraCorresponding.length; i++ ) {
+ int[] eca = extraCorresponding[i];
+ if ( ( eca == null ) || ( eca.length != 4 ) ) {
+ throw new IllegalArgumentException ( "bad sub-array @ [" + i + "]" );
+ }
+ }
this.extraCorresponding = extraCorresponding;
}
@@ -76,18 +85,20 @@ public class DimensionPropertyMaker exte
}
// Based on min-[width|height]
- int wmcorr = propertyList.getWritingMode(extraCorresponding[0][0],
+ int wmcorr = propertyList.selectFromWritingMode(extraCorresponding[0][0],
extraCorresponding[0][1],
- extraCorresponding[0][2]);
+ extraCorresponding[0][2],
+ extraCorresponding[0][3]);
Property subprop = propertyList.getExplicitOrShorthand(wmcorr);
if (subprop != null) {
baseMaker.setSubprop(p, Constants.CP_MINIMUM, subprop);
}
// Based on max-[width|height]
- wmcorr = propertyList.getWritingMode(extraCorresponding[1][0],
+ wmcorr = propertyList.selectFromWritingMode(extraCorresponding[1][0],
extraCorresponding[1][1],
- extraCorresponding[1][2]);
+ extraCorresponding[1][2],
+ extraCorresponding[1][3]);
subprop = propertyList.getExplicitOrShorthand(wmcorr);
// TODO: Don't set when NONE.
if (subprop != null) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java Sun Feb 26 02:29:01 2012
@@ -55,6 +55,9 @@ public class IndentPropertyMaker extends
* @param paddingCorresponding the corresping propids.
*/
public void setPaddingCorresponding(int[] paddingCorresponding) {
+ if ( ( paddingCorresponding == null ) || ( paddingCorresponding.length != 4 ) ) {
+ throw new IllegalArgumentException();
+ }
this.paddingCorresponding = paddingCorresponding;
}
@@ -63,6 +66,9 @@ public class IndentPropertyMaker extends
* @param borderWidthCorresponding the corresping propids.
*/
public void setBorderWidthCorresponding(int[] borderWidthCorresponding) {
+ if ( ( borderWidthCorresponding == null ) || ( borderWidthCorresponding.length != 4 ) ) {
+ throw new IllegalArgumentException();
+ }
this.borderWidthCorresponding = borderWidthCorresponding;
}
@@ -99,7 +105,7 @@ public class IndentPropertyMaker extends
Numeric padding = getCorresponding(paddingCorresponding, propertyList).getNumeric();
Numeric border = getCorresponding(borderWidthCorresponding, propertyList).getNumeric();
- int marginProp = pList.getWritingMode(lrtb, rltb, tbrl);
+ int marginProp = pList.selectFromWritingMode(lrtb, rltb, tbrl, tblr);
// Calculate the absolute margin.
if (propertyList.getExplicitOrShorthand(marginProp) == null) {
Property indent = propertyList.getExplicit(baseMaker.propId);
@@ -158,7 +164,7 @@ public class IndentPropertyMaker extends
Numeric padding = getCorresponding(paddingCorresponding, propertyList).getNumeric();
Numeric border = getCorresponding(borderWidthCorresponding, propertyList).getNumeric();
- int marginProp = pList.getWritingMode(lrtb, rltb, tbrl);
+ int marginProp = pList.selectFromWritingMode(lrtb, rltb, tbrl, tblr);
//Determine whether the nearest anscestor indent was specified through
//start-indent|end-indent or through a margin property.
@@ -208,7 +214,8 @@ public class IndentPropertyMaker extends
throws PropertyException {
PropertyList pList = getWMPropertyList(propertyList);
if (pList != null) {
- int wmcorr = pList.getWritingMode(corresponding[0], corresponding[1], corresponding[2]);
+ int wmcorr = pList.selectFromWritingMode
+ ( corresponding[0], corresponding[1], corresponding[2], corresponding[3] );
return propertyList.get(wmcorr);
} else {
return null;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/BFEntry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/BFEntry.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/BFEntry.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/BFEntry.java Sun Feb 26 02:29:01 2012
@@ -68,9 +68,15 @@ public class BFEntry {
@Override
public String toString() {
StringBuilder sb = new StringBuilder("BFEntry: ");
- sb.append("Unicode ").append(getUnicodeStart()).append("..").append(getUnicodeEnd());
- sb.append(" --> ").append(getGlyphStartIndex()).append("..");
- sb.append(getGlyphStartIndex() + getUnicodeEnd() - getUnicodeStart());
+ sb.append ( "{ UC[" );
+ sb.append ( unicodeStart );
+ sb.append ( ',' );
+ sb.append ( unicodeEnd );
+ sb.append ( "]: GC[" );
+ sb.append ( glyphStartIndex );
+ sb.append ( ',' );
+ sb.append ( glyphStartIndex + ( unicodeEnd - unicodeStart ) );
+ sb.append ( "] }" );
return sb.toString();
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java Sun Feb 26 02:29:01 2012
@@ -60,6 +60,7 @@ public abstract class CustomFont extends
private Map<Integer, Map<Integer, Integer>> kerning;
private boolean useKerning = true;
+ private boolean useAdvanced = true;
/** {@inheritDoc} */
public String getFontName() {
@@ -285,6 +286,15 @@ public abstract class CustomFont extends
}
}
+ /**
+ * Used to determine if advanced typographic features are enabled.
+ * By default, this is false, but may be overridden by subclasses.
+ * @return true if enabled.
+ */
+ public boolean isAdvancedEnabled() {
+ return useAdvanced;
+ }
+
/* ---- MutableFont interface ---- */
/** {@inheritDoc} */
@@ -428,6 +438,13 @@ public abstract class CustomFont extends
}
/**
+ * {@inheritDoc}
+ */
+ public void setAdvancedEnabled(boolean enabled) {
+ this.useAdvanced = enabled;
+ }
+
+ /**
* Sets the font resolver. Needed for URI resolution.
* @param resolver the font resolver
*/
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFontCollection.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFontCollection.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFontCollection.java Sun Feb 26 02:29:01 2012
@@ -33,13 +33,14 @@ public class CustomFontCollection implem
* Main constructor.
* @param fontResolver a font resolver
* @param customFonts the list of custom fonts
+ * @param useComplexScriptFeatures true if complex script features enabled
*/
public CustomFontCollection(FontResolver fontResolver,
- List<EmbedFontInfo> customFonts) {
+ List<EmbedFontInfo> customFonts, boolean useComplexScriptFeatures) {
this.fontResolver = fontResolver;
if (this.fontResolver == null) {
//Ensure that we have minimal font resolution capabilities
- this.fontResolver = FontManager.createMinimalFontResolver();
+ this.fontResolver = FontManager.createMinimalFontResolver(useComplexScriptFeatures);
}
this.embedFontInfoList = customFonts;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java Sun Feb 26 02:29:01 2012
@@ -29,7 +29,7 @@ import java.util.List;
public class EmbedFontInfo implements Serializable {
/** Serialization Version UID */
- private static final long serialVersionUID = 8755432068669997368L;
+ private static final long serialVersionUID = 8755432068669997369L;
/** filename of the metrics file */
protected String metricsFile;
@@ -37,6 +37,8 @@ public class EmbedFontInfo implements Se
protected String embedFile;
/** false, to disable kerning */
protected boolean kerning;
+ /** false, to disable advanced typographic features */
+ protected boolean advanced;
/** the requested encoding mode for the font */
protected EncodingMode encodingMode = EncodingMode.AUTO;
@@ -52,17 +54,19 @@ public class EmbedFontInfo implements Se
/**
* Main constructor
- * @param metricsFile Path to the xml file containing font metrics
- * @param kerning True if kerning should be enabled
- * @param fontTriplets List of font triplets to associate with this font
- * @param embedFile Path to the embeddable font file (may be null)
+ * @param metricsFile path to the xml file containing font metrics
+ * @param kerning true if kerning should be enabled
+ * @param advanced true if advanced typography features should be enabled
+ * @param fontTriplets list of font triplets to associate with this font
+ * @param embedFile path to the embeddable font file (may be null)
* @param subFontName the sub-fontname used for TrueType Collections (null otherwise)
*/
- public EmbedFontInfo(String metricsFile, boolean kerning,
+ public EmbedFontInfo(String metricsFile, boolean kerning, boolean advanced,
List<FontTriplet> fontTriplets, String embedFile, String subFontName) {
this.metricsFile = metricsFile;
this.embedFile = embedFile;
this.kerning = kerning;
+ this.advanced = advanced;
this.fontTriplets = fontTriplets;
this.subFontName = subFontName;
}
@@ -85,13 +89,21 @@ public class EmbedFontInfo implements Se
/**
* Determines if kerning is enabled
- * @return True if enabled
+ * @return true if enabled
*/
public boolean getKerning() {
return kerning;
}
/**
+ * Determines if advanced typographic features are enabled
+ * @return true if enabled
+ */
+ public boolean getAdvanced() {
+ return advanced;
+ }
+
+ /**
* Returns the sub-font name of the font. This is primarily used for TrueType Collections
* to select one of the sub-fonts. For all other fonts, this is always null.
* @return the sub-font name (or null)
@@ -173,6 +185,7 @@ public class EmbedFontInfo implements Se
public String toString() {
return "metrics-url=" + metricsFile + ", embed-url=" + embedFile
+ ", kerning=" + kerning
+ + ", advanced=" + advanced
+ ", enc-mode=" + encodingMode
+ ", font-triplet=" + fontTriplets
+ (getSubFontName() != null ? ", sub-font=" + getSubFontName() : "")
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java Sun Feb 26 02:29:01 2012
@@ -25,11 +25,16 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.complexscripts.fonts.Positionable;
+import org.apache.fop.complexscripts.fonts.Substitutable;
+
+// CSOFF: LineLengthCheck
+
/**
* This class holds font state information and provides access to the font
* metrics.
*/
-public class Font {
+public class Font implements Substitutable, Positionable {
/** Extra Bold font weight */
public static final int WEIGHT_EXTRA_BOLD = 800;
@@ -189,6 +194,30 @@ public class Font {
}
/**
+ * Returns the amount of kerning between two characters.
+ *
+ * The value returned measures in pt. So it is already adjusted for font size.
+ *
+ * @param ch1 first character
+ * @param ch2 second character
+ * @return the distance to adjust for kerning, 0 if there's no kerning
+ */
+ public int getKernValue(int ch1, int ch2) {
+ // TODO !BMP
+ if ( ch1 > 0x10000 ) {
+ return 0;
+ } else if ( ( ch1 >= 0xD800 ) && ( ch1 <= 0xE000 ) ) {
+ return 0;
+ } else if ( ch2 > 0x10000 ) {
+ return 0;
+ } else if ( ( ch2 >= 0xD800 ) && ( ch2 <= 0xE000 ) ) {
+ return 0;
+ } else {
+ return getKernValue ( (char) ch1, (char) ch2 );
+ }
+ }
+
+ /**
* Returns the width of a character
* @param charnum character to look up
* @return width of the character
@@ -241,8 +270,8 @@ public class Font {
*/
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer();
- sbuf.append('(');
+ StringBuffer sbuf = new StringBuffer(super.toString());
+ sbuf.append('{');
/*
sbuf.append(fontFamily);
sbuf.append(',');*/
@@ -254,7 +283,7 @@ public class Font {
sbuf.append(fontStyle);
sbuf.append(',');
sbuf.append(fontWeight);*/
- sbuf.append(')');
+ sbuf.append('}');
return sbuf.toString();
}
@@ -264,7 +293,7 @@ public class Font {
* This also performs some guessing on widths on various
* versions of space that might not exists in the font.
* @param c character to inspect
- * @return the width of the character
+ * @return the width of the character or -1 if no width available
*/
public int getCharWidth(char c) {
int width;
@@ -329,6 +358,23 @@ public class Font {
}
/**
+ * Helper method for getting the width of a unicode char
+ * from the current fontstate.
+ * This also performs some guessing on widths on various
+ * versions of space that might not exists in the font.
+ * @param c character to inspect
+ * @return the width of the character or -1 if no width available
+ */
+ public int getCharWidth(int c) {
+ if ( c < 0x10000 ) {
+ return getCharWidth ( (char) c );
+ } else {
+ // TODO !BMP
+ return -1;
+ }
+ }
+
+ /**
* Calculates the word width.
* @param word text to get width for
* @return the width of the text
@@ -347,6 +393,59 @@ public class Font {
return width;
}
-}
+ /** {@inheritDoc} */
+ public boolean performsSubstitution() {
+ if ( metric instanceof Substitutable ) {
+ Substitutable s = (Substitutable) metric;
+ return s.performsSubstitution();
+ } else {
+ return false;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public CharSequence performSubstitution ( CharSequence cs, String script, String language ) {
+ if ( metric instanceof Substitutable ) {
+ Substitutable s = (Substitutable) metric;
+ return s.performSubstitution ( cs, script, language );
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /** {@inheritDoc} */
+ public CharSequence reorderCombiningMarks ( CharSequence cs, int[][] gpa, String script, String language ) {
+ if ( metric instanceof Substitutable ) {
+ Substitutable s = (Substitutable) metric;
+ return s.reorderCombiningMarks ( cs, gpa, script, language );
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ /** {@inheritDoc} */
+ public boolean performsPositioning() {
+ if ( metric instanceof Positionable ) {
+ Positionable p = (Positionable) metric;
+ return p.performsPositioning();
+ } else {
+ return false;
+ }
+ }
+ /** {@inheritDoc} */
+ public int[][] performPositioning ( CharSequence cs, String script, String language, int fontSize ) {
+ if ( metric instanceof Positionable ) {
+ Positionable p = (Positionable) metric;
+ return p.performPositioning ( cs, script, language, fontSize );
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /** {@inheritDoc} */
+ public int[][] performPositioning ( CharSequence cs, String script, String language ) {
+ return performPositioning ( cs, script, language, fontSize );
+ }
+
+}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfoConfigurator.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfoConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfoConfigurator.java Sun Feb 26 02:29:01 2012
@@ -253,20 +253,26 @@ public class FontInfoConfigurator {
}
boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
+ boolean useAdvanced = fontCfg.getAttributeAsBoolean("advanced", true);
EncodingMode encodingMode = EncodingMode.getEncodingMode(
fontCfg.getAttribute("encoding-mode", EncodingMode.AUTO.getName()));
EmbedFontInfo embedFontInfo
- = new EmbedFontInfo(metricsUrl, useKerning, tripletList, embedUrl, subFont);
+ = new EmbedFontInfo(metricsUrl, useKerning, useAdvanced, tripletList, embedUrl,
+ subFont);
embedFontInfo.setEncodingMode(encodingMode);
+ boolean skipCachedFont = false;
if (fontCache != null) {
if (!fontCache.containsFont(embedFontInfo)) {
fontCache.addFont(embedFontInfo);
+ } else {
+ skipCachedFont = true;
}
}
if (log.isDebugEnabled()) {
String embedFile = embedFontInfo.getEmbedFile();
- log.debug("Adding font " + (embedFile != null ? embedFile + ", " : "")
+ log.debug( ( skipCachedFont ? "Skipping (cached) font " : "Adding font " )
+ + (embedFile != null ? embedFile + ", " : "")
+ "metric file " + embedFontInfo.getMetricsFile());
for (int j = 0; j < tripletList.size(); ++j) {
FontTriplet triplet = tripletList.get(j);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java Sun Feb 26 02:29:01 2012
@@ -43,31 +43,36 @@ public abstract class FontLoader {
protected static final Log log = LogFactory.getLog(FontLoader.class);
/** URI representing the font file */
- protected String fontFileURI = null;
+ protected String fontFileURI;
/** the FontResolver to use for font URI resolution */
- protected FontResolver resolver = null;
+ protected FontResolver resolver;
/** the loaded font */
- protected CustomFont returnFont = null;
+ protected CustomFont returnFont;
/** true if the font has been loaded */
- protected boolean loaded = false;
+ protected boolean loaded;
/** true if the font will be embedded, false if it will be referenced only. */
- protected boolean embedded = true;
- /** true if kerning information shall be loaded if available. */
- protected boolean useKerning = true;
+ protected boolean embedded;
+ /** true if kerning information false be loaded if available. */
+ protected boolean useKerning;
+ /** true if advanced typographic information shall be loaded if available. */
+ protected boolean useAdvanced;
/**
* Default constructor.
* @param fontFileURI the URI to the PFB file of a Type 1 font
* @param embedded indicates whether the font is embedded or referenced
* @param useKerning indicates whether kerning information shall be loaded if available
+ * @param useAdvanced indicates whether advanced typographic information shall be loaded if
+ * available
* @param resolver the font resolver used to resolve URIs
*/
public FontLoader(String fontFileURI, boolean embedded, boolean useKerning,
- FontResolver resolver) {
+ boolean useAdvanced, FontResolver resolver) {
this.fontFileURI = fontFileURI;
this.embedded = embedded;
this.useKerning = useKerning;
+ this.useAdvanced = useAdvanced;
this.resolver = resolver;
}
@@ -105,7 +110,7 @@ public abstract class FontLoader {
boolean embedded, EncodingMode encodingMode,
FontResolver resolver) throws IOException {
return loadFont(fontUrl.toExternalForm(), subFontName,
- embedded, encodingMode, true,
+ embedded, encodingMode, true, true,
resolver);
}
@@ -116,13 +121,15 @@ public abstract class FontLoader {
* @param embedded indicates whether the font is embedded or referenced
* @param encodingMode the requested encoding mode
* @param useKerning indicates whether kerning information should be loaded if available
+ * @param useAdvanced indicates whether advanced typographic information shall be loaded if
+ * available
* @param resolver the font resolver to use when resolving URIs
* @return the newly loaded font
* @throws IOException In case of an I/O error
*/
public static CustomFont loadFont(String fontFileURI, String subFontName,
boolean embedded, EncodingMode encodingMode, boolean useKerning,
- FontResolver resolver) throws IOException {
+ boolean useAdvanced, FontResolver resolver) throws IOException {
fontFileURI = fontFileURI.trim();
boolean type1 = isType1(fontFileURI);
FontLoader loader;
@@ -134,7 +141,7 @@ public abstract class FontLoader {
loader = new Type1FontLoader(fontFileURI, embedded, useKerning, resolver);
} else {
loader = new TTFFontLoader(fontFileURI, subFontName,
- embedded, encodingMode, useKerning, resolver);
+ embedded, encodingMode, useKerning, useAdvanced, resolver);
}
return loader.getFont();
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontManager.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontManager.java Sun Feb 26 02:29:01 2012
@@ -224,16 +224,32 @@ public class FontManager {
getFontSubstitutions().adjustFontInfo(fontInfo);
}
- /** @return a new FontResolver to be used by the font subsystem */
- public static FontResolver createMinimalFontResolver() {
- return new FontResolver() {
-
- /** {@inheritDoc} */
- public Source resolve(String href) {
- //Minimal functionality here
- return new StreamSource(href);
- }
- };
+ /**
+ * Minimum implemenation of FontResolver.
+ */
+ public static class MinimalFontResolver implements FontResolver {
+ private boolean useComplexScriptFeatures;
+ MinimalFontResolver(boolean useComplexScriptFeatures) {
+ this.useComplexScriptFeatures = useComplexScriptFeatures;
+ }
+ /** {@inheritDoc} */
+ public Source resolve(String href) {
+ //Minimal functionality here
+ return new StreamSource(href);
+ }
+ /** {@inheritDoc} */
+ public boolean isComplexScriptFeaturesEnabled() {
+ return useComplexScriptFeatures;
+ }
+ }
+
+ /**
+ * Create minimal font resolver.
+ * @param useComplexScriptFeatures true if complex script features enabled
+ * @return a new FontResolver to be used by the font subsystem
+ */
+ public static FontResolver createMinimalFontResolver(boolean useComplexScriptFeatures) {
+ return new MinimalFontResolver ( useComplexScriptFeatures );
}
/**
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontManagerConfigurator.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontManagerConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontManagerConfigurator.java Sun Feb 26 02:29:01 2012
@@ -98,6 +98,18 @@ public class FontManagerConfigurator {
}
}
+ // [GA] permit configuration control over base14 kerning; without this,
+ // there is no way for a user to enable base14 kerning other than by
+ // programmatic API;
+ if (cfg.getChild("base14-kerning", false) != null) {
+ try {
+ fontManager
+ .setBase14KerningEnabled(cfg.getChild("base14-kerning").getValueAsBoolean());
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e, true);
+ }
+ }
+
// global font configuration
Configuration fontsCfg = cfg.getChild("fonts", false);
if (fontsCfg != null) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontReader.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontReader.java Sun Feb 26 02:29:01 2012
@@ -34,6 +34,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
@@ -52,7 +53,7 @@ import org.apache.fop.fonts.apps.TTFRead
*/
public class FontReader extends DefaultHandler {
- private Locator locator = null;
+ // private Locator locator = null; // not used at present
private boolean isCID = false;
private CustomFont returnFont = null;
private MultiByteFont multiFont = null;
@@ -117,6 +118,14 @@ public class FontReader extends DefaultH
}
/**
+ * Enable/disable use of advanced typographic features for the font
+ * @param enabled true to enable, false to disable
+ */
+ public void setAdvancedEnabled(boolean enabled) {
+ returnFont.setAdvancedEnabled(enabled);
+ }
+
+ /**
* Sets the font resolver. Needed for URI resolution.
* @param resolver the font resolver
*/
@@ -153,7 +162,7 @@ public class FontReader extends DefaultH
* {@inheritDoc}
*/
public void setDocumentLocator(Locator locator) {
- this.locator = locator;
+ // this.locator = locator; // not used at present
}
/**
@@ -212,6 +221,7 @@ public class FontReader extends DefaultH
currentKerning.put(new Integer(attributes.getValue("kpx2")),
new Integer(attributes.getValue("kern")));
}
+
}
private int getInt(String str) throws SAXException {
@@ -305,6 +315,5 @@ public class FontReader extends DefaultH
public void characters(char[] ch, int start, int length) {
text.append(ch, start, length);
}
-}
-
+}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontResolver.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontResolver.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontResolver.java Sun Feb 26 02:29:01 2012
@@ -36,4 +36,10 @@ public interface FontResolver {
*/
Source resolve(String href);
+ /**
+ * Check whether complex script features are enabled.
+ * @return true if FOP is to use complex script features
+ */
+ boolean isComplexScriptFeaturesEnabled();
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontSetup.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontSetup.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontSetup.java Sun Feb 26 02:29:01 2012
@@ -57,9 +57,10 @@ public final class FontSetup {
/**
* Sets up a font info
* @param fontInfo font info
+ * @param base14Kerning true if base14 kerning applies
*/
- public static void setup(FontInfo fontInfo) {
- setup(fontInfo, null, null);
+ public static void setup(FontInfo fontInfo, boolean base14Kerning) {
+ setup(fontInfo, null, null, base14Kerning);
}
/**
@@ -71,10 +72,10 @@ public final class FontSetup {
* @param fontInfo the font info object to set up
* @param embedFontInfoList a list of EmbedFontInfo objects
* @param resolver the font resolver
+ * @param base14Kerning true if base14 kerning applies
*/
public static void setup(FontInfo fontInfo, List<EmbedFontInfo> embedFontInfoList,
- FontResolver resolver) {
- final boolean base14Kerning = false;
+ FontResolver resolver, boolean base14Kerning) {
fontInfo.addMetrics("F1", new Helvetica(base14Kerning));
fontInfo.addMetrics("F2", new HelveticaOblique(base14Kerning));
fontInfo.addMetrics("F3", new HelveticaBold(base14Kerning));
@@ -180,7 +181,7 @@ public final class FontSetup {
final int startNum = 15;
/* Add configured fonts */
- addConfiguredFonts(fontInfo, embedFontInfoList, startNum, resolver);
+ addConfiguredFonts(fontInfo, embedFontInfoList, startNum, resolver, base14Kerning);
}
/**
@@ -191,14 +192,17 @@ public final class FontSetup {
* @param resolver the font resolver
*/
private static void addConfiguredFonts(FontInfo fontInfo,
- List<EmbedFontInfo> embedFontInfoList, int num, FontResolver resolver) {
+ List<EmbedFontInfo> embedFontInfoList, int num, FontResolver resolver,
+ boolean base14Kerning) {
if (embedFontInfoList == null) {
return; //No fonts to process
}
if (resolver == null) {
//Ensure that we have minimal font resolution capabilities
- resolver = createMinimalFontResolver();
+ //None of the built-in base14 fonts have advanced typographic data
+ boolean useAdvanced = false;
+ resolver = createMinimalFontResolver(useAdvanced);
}
String internalName = null;
@@ -218,15 +222,31 @@ public final class FontSetup {
}
}
- /** @return a new FontResolver to be used by the font subsystem */
- public static FontResolver createMinimalFontResolver() {
- return new FontResolver() {
-
- /** {@inheritDoc} */
- public Source resolve(String href) {
- //Minimal functionality here
- return new StreamSource(href);
- }
- };
+ /**
+ * Minimum implemenation of FontResolver.
+ */
+ public static class MinimalFontResolver implements FontResolver {
+ private boolean useComplexScriptFeatures;
+ MinimalFontResolver(boolean useComplexScriptFeatures) {
+ this.useComplexScriptFeatures = useComplexScriptFeatures;
+ }
+ /** {@inheritDoc} */
+ public Source resolve(String href) {
+ //Minimal functionality here
+ return new StreamSource(href);
+ }
+ /** {@inheritDoc} */
+ public boolean isComplexScriptFeaturesEnabled() {
+ return useComplexScriptFeatures;
+ }
+ }
+
+ /**
+ * Create minimal font resolver.
+ * @param useComplexScriptFeatures true if complex script features enabled
+ * @return a new FontResolver to be used by the font subsystem
+ */
+ public static FontResolver createMinimalFontResolver(boolean useComplexScriptFeatures) {
+ return new MinimalFontResolver ( useComplexScriptFeatures );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org