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 sp...@apache.org on 2008/02/14 22:57:53 UTC
svn commit: r627882 [6/41] - in
/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking: ./
examples/embedding/ examples/embedding/java/embedding/
examples/embedding/java/embedding/intermediate/ examples/embedding/xml/xml/
examples/fo/ examples/f...
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/ColorProfile.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Declarations.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Flow.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequenceWrapper.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Root.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Root.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Root.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Root.java Thu Feb 14 13:55:44 2008
@@ -31,8 +31,8 @@
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.pagination.bookmarks.BookmarkTree;
import org.apache.fop.fo.extensions.destination.Destination;
+import org.apache.fop.fo.pagination.bookmarks.BookmarkTree;
/**
* The fo:root formatting object. Contains page masters, page-sequences.
@@ -73,20 +73,16 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
mediaUsage = pList.get(PR_MEDIA_USAGE).getEnum();
}
- /**
- * Signal end of this xml element.
- */
+ /** {@inheritDoc} */
protected void endOfNode() throws FOPException {
if (!pageSequenceFound || layoutMasterSet == null) {
- missingChildElementError("(layout-master-set, declarations?, " +
- "bookmark-tree?, (page-sequence+|fox:external-document))");
+ missingChildElementError("(layout-master-set, declarations?, "
+ + "bookmark-tree?, (page-sequence|fox:external-document)+)");
}
}
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/SideRegion.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/StaticContent.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Title.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/BorderSpacingShorthandParser.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java Thu Feb 14 13:55:44 2008
@@ -63,7 +63,7 @@
// Calculate the values as described in 7.7.20.
Property style = propertyList.get(borderStyleId);
if (style.getEnum() == Constants.EN_NONE) {
- return new FixedLength(0);
+ return FixedLength.ZERO_FIXED_LENGTH;
}
return p;
}
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/BoxPropShorthandParser.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CharacterProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/ColorProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/ColorProperty.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/ColorProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/ColorProperty.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Id: ColorTypeProperty.java 377045 2006-02-11 20:23:47Z jeremias $ */
+/* $Id$ */
package org.apache.fop.fo.properties;
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/ColorProperty.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonAbsolutePosition.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonAccessibility.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonAural.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java Thu Feb 14 13:55:44 2008
@@ -21,14 +21,17 @@
import java.awt.Color;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.datatypes.Length;
import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.datatypes.URISpecification;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
-import org.apache.fop.image.FopImage;
-import org.apache.fop.image.ImageFactory;
/**
* Stores all common border and padding properties.
@@ -66,7 +69,7 @@
public Length backgroundPositionVertical;
- private FopImage fopimage;
+ private ImageInfo backgroundImageInfo;
/** the "before" edge */
@@ -232,18 +235,16 @@
Constants.PR_BACKGROUND_POSITION_VERTICAL).getLength();
//Additional processing: preload image
- String url = ImageFactory.getURL(backgroundImage);
+ String uri = URISpecification.getURL(backgroundImage);
FOUserAgent userAgent = pList.getFObj().getUserAgent();
- ImageFactory fact = userAgent.getFactory().getImageFactory();
- fopimage = fact.getImage(url, userAgent);
- if (fopimage == null) {
- Property.log.error("Background image not available: " + backgroundImage);
- } else {
- // load dimensions
- if (!fopimage.load(FopImage.DIMENSIONS)) {
- Property.log.error("Cannot read background image dimensions: "
- + backgroundImage);
- }
+ ImageManager manager = userAgent.getFactory().getImageManager();
+ ImageSessionContext sessionContext = userAgent.getImageSessionContext();
+ ImageInfo info;
+ try {
+ info = manager.getImageInfo(uri, sessionContext);
+ this.backgroundImageInfo = info;
+ } catch (Exception e) {
+ Property.log.error("Background image not available: " + uri);
}
//TODO Report to caller so he can decide to throw an exception
}
@@ -315,11 +316,11 @@
}
/**
- * @return the background image as a preloaded FopImage, null if there is
+ * @return the background image info object, null if there is
* no background image.
*/
- public FopImage getFopImage() {
- return this.fopimage;
+ public ImageInfo getImageInfo() {
+ return this.backgroundImageInfo;
}
/**
@@ -455,7 +456,7 @@
* @return true if there is any kind of background to be painted
*/
public boolean hasBackground() {
- return ((backgroundColor != null || getFopImage() != null));
+ return ((backgroundColor != null || getImageInfo() != null));
}
/** @return true if border is non-zero. */
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonFont.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonHyphenation.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonMarginInline.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CondLengthProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/EnumLength.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/EnumNumber.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/EnumProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/FixedLength.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/FixedLength.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/FixedLength.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/FixedLength.java Thu Feb 14 13:55:44 2008
@@ -26,24 +26,71 @@
*/
public final class FixedLength extends LengthProperty {
+ /** Describes the unit pica. */
+ public static final String PICA = "pc";
+
+ /** Describes the unit point. */
+ public static final String POINT = "pt";
+
+ /** Describes the unit millimeter. */
+ public static final String MM = "mm";
+
+ /** Describes the unit centimeter. */
+ public static final String CM = "cm";
+
+ /** Describes the unit inch. */
+ public static final String INCH = "in";
+
+ /** Describes the unit millipoint. */
+ public static final String MPT = "mpt";
+
/** cache holding all canonical FixedLength instances */
private static final PropertyCache cache = new PropertyCache();
+ /** canonical zero-length instance */
+ public static final FixedLength ZERO_FIXED_LENGTH = new FixedLength(0, FixedLength.MPT, 1.0f);
+
private int millipoints;
/**
- * Set the length given a number of units and a unit name.
+ * Set the length given a number of units, a unit name and
+ * an assumed resolution (used in case the units are pixels)
*
- * @param numUnits quantity of input units
- * @param units input unit specifier (in, cm, etc.)
+ * @param numUnits quantity of input units
+ * @param units input unit specifier
+ * @param res input/source resolution
+ */
+ private FixedLength(double numUnits, String units, float res) {
+ this.millipoints = convert(numUnits, units, res);
+ }
+
+ /**
+ * Return the cached {@link FixedLength} instance corresponding
+ * to the computed value in base-units (millipoints).
+ *
+ * @param numUnits quantity of input units
+ * @param units input unit specifier
+ * @param sourceResolution input/source resolution (= ratio of pixels per pt)
+ * @return the canonical FixedLength instance corresponding
+ * to the given number of units and unit specifier
+ * in the given resolution
*/
- private FixedLength(double numUnits, String units) {
- convert(numUnits, units);
+ public static FixedLength getInstance(double numUnits,
+ String units,
+ float sourceResolution) {
+ if (numUnits == 0.0) {
+ return ZERO_FIXED_LENGTH;
+ } else {
+ return (FixedLength)cache.fetch(
+ new FixedLength(numUnits, units, sourceResolution));
+ }
+
}
/**
- * Return the cached FixedLength instance corresponding
+ * Return the cached {@link FixedLength} instance corresponding
* to the computed value
+ * This method assumes a source-resolution of 1 (1px = 1pt)
*
* @param numUnits input units
* @param units unit specifier
@@ -52,118 +99,103 @@
*/
public static FixedLength getInstance(double numUnits,
String units) {
- return (FixedLength) cache.fetch(new FixedLength(numUnits, units));
+ return getInstance(numUnits, units, 1.0f);
}
/**
- * @param baseUnits the length as a number of base units (millipoints)
+ * Return the cached {@link FixedLength} instance corresponding
+ * to the computed value.
+ * This method assumes 'millipoints' (non-standard) as units,
+ * and an implied source-resolution of 1 (1px = 1pt).
+ *
+ * @param numUnits input units
+ * @return the canonical FixedLength instance corresponding
+ * to the given number of units and unit specifier
*/
- public FixedLength(int baseUnits) {
- millipoints = baseUnits;
+ public static FixedLength getInstance(double numUnits) {
+ return getInstance(numUnits, FixedLength.MPT, 1.0f);
+
}
-
+
/**
* Convert the given length to a dimensionless integer representing
* a whole number of base units (milli-points).
+ *
* @param dvalue quantity of input units
* @param unit input unit specifier (in, cm, etc.)
+ * @param res the input/source resolution (in case the unit spec is "px")
*/
- protected void convert(double dvalue, String unit) {
- // TODO: the whole routine smells fishy.
+ private static int convert(double dvalue, String unit, float res) {
+ // TODO: Maybe this method has a better place in org.apache.fop.util.UnitConv?.
- int assumedResolution = 1; // points/pixel = 72dpi
-
- if (unit.equals("in")) {
- dvalue = dvalue * 72;
- } else if (unit.equals("cm")) {
- dvalue = dvalue * 28.3464567;
- } else if (unit.equals("mm")) {
- dvalue = dvalue * 2.83464567;
- } else if (unit.equals("pt")) {
- // Do nothing.
- // dvalue = dvalue;
- } else if (unit.equals("mpt")) { //mpt is non-standard!!! mpt=millipoints
- // TODO: this seems to be wrong.
- // Do nothing.
- // dvalue = dvalue;
- } else if (unit.equals("pc")) {
- dvalue = dvalue * 12;
- /*
- * } else if (unit.equals("em")) {
- * dvalue = dvalue * fontsize;
- */
- } else if (unit.equals("px")) {
- // TODO: get resolution from user agent?
- dvalue = dvalue * assumedResolution;
- } else {
- dvalue = 0;
- log.error("Unknown length unit '" + unit + "'");
- }
- if (unit.equals("mpt")) {
- millipoints = (int)dvalue;
+ if ("px".equals(unit)) {
+ //device-dependent units, take the resolution into account
+ dvalue *= (res * 1000);
} else {
- millipoints = (int)(dvalue * 1000);
+ if (FixedLength.INCH.equals(unit)) {
+ dvalue *= 72000;
+ } else if (FixedLength.CM.equals(unit)) {
+ dvalue *= 28346.4567;
+ } else if (FixedLength.MM.equals(unit)) {
+ dvalue *= 2834.64567;
+ } else if (FixedLength.POINT.equals(unit)) {
+ dvalue *= 1000;
+ } else if (FixedLength.PICA.equals(unit)) {
+ dvalue *= 12000;
+ } else if (!FixedLength.MPT.equals(unit)) {
+ dvalue = 0;
+ log.error("Unknown length unit '" + unit + "'");
+ }
}
+ return (int)dvalue;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getValue() {
return millipoints;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getValue(PercentBaseContext context) {
return millipoints;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public double getNumericValue() {
return millipoints;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public double getNumericValue(PercentBaseContext context) {
return millipoints;
}
/**
- * Return true since FixedLength are always absolute.
+ * Return true since a FixedLength is always absolute.
* {@inheritDoc}
*/
public boolean isAbsolute() {
return true;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String toString() {
- return millipoints + "mpt";
+ return millipoints + FixedLength.MPT;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
if (obj instanceof FixedLength) {
return (((FixedLength)obj).millipoints == this.millipoints);
- } else {
- return false;
}
+ return false;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int hashCode() {
return millipoints;
}
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/FixedLength.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java Thu Feb 14 13:55:44 2008
@@ -43,6 +43,24 @@
super(propId);
}
+
+ /**
+ * {@inheritDoc}
+ * Contrary to basic lengths, percentages for font-size can be resolved
+ * here already: if the property evaluates to a {@link PercentLength},
+ * it is immediately replaced by the resolved {@link FixedLength}.
+ */
+ public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException {
+ Property p = super.make(propertyList, value, fo);
+ if (p instanceof PercentLength) {
+ Property pp = propertyList.getFromParent(this.propId);
+ p = FixedLength.getInstance(
+ pp.getLength().getValue() * ((PercentLength)p).getPercentage() / 100);
+ }
+ return p;
+ }
+
+
/**
* {@inheritDoc}
* Implements the parts of 7.8.4 relevant to relative font sizes
@@ -52,12 +70,14 @@
FObj fo) throws PropertyException {
if (p.getEnum() == EN_LARGER || p.getEnum() == EN_SMALLER) {
// get the corresponding property from parent
- Property pp = propertyList.getFromParent(this.getPropId());
+ Property pp = propertyList.getFromParent(this.propId);
int baseFontSize = computeClosestAbsoluteFontSize(pp.getLength().getValue());
if (p.getEnum() == EN_LARGER) {
- return new FixedLength((int)Math.round((baseFontSize * FONT_SIZE_GROWTH_FACTOR)));
+ return FixedLength.getInstance(
+ Math.round(baseFontSize * FONT_SIZE_GROWTH_FACTOR));
} else {
- return new FixedLength((int)Math.round((baseFontSize / FONT_SIZE_GROWTH_FACTOR)));
+ return FixedLength.getInstance(
+ Math.round(baseFontSize / FONT_SIZE_GROWTH_FACTOR));
}
}
return super.convertProperty(p, propertyList, fo);
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/GenericShorthandParser.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java Thu Feb 14 13:55:44 2008
@@ -108,7 +108,7 @@
//Margin is used
Numeric margin = propertyList.get(marginProp).getNumeric();
- Numeric v = new FixedLength(0);
+ Numeric v = FixedLength.ZERO_FIXED_LENGTH;
if (!propertyList.getFObj().generatesReferenceAreas()) {
// The inherited_value_of([start|end]-indent)
v = NumericOp.addition(v, propertyList.getInherited(baseMaker.propId).getNumeric());
@@ -173,7 +173,7 @@
if (isInherited(propertyList) || !marginNearest) {
return null;
} else {
- return new FixedLength(0);
+ return FixedLength.ZERO_FIXED_LENGTH;
}
} else {
return indent;
@@ -182,7 +182,7 @@
//Margin is used
Numeric margin = propertyList.get(marginProp).getNumeric();
- Numeric v = new FixedLength(0);
+ Numeric v = FixedLength.ZERO_FIXED_LENGTH;
if (isInherited(propertyList)) {
// The inherited_value_of([start|end]-indent)
v = NumericOp.addition(v, propertyList.getInherited(baseMaker.propId).getNumeric());
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/KeepProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthPairProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthProperty.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthProperty.java Thu Feb 14 13:55:44 2008
@@ -45,9 +45,7 @@
super(propId);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Property convertProperty(Property p,
PropertyList propertyList,
FObj fo) throws PropertyException {
@@ -59,7 +57,9 @@
}
if (p instanceof NumberProperty) {
//Assume pixels (like in HTML) when there's no unit
- return FixedLength.getInstance(p.getNumeric().getNumericValue(), "px");
+ return FixedLength.getInstance(
+ p.getNumeric().getNumericValue(), "px",
+ propertyList.getFObj().getUserAgent().getSourceResolution() / 72.0f);
}
Length val = p.getLength();
if (val != null) {
@@ -87,30 +87,22 @@
return 0.0;
}
- /**
- * @return the numeric dimension. Length always a dimension of 1.
- */
+ /** @return the numeric dimension. Length always a dimension of 1 */
public int getDimension() {
return 1;
}
- /**
- * @return this.length cast as a Numeric
- */
+ /** @return this.length cast as a Numeric */
public Numeric getNumeric() {
return this;
}
- /**
- * @return this.length
- */
+ /** @return this.length */
public Length getLength() {
return this;
}
- /**
- * @return this.length cast as an Object
- */
+ /** @return this.length cast as an Object */
public Object getObject() {
return this;
}
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java Thu Feb 14 13:55:44 2008
@@ -65,9 +65,7 @@
|| (len.isAbsolute() && len.getValue() < 0));
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Property convertProperty(Property p,
PropertyList propertyList, FObj fo)
throws PropertyException {
@@ -84,7 +82,7 @@
log.warn(FObj.decorateWithContextInfo(
"Replaced negative value (" + len + ") for " + getName()
+ " with 0mpt", fo));
- p = new FixedLength(0);
+ p = FixedLength.ZERO_FIXED_LENGTH;
}
}
}
@@ -107,7 +105,7 @@
log.warn("Replaced negative value (" + len + ") for " + getName()
+ " with 0mpt");
val.setComponent(subpropertyId,
- new FixedLength(0), false);
+ FixedLength.ZERO_FIXED_LENGTH, false);
return baseProperty;
}
}
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java Thu Feb 14 13:55:44 2008
@@ -19,6 +19,8 @@
package org.apache.fop.fo.properties;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.LengthBase;
import org.apache.fop.datatypes.Numeric;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
@@ -85,7 +87,16 @@
FObj fo) throws PropertyException {
Numeric numval = p.getNumeric();
if (numval != null && numval.getDimension() == 0) {
- p = new PercentLength(numval.getNumericValue(), getPercentBase(propertyList));
+ if (getPercentBase(propertyList) instanceof LengthBase) {
+ Length base = ((LengthBase)getPercentBase(propertyList)).getBaseLength();
+ if (base != null && base.isAbsolute()) {
+ p = FixedLength.getInstance(
+ numval.getNumericValue() * base.getNumericValue());
+ } else {
+ p = new PercentLength(
+ numval.getNumericValue(), getPercentBase(propertyList));
+ }
+ }
Property spaceProp = super.convertProperty(p, propertyList, fo);
spaceProp.setSpecifiedValue(String.valueOf(numval.getNumericValue()));
return spaceProp;
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/ListProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/NumberProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/NumberProperty.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/NumberProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/NumberProperty.java Thu Feb 14 13:55:44 2008
@@ -61,7 +61,7 @@
}
Number val = p.getNumber();
if (val != null) {
- return new NumberProperty(val);
+ return getInstance(val.doubleValue());
}
return convertPropertyDatatype(p, propertyList, fo);
}
@@ -74,40 +74,53 @@
private final Number number;
/**
- * Constructor for Number input
- * @param num Number object value for property
- */
- private NumberProperty(Number num) {
- this.number = num;
- }
-
- /**
* Constructor for double input
* @param num double numeric value for property
*/
- protected NumberProperty(double num) {
- this.number = new Double(num);
+ private NumberProperty(double num) {
+ //Store the number as an int or a long,
+ //if possible
+ if (num == Math.floor(num)) {
+ if (num < Integer.MAX_VALUE) {
+ this.number = new Integer((int)num);
+ } else {
+ this.number = new Long((long)num);
+ }
+ } else {
+ this.number = new Double(num);
+ }
}
/**
* Constructor for integer input
* @param num integer numeric value for property
*/
- protected NumberProperty(int num) {
+ private NumberProperty(int num) {
this.number = new Integer(num);
}
/**
* Returns the canonical NumberProperty instance
* corresponding to the given Number
- * @param num the base Number
+ * @param num the base Double
* @return the canonical NumberProperty
*/
- public static NumberProperty getInstance(Number num) {
+ public static NumberProperty getInstance(Double num) {
return (NumberProperty)cache.fetch(
- new NumberProperty(num));
+ new NumberProperty(num.doubleValue()));
}
+ /**
+ * Returns the canonical NumberProperty instance
+ * corresponding to the given Integer
+ * @param num the base Integer
+ * @return the canonical NumberProperty
+ */
+ public static NumberProperty getInstance(Integer num) {
+ return (NumberProperty)cache.fetch(
+ new NumberProperty(num.intValue()));
+ }
+
/**
* Returns the canonical NumberProperty instance
* corresponding to the given double
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/NumberProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PercentLength.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PercentLength.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PercentLength.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PercentLength.java Thu Feb 14 13:55:44 2008
@@ -80,16 +80,12 @@
return false;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public double getNumericValue() {
return getNumericValue(null);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public double getNumericValue(PercentBaseContext context) {
try {
resolvedValue = factor * lbase.getBaseLength(context);
@@ -99,6 +95,11 @@
return 0;
}
}
+
+ /** {@inheritDoc} */
+ public String getString() {
+ return (factor * 100.0) + "%";
+ }
/**
* Return the length of this PercentLength.
@@ -108,9 +109,7 @@
return (int) getNumericValue();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getValue(PercentBaseContext context) {
return (int) getNumericValue(context);
}
@@ -119,8 +118,11 @@
* @return the String equivalent of this
*/
public String toString() {
- // TODO: What about the base value?
- return (new Double(factor * 100.0).toString()) + "%";
+ StringBuffer sb =
+ new StringBuffer(PercentLength.class.getName())
+ .append("[factor=").append(factor)
+ .append(",lbase=").append(lbase).append("]");
+ return sb.toString();
}
}
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PercentLength.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PositionShorthandParser.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/Property.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PropertyMaker.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PropertyMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PropertyMaker.java Thu Feb 14 13:55:44 2008
@@ -427,8 +427,8 @@
}
}
} else {
- // Check for keyword shorthand values to be substituted.
- pvalue = checkValueKeywords(pvalue);
+ // Check for keyword shorthand values to be substituted.
+ pvalue = checkValueKeywords(pvalue.trim());
newProp = checkEnumValues(pvalue);
}
if (newProp == null) {
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PropertyMaker.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/ShorthandParser.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/SpaceProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/StringProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/TableColLength.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/TextDecorationProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CIDFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CIDFont.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CIDFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CIDFont.java Thu Feb 14 13:55:44 2008
@@ -83,15 +83,14 @@
return 0;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean isMultiByte() {
return true;
}
/**
- * Returns char[] array .
+ * Returns a char array containing all Unicode characters that have been accessed.
+ * @return a char array with all used Unicode characters
*/
public abstract char[] getCharsUsed();
}
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CIDFontType.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CIDFontType.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CIDFontType.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CIDFontType.java Thu Feb 14 13:55:44 2008
@@ -27,12 +27,12 @@
public class CIDFontType extends ValuedEnum {
/**
- * CID Font Type 0
+ * CID Font Type 0 (based on Type 1 format)
*/
public static final CIDFontType CIDTYPE0 = new CIDFontType("CIDFontType0", 0);
/**
- * CID Font Type 2
+ * CID Font Type 2 (based on TrueType format)
*/
public static final CIDFontType CIDTYPE2 = new CIDFontType("CIDFontType2", 1);
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CachedFontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CachedFontInfo.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CachedFontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CachedFontInfo.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.fonts;
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CachedFontInfo.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CustomFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CustomFont.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CustomFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CustomFont.java Thu Feb 14 13:55:44 2008
@@ -230,9 +230,7 @@
* @return the index of the first character
*/
public int getFirstChar() {
- return 0;
- // return firstChar;
- /**(todo) Why is this hardcoded??? This code was in SingleByteFont.java */
+ return firstChar;
}
/**
@@ -408,14 +406,25 @@
this.resolver = resolver;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void putKerningEntry(Integer key, Map value) {
if (kerning == null) {
kerning = new java.util.HashMap();
}
this.kerning.put(key, value);
+ }
+
+ /**
+ * Replaces the existing kerning map with a new one.
+ * @param kerningMap the kerning map (Map<Integer, Map<Integer, Integer>, the integers are
+ * character codes)
+ */
+ public void replaceKerningMap(Map kerningMap) {
+ if (kerningMap == null) {
+ this.kerning = Collections.EMPTY_MAP;
+ } else {
+ this.kerning = kerningMap;
+ }
}
}
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/EmbedFontInfo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontCache.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontCache.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontCache.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.fonts;
@@ -31,6 +31,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.util.LogUtil;
@@ -39,8 +40,11 @@
*/
public final class FontCache implements Serializable {
- /** Serialization Version UID */
- private static final long serialVersionUID = 605232520271754717L;
+ /**
+ * Serialization Version UID. Change this value if you want to make sure the user's cache
+ * file is purged after an update.
+ */
+ private static final long serialVersionUID = 605232520271754718L;
/** logging instance */
private static Log log = LogFactory.getLog(FontCache.class);
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontCache.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontInfo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java Thu Feb 14 13:55:44 2008
@@ -28,9 +28,9 @@
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.fonts.truetype.TTFFontLoader;
import org.apache.fop.fonts.type1.Type1FontLoader;
@@ -46,8 +46,6 @@
/** URI representing the font file */
protected String fontFileURI = null;
- /** the InputStream to load the font from */
- protected InputStream in = null;
/** the FontResolver to use for font URI resolution */
protected FontResolver resolver = null;
/** the loaded font */
@@ -59,12 +57,10 @@
/**
* Default constructor.
* @param fontFileURI the URI to the PFB file of a Type 1 font
- * @param in the InputStream reading the PFM file of a Type 1 font
* @param resolver the font resolver used to resolve URIs
*/
- public FontLoader(String fontFileURI, InputStream in, FontResolver resolver) {
+ public FontLoader(String fontFileURI, FontResolver resolver) {
this.fontFileURI = fontFileURI;
- this.in = in;
this.resolver = resolver;
}
@@ -107,58 +103,25 @@
public static CustomFont loadFont(String fontFileURI, FontResolver resolver)
throws IOException {
fontFileURI = fontFileURI.trim();
- String effURI;
boolean type1 = isType1(fontFileURI);
+ FontLoader loader;
if (type1) {
- String pfmExt = fontFileURI.substring(
- fontFileURI.length() - 3, fontFileURI.length());
- pfmExt = pfmExt.substring(0, 2) + (Character.isUpperCase(pfmExt.charAt(2)) ? "M" : "m");
- effURI = fontFileURI.substring(0, fontFileURI.length() - 4) + "." + pfmExt;
+ loader = new Type1FontLoader(fontFileURI, resolver);
} else {
- effURI = fontFileURI;
+ loader = new TTFFontLoader(fontFileURI, resolver);
}
- if (log.isDebugEnabled()) {
- log.debug("opening " + effURI);
- }
- InputStream in = openFontUri(resolver, effURI);
- return loadFontFromInputStream(fontFileURI, resolver, type1, in);
+ return loader.getFont();
}
/**
- * Loads and returns a font given an input stream.
- * @param fontFileURI font file uri
- * @param resolver font resolver
- * @param isType1 is it a type1 font?
- * @param in input stream
- * @return the loaded font.
- * @throws IOException In case of an I/O error
- */
- protected static CustomFont loadFontFromInputStream(
- String fontFileURI, FontResolver resolver, boolean isType1,
- InputStream in)
- throws IOException {
- FontLoader loader;
- try {
- if (isType1) {
- loader = new Type1FontLoader(fontFileURI, in, resolver);
- } else {
- loader = new TTFFontLoader(fontFileURI, in, resolver);
- }
- return loader.getFont();
- } finally {
- IOUtils.closeQuietly(in);
- }
- }
-
- /**
- * Opens a font uri and returns an input stream.
+ * Opens a font URI and returns an input stream.
* @param resolver the FontResolver to use for font URI resolution
* @param uri the URI representing the font
* @return the InputStream to read the font from.
* @throws IOException In case of an I/O error
* @throws MalformedURLException If an invalid URL is built
*/
- private static InputStream openFontUri(FontResolver resolver, String uri)
+ protected static InputStream openFontUri(FontResolver resolver, String uri)
throws IOException, MalformedURLException {
InputStream in = null;
if (resolver != null) {
@@ -191,7 +154,11 @@
*/
protected abstract void read() throws IOException;
- /** @see FontLoader#getFont() */
+ /**
+ * Returns the custom font that was read using this instance of FontLoader.
+ * @return the newly loaded font
+ * @throws IOException if an I/O error occurs
+ */
public CustomFont getFont() throws IOException {
if (!loaded) {
read();
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontReader.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontResolver.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontSetup.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontTriplet.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontType.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontType.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontType.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontType.java Thu Feb 14 13:55:44 2008
@@ -31,7 +31,7 @@
*/
public static final FontType OTHER = new FontType("Other", 0);
/**
- * Adobe Type 0 fonts
+ * Adobe Type 0 fonts (composite font)
*/
public static final FontType TYPE0 = new FontType("Type0", 1);
/**
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontUtil.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/SingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/SingleByteFont.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/SingleByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/SingleByteFont.java Thu Feb 14 13:55:44 2008
@@ -19,6 +19,8 @@
package org.apache.fop.fonts;
+import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -32,86 +34,79 @@
private CodePointMapping mapping;
- private String encoding = "WinAnsiEncoding";
-
private int[] width = null;
+ private Set warnedChars;
+
/**
* Main constructor.
*/
public SingleByteFont() {
- updateMapping();
+ setEncoding(CodePointMapping.WIN_ANSI_ENCODING);
}
- /**
- * Updates the mapping variable based on the encoding.
- */
- protected void updateMapping() {
- try {
- mapping = CodePointMapping.getMapping(getEncoding());
- } catch (UnsupportedOperationException e) {
- log.error("Font '" + super.getFontName() + "': " + e.getMessage());
- }
- }
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean isEmbeddable() {
return (getEmbedFileName() == null && getEmbedResourceName() == null) ? false
: true;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String getEncoding() {
- return encoding;
+ return this.mapping.getName();
}
/**
- * Sets the encoding of the font.
- * @param encoding the encoding (ex. "WinAnsiEncoding" or "SymbolEncoding")
+ * Returns the code point mapping (encoding) of this font.
+ * @return the code point mapping
*/
- public void setEncoding(String encoding) {
- this.encoding = encoding;
- updateMapping();
+ public CodePointMapping getCodePointMapping() {
+ return this.mapping;
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
public int getWidth(int i, int size) {
- return size * width[i];
+ int idx = i - getFirstChar();
+ if (idx >= 0 && idx < width.length) {
+ return size * width[i - getFirstChar()];
+ } else {
+ return 0;
+ }
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int[] getWidths() {
int[] arr = new int[width.length];
System.arraycopy(width, 0, arr, 0, width.length - 1);
return arr;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public char mapChar(char c) {
notifyMapOperation();
char d = mapping.mapChar(c);
if (d != 0) {
return d;
} else {
- log.warn("Glyph " + (int)c + " (0x" + Integer.toHexString(c)
- + ") not available in font " + getFontName());
+ Character ch = new Character(c);
+ if (warnedChars == null) {
+ warnedChars = new java.util.HashSet();
+ }
+ if (warnedChars.size() < 8 && !warnedChars.contains(ch)) {
+ warnedChars.add(ch);
+ if (warnedChars.size() == 8) {
+ log.warn("Many requested glyphs are not available in font " + getFontName());
+ } else {
+ log.warn("Glyph " + (int)c + " (0x" + Integer.toHexString(c)
+ + ", " + Glyphs.charToGlyphName(c)
+ + ") not available in font " + getFontName());
+ }
+ }
return '#';
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean hasChar(char c) {
return (mapping.mapChar(c) > 0);
}
@@ -119,15 +114,43 @@
/* ---- single byte font specific setters --- */
/**
+ * Updates the mapping variable based on the encoding.
+ * @param encoding the name of the encoding
+ */
+ protected void updateMapping(String encoding) {
+ try {
+ this.mapping = CodePointMapping.getMapping(encoding);
+ } catch (UnsupportedOperationException e) {
+ log.error("Font '" + super.getFontName() + "': " + e.getMessage());
+ }
+ }
+
+ /**
+ * Sets the encoding of the font.
+ * @param encoding the encoding (ex. "WinAnsiEncoding" or "SymbolEncoding")
+ */
+ public void setEncoding(String encoding) {
+ updateMapping(encoding);
+ }
+
+ /**
+ * Sets the encoding of the font.
+ * @param encoding the encoding information
+ */
+ public void setEncoding(CodePointMapping encoding) {
+ this.mapping = encoding;
+ }
+
+ /**
* Sets a width for a character.
* @param index index of the character
* @param width the width of the character
*/
public void setWidth(int index, int width) {
if (this.width == null) {
- this.width = new int[256];
+ this.width = new int[getLastChar() - getFirstChar() + 1];
}
- this.width[index] = width;
+ this.width[index - getFirstChar()] = width;
}
}
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/Typeface.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontFinder.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.fonts.autodetect;
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.fonts.autodetect;
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.fonts.autodetect;
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.fonts.autodetect;
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.fonts.autodetect;
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java Thu Feb 14 13:55:44 2008
@@ -1,129 +1,137 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.fonts.truetype;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.fop.fonts.BFEntry;
-import org.apache.fop.fonts.CIDFontType;
-import org.apache.fop.fonts.FontLoader;
-import org.apache.fop.fonts.FontResolver;
-import org.apache.fop.fonts.MultiByteFont;
-
-/**
- * Loads a font into memory directly from the original font file.
- */
-public class TTFFontLoader extends FontLoader {
-
- private MultiByteFont multiFont;
-
- /**
- * Default constructor
- * @param fontFileURI the URI representing the font file
- * @param in the InputStream to load the font from
- * @param resolver the FontResolver for font URI resolution
- */
- public TTFFontLoader(String fontFileURI, InputStream in, FontResolver resolver) {
- super(fontFileURI, in, resolver);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void read() throws IOException {
- TTFFile ttf = new TTFFile();
- FontFileReader reader = new FontFileReader(in);
- boolean supported = ttf.readFont(reader, null);
- if (!supported) {
- throw new IOException("Could not load TrueType font: " + fontFileURI);
- }
- if (ttf.isCFF()) {
- throw new UnsupportedOperationException(
- "OpenType fonts with CFF data are not supported, yet");
- }
- multiFont = new MultiByteFont();
- multiFont.setResolver(this.resolver);
- returnFont = multiFont;
-
- returnFont.setFontName(ttf.getPostScriptName());
- returnFont.setFullName(ttf.getFullName());
- returnFont.setFamilyNames(ttf.getFamilyNames());
- returnFont.setFontSubFamilyName(ttf.getSubFamilyName());
- //multiFont.setTTCName(ttcName)
- returnFont.setCapHeight(ttf.getCapHeight());
- returnFont.setXHeight(ttf.getXHeight());
- returnFont.setAscender(ttf.getLowerCaseAscent());
- returnFont.setDescender(ttf.getLowerCaseDescent());
- returnFont.setFontBBox(ttf.getFontBBox());
- //returnFont.setFirstChar(ttf.getFirstChar();)
- returnFont.setFlags(ttf.getFlags());
- returnFont.setStemV(Integer.parseInt(ttf.getStemV())); //not used for TTF
- returnFont.setItalicAngle(Integer.parseInt(ttf.getItalicAngle()));
- returnFont.setMissingWidth(0);
-
- multiFont.setCIDType(CIDFontType.CIDTYPE2);
- int[] wx = ttf.getWidths();
- multiFont.setWidthArray(wx);
- List entries = ttf.getCMaps();
- BFEntry[] bfentries = new BFEntry[entries.size()];
- int pos = 0;
- Iterator iter = ttf.getCMaps().listIterator();
- while (iter.hasNext()) {
- TTFCmapEntry ce = (TTFCmapEntry)iter.next();
- bfentries[pos] = new BFEntry(ce.getUnicodeStart(), ce.getUnicodeEnd(),
- ce.getGlyphStartIndex());
- pos++;
- }
- multiFont.setBFEntries(bfentries);
- copyKerning(ttf, true);
- multiFont.setEmbedFileName(this.fontFileURI);
- loaded = true;
- }
-
- /**
- * Copy kerning information.
- */
- private void copyKerning(TTFFile ttf, boolean isCid) {
-
- // Get kerning
- Iterator iter;
- if (isCid) {
- iter = ttf.getKerning().keySet().iterator();
- } else {
- iter = ttf.getAnsiKerning().keySet().iterator();
- }
-
- while (iter.hasNext()) {
- Integer kpx1 = (Integer)iter.next();
-
- Map h2;
- if (isCid) {
- h2 = (Map)ttf.getKerning().get(kpx1);
- } else {
- h2 = (Map)ttf.getAnsiKerning().get(kpx1);
- }
- returnFont.putKerningEntry(kpx1, h2);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts.truetype;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.fop.fonts.BFEntry;
+import org.apache.fop.fonts.CIDFontType;
+import org.apache.fop.fonts.FontLoader;
+import org.apache.fop.fonts.FontResolver;
+import org.apache.fop.fonts.MultiByteFont;
+
+/**
+ * Loads a font into memory directly from the original font file.
+ */
+public class TTFFontLoader extends FontLoader {
+
+ private MultiByteFont multiFont;
+
+ /**
+ * Default constructor
+ * @param fontFileURI the URI representing the font file
+ * @param resolver the FontResolver for font URI resolution
+ */
+ public TTFFontLoader(String fontFileURI, FontResolver resolver) {
+ super(fontFileURI, resolver);
+ }
+
+ /** {@inheritDoc} */
+ protected void read() throws IOException {
+ InputStream in = openFontUri(resolver, this.fontFileURI);
+ try {
+ TTFFile ttf = new TTFFile();
+ FontFileReader reader = new FontFileReader(in);
+ boolean supported = ttf.readFont(reader, null);
+ if (!supported) {
+ throw new IOException("Could not load TrueType font: " + fontFileURI);
+ }
+ buildFont(ttf);
+ loaded = true;
+ } finally {
+ IOUtils.closeQuietly(in);
+ }
+ }
+
+ private void buildFont(TTFFile ttf) {
+ if (ttf.isCFF()) {
+ throw new UnsupportedOperationException(
+ "OpenType fonts with CFF data are not supported, yet");
+ }
+ multiFont = new MultiByteFont();
+ multiFont.setResolver(this.resolver);
+ returnFont = multiFont;
+
+ returnFont.setFontName(ttf.getPostScriptName());
+ returnFont.setFullName(ttf.getFullName());
+ returnFont.setFamilyNames(ttf.getFamilyNames());
+ returnFont.setFontSubFamilyName(ttf.getSubFamilyName());
+ //multiFont.setTTCName(ttcName)
+ returnFont.setCapHeight(ttf.getCapHeight());
+ returnFont.setXHeight(ttf.getXHeight());
+ returnFont.setAscender(ttf.getLowerCaseAscent());
+ returnFont.setDescender(ttf.getLowerCaseDescent());
+ returnFont.setFontBBox(ttf.getFontBBox());
+ //returnFont.setFirstChar(ttf.getFirstChar();)
+ returnFont.setFlags(ttf.getFlags());
+ returnFont.setStemV(Integer.parseInt(ttf.getStemV())); //not used for TTF
+ returnFont.setItalicAngle(Integer.parseInt(ttf.getItalicAngle()));
+ returnFont.setMissingWidth(0);
+
+ multiFont.setCIDType(CIDFontType.CIDTYPE2);
+ int[] wx = ttf.getWidths();
+ multiFont.setWidthArray(wx);
+ List entries = ttf.getCMaps();
+ BFEntry[] bfentries = new BFEntry[entries.size()];
+ int pos = 0;
+ Iterator iter = ttf.getCMaps().listIterator();
+ while (iter.hasNext()) {
+ TTFCmapEntry ce = (TTFCmapEntry)iter.next();
+ bfentries[pos] = new BFEntry(ce.getUnicodeStart(), ce.getUnicodeEnd(),
+ ce.getGlyphStartIndex());
+ pos++;
+ }
+ multiFont.setBFEntries(bfentries);
+ copyKerning(ttf, true);
+ multiFont.setEmbedFileName(this.fontFileURI);
+ }
+
+ /**
+ * Copy kerning information.
+ */
+ private void copyKerning(TTFFile ttf, boolean isCid) {
+
+ // Get kerning
+ Iterator iter;
+ if (isCid) {
+ iter = ttf.getKerning().keySet().iterator();
+ } else {
+ iter = ttf.getAnsiKerning().keySet().iterator();
+ }
+
+ while (iter.hasNext()) {
+ Integer kpx1 = (Integer)iter.next();
+
+ Map h2;
+ if (isCid) {
+ h2 = (Map)ttf.getKerning().get(kpx1);
+ } else {
+ h2 = (Map)ttf.getAnsiKerning().get(kpx1);
+ }
+ returnFont.putKerningEntry(kpx1, h2);
+ }
+ }
+}
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org