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 vh...@apache.org on 2012/04/05 18:20:17 UTC
svn commit: r1309921 [7/42] - in
/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript: ./ examples/embedding/
examples/embedding/java/embedding/ examples/embedding/java/embedding/atxml/
examples/embedding/java/embedding/tools/ examples/plan/src/org/apac...
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPDitheredRectanglePainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPDitheredRectanglePainter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPDitheredRectanglePainter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPDitheredRectanglePainter.java Thu Apr 5 16:19:19 2012
@@ -90,22 +90,18 @@ public class AFPDitheredRectanglePainter
imageObjectInfo.setData(dither);
//Positioning
- AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo();
int rotation = paintingState.getRotation();
AffineTransform at = paintingState.getData().getTransform();
Point2D origin = at.transform(new Point2D.Float(
rectanglePaintInfo.getX() * 1000,
rectanglePaintInfo.getY() * 1000), null);
- objectAreaInfo.setX((int)Math.round(origin.getX()));
- objectAreaInfo.setY((int)Math.round(origin.getY()));
AFPUnitConverter unitConv = paintingState.getUnitConverter();
float width = unitConv.pt2units(rectanglePaintInfo.getWidth());
float height = unitConv.pt2units(rectanglePaintInfo.getHeight());
- objectAreaInfo.setWidth(Math.round(width));
- objectAreaInfo.setHeight(Math.round(height));
- objectAreaInfo.setHeightRes(resolution);
- objectAreaInfo.setWidthRes(resolution);
- objectAreaInfo.setRotation(rotation);
+ AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(
+ (int) Math.round(origin.getX()),
+ (int) Math.round(origin.getY()),
+ Math.round(width), Math.round(height), resolution, rotation);
imageObjectInfo.setObjectAreaInfo(objectAreaInfo);
//Create rectangle
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPEventProducer.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPEventProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPEventProducer.java Thu Apr 5 16:19:19 2012
@@ -39,8 +39,7 @@ public interface AFPEventProducer extend
* @return the event producer
*/
public static AFPEventProducer get(EventBroadcaster broadcaster) {
- return (AFPEventProducer)broadcaster.getEventProducerFor(
- AFPEventProducer.class);
+ return (AFPEventProducer) broadcaster.getEventProducerFor(AFPEventProducer.class);
}
}
@@ -81,4 +80,37 @@ public interface AFPEventProducer extend
* @event.severity ERROR
*/
void resourceEmbeddingError(Object source, String resourceName, Exception e);
+
+ /**
+ * A mandatory font configuration node is missing at location.
+ * @param source the event source
+ * @param missingConfig the expected configuration element
+ * @param location the position of the missing element within the config file.
+ * @event.severity ERROR
+ */
+ void fontConfigMissing(Object source, String missingConfig, String location);
+
+ /**
+ * The character set given has an invalid name.
+ * @param source the event source
+ * @param msg the error message
+ * @event.severity ERROR
+ */
+ void characterSetNameInvalid(Object source, String msg);
+
+ /**
+ * The code page for an AFP font could not be found.
+ * @param source the event source
+ * @param e the original exception
+ * @event.severity ERROR
+ */
+ void codePageNotFound(Object source, Exception e);
+
+ /**
+ * This is a generic event for invalid configuration errors.
+ * @param source the event source
+ * @param e the original exception
+ * @event.severity ERROR
+ */
+ void invalidConfiguration(Object source, Exception e);
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPEventProducer.xml?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPEventProducer.xml (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPEventProducer.xml Thu Apr 5 16:19:19 2012
@@ -4,4 +4,8 @@
<message key="warnMissingDefaultFont">No AFP default "any", {style}, {weight} font configured.</message>
<message key="characterSetEncodingError">An error occurred when attempting to encode character set {charSetName} with encoding scheme {encoding}.</message>
<message key="resourceEmbeddingError">An error occurs while embedding the resource named "{resourceName}".[ Reason: {e}]</message>
+ <message key="invalidConfiguration">There has been a configuration error.[ Reason: {e}]</message>
+ <message key="fontConfigMissing">The mandatory configuation node: '{missingConfig}' was not found at {location}.</message>
+ <message key="characterSetNameInvalid">The character set given has an invalid name. [ Reason: {msg} ]</message>
+ <message key="codePageNotFound">The code page for an AFP font cannot be found.[ Reason: {e}]</message>
</catalogue>
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPGraphics2D.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPGraphics2D.java Thu Apr 5 16:19:19 2012
@@ -26,7 +26,6 @@ import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Paint;
@@ -166,6 +165,14 @@ public class AFPGraphics2D extends Abstr
}
/**
+ * Returns the AFP resource manager associated with this {@link Graphics2D} instance.
+ * @return the resource manager
+ */
+ public AFPResourceManager getResourceManager() {
+ return this.resourceManager;
+ }
+
+ /**
* Sets the AFP resource info
*
* @param resourceInfo the AFP resource info
@@ -497,12 +504,14 @@ public class AFPGraphics2D extends Abstr
}
/** {@inheritDoc} */
+ @Override
public void draw(Shape shape) {
LOG.debug("draw() shape=" + shape);
doDrawing(shape, false);
}
/** {@inheritDoc} */
+ @Override
public void fill(Shape shape) {
LOG.debug("fill() shape=" + shape);
doDrawing(shape, true);
@@ -521,6 +530,7 @@ public class AFPGraphics2D extends Abstr
}
/** {@inheritDoc} */
+ @Override
public void drawString(String str, float x, float y) {
try {
if (customTextHandler != null && !textAsShapes) {
@@ -534,21 +544,25 @@ public class AFPGraphics2D extends Abstr
}
/** {@inheritDoc} */
+ @Override
public GraphicsConfiguration getDeviceConfiguration() {
return graphicsConfig;
}
/** {@inheritDoc} */
+ @Override
public Graphics create() {
return new AFPGraphics2D(this);
}
/** {@inheritDoc} */
+ @Override
public void dispose() {
this.graphicsObj = null;
}
/** {@inheritDoc} */
+ @Override
public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
return drawImage(img, x, y, img.getWidth(observer), img.getHeight(observer), observer);
}
@@ -595,6 +609,7 @@ public class AFPGraphics2D extends Abstr
}
/** {@inheritDoc} */
+ @Override
public boolean drawImage(Image img, int x, int y, int width, int height,
ImageObserver observer) {
// draw with AWT Graphics2D
@@ -609,6 +624,7 @@ public class AFPGraphics2D extends Abstr
}
/** {@inheritDoc} */
+ @Override
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
int imgWidth = img.getWidth();
int imgHeight = img.getHeight();
@@ -658,17 +674,20 @@ public class AFPGraphics2D extends Abstr
}
/** {@inheritDoc} */
+ @Override
public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
LOG.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform);
}
/** {@inheritDoc} */
+ @Override
public FontMetrics getFontMetrics(Font f) {
LOG.debug("getFontMetrics() NYI: f=" + f);
return null;
}
/** {@inheritDoc} */
+ @Override
public void setXORMode(Color col) {
LOG.debug("setXORMode() NYI: col=" + col);
}
@@ -681,6 +700,7 @@ public class AFPGraphics2D extends Abstr
}
/** {@inheritDoc} */
+ @Override
public void copyArea(int x, int y, int width, int height, int dx, int dy) {
LOG.debug("copyArea() NYI: ");
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPImageObjectInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPImageObjectInfo.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPImageObjectInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPImageObjectInfo.java Thu Apr 5 16:19:19 2012
@@ -85,7 +85,7 @@ public class AFPImageObjectInfo extends
* @return true if this image uses compression
*/
public boolean hasCompression() {
- return compression > -1;
+ return compression != -1;
}
/**
@@ -123,6 +123,7 @@ public class AFPImageObjectInfo extends
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return "AFPImageObjectInfo{" + super.toString()
+ ", compression=" + compression
@@ -131,4 +132,4 @@ public class AFPImageObjectInfo extends
+ ", " + (isSubtractive() ? "subtractive" : "additive")
+ "}";
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPObjectAreaInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPObjectAreaInfo.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPObjectAreaInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPObjectAreaInfo.java Thu Apr 5 16:19:19 2012
@@ -24,66 +24,60 @@ package org.apache.fop.afp;
* dimensions and resolutions of data objects.
*/
public class AFPObjectAreaInfo {
- private int x;
- private int y;
- private int width;
- private int height;
+ private final int x;
+ private final int y;
+ private final int width;
+ private final int height;
private int widthRes;
private int heightRes;
- private int rotation = 0;
+ private final int rotation;
/**
- * Sets the x position of the data object
+ * Constructor
*
- * @param x the x position of the data object
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @param width the width
+ * @param height the height
+ * @param resolution the resolution (sets both width and height resolutions)
+ * @param rotation the rotation angle
*/
- public void setX(int x) {
+ public AFPObjectAreaInfo(int x, int y, int width, int height, int resolution, int rotation) {
this.x = x;
- }
-
- /**
- * Sets the y position of the data object
- *
- * @param y the y position of the data object
- */
- public void setY(int y) {
this.y = y;
- }
-
- /**
- * Sets the data object width
- *
- * @param width the width of the data object
- */
- public void setWidth(int width) {
this.width = width;
+ this.height = height;
+ this.rotation = rotation;
+ this.widthRes = resolution;
+ this.heightRes = resolution;
}
/**
- * Sets the data object height
+ * Sets both the width and the height resolutions.
*
- * @param height the height of the data object
+ * @param resolution the resolution
*/
- public void setHeight(int height) {
- this.height = height;
+ public void setResolution(int resolution) {
+ this.widthRes = resolution;
+ this.heightRes = resolution;
}
/**
- * Sets the width resolution
+ * Sets the width resolution.
*
- * @param widthRes the width resolution
+ * @param resolution the resolution
*/
- public void setWidthRes(int widthRes) {
- this.widthRes = widthRes;
+ public void setWidthRes(int resolution) {
+ this.widthRes = resolution;
}
/**
- * Sets the height resolution
+ * Sets the height resolution.
*
- * @param heightRes the height resolution
+ * @param resolution the resolution
*/
- public void setHeightRes(int heightRes) {
- this.heightRes = heightRes;
+ public void setHeightRes(int resolution) {
+ this.heightRes = resolution;
}
/**
@@ -125,7 +119,7 @@ public class AFPObjectAreaInfo {
/**
* Returns the width resolution of this data object
*
- * @return the width resolution of this data object
+ * @return the resolution of this data object
*/
public int getWidthRes() {
return widthRes;
@@ -134,7 +128,7 @@ public class AFPObjectAreaInfo {
/**
* Returns the height resolution of this data object
*
- * @return the height resolution of this data object
+ * @return the resolution of this data object
*/
public int getHeightRes() {
return heightRes;
@@ -149,24 +143,15 @@ public class AFPObjectAreaInfo {
return rotation;
}
- /**
- * Sets the data object rotation
- *
- * @param rotation the data object rotation
- */
- public void setRotation(int rotation) {
- this.rotation = rotation;
- }
-
/** {@inheritDoc} */
public String toString() {
return "x=" + x
- + ", y=" + y
- + ", width=" + width
- + ", height=" + height
- + ", widthRes=" + widthRes
- + ", heightRes=" + heightRes
- + ", rotation=" + rotation;
+ + ", y=" + y
+ + ", width=" + width
+ + ", height=" + height
+ + ", widthRes=" + widthRes
+ + ", heigtRes=" + heightRes
+ + ", rotation=" + rotation;
}
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPPaintingState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPPaintingState.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPPaintingState.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPPaintingState.java Thu Apr 5 16:19:19 2012
@@ -53,6 +53,9 @@ public class AFPPaintingState extends or
/** dithering quality setting (0.0f..1.0f) */
private float ditheringQuality;
+ /** image encoding quality setting (0.0f..1.0f) */
+ private float bitmapEncodingQuality;
+
/** color image handler */
private ColorConverter colorConverter = GrayScaleColorConverter.getInstance();
@@ -61,6 +64,9 @@ public class AFPPaintingState extends or
* format.
*/
private boolean nativeImagesSupported = false;
+
+ private boolean canEmbedJpeg = false;
+
/**
* true if CMYK images (requires IOCA FS45 suppport on the target platform)
* may be generated
@@ -73,6 +79,11 @@ public class AFPPaintingState extends or
/** the output resolution */
private int resolution = 240; // 240 dpi
+ /** determines whether GOCA is enabled or disabled */
+ private boolean gocaEnabled = true;
+ /** determines whether to stroke text in GOCA mode or to use text operators where possible */
+ private boolean strokeGocaText = false;
+
/** the current page */
private transient AFPPagePaintingState pagePaintingState = new AFPPagePaintingState();
@@ -215,6 +226,24 @@ public class AFPPaintingState extends or
}
/**
+ * Set whether or not JPEG images can be embedded within an AFP document.
+ *
+ * @param canEmbed true if the JPEG image can be embedded
+ */
+ public void setCanEmbedJpeg(boolean canEmbed) {
+ canEmbedJpeg = canEmbed;
+ }
+
+ /**
+ * Returns true if JPEGs can be embedded in an AFP document.
+ *
+ * @return true if JPEG embedding is allowed
+ */
+ public boolean canEmbedJpeg() {
+ return canEmbedJpeg;
+ }
+
+ /**
* Controls whether CMYK images (IOCA FS45) are enabled. By default, support
* is disabled for wider compatibility. When disabled, any CMYK image is
* converted to the selected color format.
@@ -255,6 +284,25 @@ public class AFPPaintingState extends or
}
/**
+ * Gets the image encoding quality setting to use when encoding bitmap images.
+ * @return the encoding quality (a value between 0.0f and 1.0f, 1.0 meaning loss-less)
+ */
+ public float getBitmapEncodingQuality() {
+ return this.bitmapEncodingQuality;
+ }
+
+ /**
+ * Sets the image encoding quality setting to use when encoding bitmap images.
+ * @param quality Defines the desired quality level for the conversion.
+ * Valid values: a value between 0.0f (lowest) and 1.0f (best, loss-less)
+ */
+ public void setBitmapEncodingQuality(float quality) {
+ quality = Math.max(quality, 0.0f);
+ quality = Math.min(quality, 1.0f);
+ this.bitmapEncodingQuality = quality;
+ }
+
+ /**
* Sets the output/device resolution
*
* @param resolution
@@ -276,12 +324,46 @@ public class AFPPaintingState extends or
return this.resolution;
}
+ /**
+ * Controls whether GOCA is enabled or disabled.
+ * @param enabled true if GOCA is enabled, false if it is disabled
+ */
+ public void setGOCAEnabled(boolean enabled) {
+ this.gocaEnabled = enabled;
+ }
+
+ /**
+ * Indicates whether GOCA is enabled or disabled.
+ * @return true if GOCA is enabled, false if GOCA is disabled
+ */
+ public boolean isGOCAEnabled() {
+ return this.gocaEnabled;
+ }
+
+ /**
+ * Controls whether to stroke text in GOCA mode or to use text operators where possible.
+ * @param stroke true to stroke, false to paint with text operators where possible
+ */
+ public void setStrokeGOCAText(boolean stroke) {
+ this.strokeGocaText = stroke;
+ }
+
+ /**
+ * Indicates whether to stroke text in GOCA mode or to use text operators where possible.
+ * @return true to stroke, false to paint with text operators where possible
+ */
+ public boolean isStrokeGOCAText() {
+ return this.strokeGocaText;
+ }
+
/** {@inheritDoc} */
+ @Override
protected AbstractData instantiateData() {
return new AFPData();
}
/** {@inheritDoc} */
+ @Override
protected AbstractPaintingState instantiate() {
return new AFPPaintingState();
}
@@ -423,6 +505,7 @@ public class AFPPaintingState extends or
}
/** {@inheritDoc} */
+ @Override
public Object clone() {
AFPPaintingState paintingState = (AFPPaintingState) super.clone();
paintingState.pagePaintingState = (AFPPagePaintingState) this.pagePaintingState.clone();
@@ -436,6 +519,7 @@ public class AFPPaintingState extends or
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return "AFPPaintingState{" + "portraitRotation=" + portraitRotation
+ ", landscapeRotation=" + landscapeRotation + ", colorImages=" + colorImages
@@ -548,6 +632,7 @@ public class AFPPaintingState extends or
}
/** {@inheritDoc} */
+ @Override
public Object clone() {
AFPPagePaintingState state = new AFPPagePaintingState();
state.width = this.width;
@@ -559,6 +644,7 @@ public class AFPPaintingState extends or
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return "AFPPagePaintingState{width=" + width + ", height=" + height + ", orientation="
+ orientation + ", fonts=" + fonts + ", fontCount=" + fontCount + "}";
@@ -577,6 +663,7 @@ public class AFPPaintingState extends or
private String imageUri = null;
/** {@inheritDoc} */
+ @Override
public Object clone() {
AFPData obj = (AFPData) super.clone();
obj.filled = this.filled;
@@ -585,15 +672,17 @@ public class AFPPaintingState extends or
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return "AFPData{" + super.toString() + ", filled=" + filled + ", imageUri=" + imageUri
+ "}";
}
/** {@inheritDoc} */
+ @Override
protected AbstractData instantiate() {
return new AFPData();
}
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPRectanglePainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPRectanglePainter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPRectanglePainter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPRectanglePainter.java Thu Apr 5 16:19:19 2012
@@ -58,14 +58,6 @@ public class AFPRectanglePainter extends
lineDataInfo.setThickness ( Math.round(height) );
switch (lineDataInfo.getRotation()) {
- default:
- case 0:
- lineDataInfo.setX1 ( Math.round((float)at.getTranslateX() + x) );
- yNew = Math.round((float)at.getTranslateY() + y);
- lineDataInfo.setY1 ( yNew );
- lineDataInfo.setY2 ( yNew );
- lineDataInfo.setX2 ( Math.round((float)at.getTranslateX() + x + width) );
- break;
case 90:
lineDataInfo.setX1 ( Math.round((float)at.getTranslateY() + x) );
yNew = pageWidth - Math.round((float)at.getTranslateX()) + Math.round(y);
@@ -87,6 +79,14 @@ public class AFPRectanglePainter extends
lineDataInfo.setY2 ( yNew );
lineDataInfo.setX2 ( pageHeight - Math.round((float)at.getTranslateY() - x - width) );
break;
+ case 0:
+ default:
+ lineDataInfo.setX1 ( Math.round((float)at.getTranslateX() + x) );
+ yNew = Math.round((float)at.getTranslateY() + y);
+ lineDataInfo.setY1 ( yNew );
+ lineDataInfo.setY2 ( yNew );
+ lineDataInfo.setX2 ( Math.round((float)at.getTranslateX() + x + width) );
+ break;
}
dataStream.createLine(lineDataInfo);
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceInfo.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceInfo.java Thu Apr 5 16:19:19 2012
@@ -173,4 +173,4 @@ public class AFPResourceInfo {
hash = 31 * hash + (null == level ? 0 : level.hashCode());
return hash;
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceLevel.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceLevel.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceLevel.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceLevel.java Thu Apr 5 16:19:19 2012
@@ -198,4 +198,4 @@ public class AFPResourceLevel {
hash = 31 * hash + (null == extFilePath ? 0 : extFilePath.hashCode());
return hash;
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPResourceManager.java Thu Apr 5 16:19:19 2012
@@ -66,10 +66,12 @@ public class AFPResourceManager {
private int instreamObjectCount = 0;
/** a mapping of resourceInfo --> include name */
- private final Map/*<AFPResourceInfo,String>*/ includeNameMap
- = new java.util.HashMap()/*<AFPResourceInfo,String>*/;
+ private final Map<AFPResourceInfo, String> includeNameMap
+ = new java.util.HashMap<AFPResourceInfo, String>();
- private Map pageSegmentMap = new java.util.HashMap();
+ /** a mapping of resourceInfo --> page segment name */
+ private Map<AFPResourceInfo, String> pageSegmentMap
+ = new java.util.HashMap<AFPResourceInfo, String>();
private AFPResourceLevelDefaults resourceLevelDefaults = new AFPResourceLevelDefaults();
@@ -126,32 +128,49 @@ public class AFPResourceManager {
}
/**
- * Creates a new data object in the AFP datastream
- *
+ * Tries to create an include of a data object that has been previously added to the
+ * AFP data stream. If no such object was available, the method returns false which serves
+ * as a signal that the object has to be created.
* @param dataObjectInfo the data object info
- *
+ * @return true if the inclusion succeeded, false if the object was not available
* @throws IOException thrown if an I/O exception of some sort has occurred.
*/
- public void createObject(AFPDataObjectInfo dataObjectInfo) throws IOException {
- AbstractNamedAFPObject namedObj = null;
-
+ public boolean tryIncludeObject(AFPDataObjectInfo dataObjectInfo) throws IOException {
AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
updateResourceInfoUri(resourceInfo);
- String objectName = (String)includeNameMap.get(resourceInfo);
+ String objectName = includeNameMap.get(resourceInfo);
if (objectName != null) {
// an existing data resource so reference it by adding an include to the current page
includeObject(dataObjectInfo, objectName);
- return;
+ return true;
}
- objectName = (String)pageSegmentMap.get(resourceInfo);
+ objectName = pageSegmentMap.get(resourceInfo);
if (objectName != null) {
// an existing data resource so reference it by adding an include to the current page
includePageSegment(dataObjectInfo, objectName);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Creates a new data object in the AFP datastream
+ *
+ * @param dataObjectInfo the data object info
+ *
+ * @throws IOException thrown if an I/O exception of some sort has occurred.
+ */
+ public void createObject(AFPDataObjectInfo dataObjectInfo) throws IOException {
+ if (tryIncludeObject(dataObjectInfo)) {
+ //Object has already been produced and is available by inclusion, so return early.
return;
}
+ AbstractNamedAFPObject namedObj = null;
+ AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+
boolean useInclude = true;
Registry.ObjectType objectType = null;
@@ -194,7 +213,7 @@ public class AFPResourceManager {
resourceGroup.addObject(namedObj);
// create the include object
- objectName = namedObj.getName();
+ String objectName = namedObj.getName();
if (usePageSegment) {
includePageSegment(dataObjectInfo, objectName);
pageSegmentMap.put(resourceInfo, objectName);
@@ -223,8 +242,7 @@ public class AFPResourceManager {
private void includeObject(AFPDataObjectInfo dataObjectInfo,
String objectName) {
- IncludeObject includeObject
- = dataObjectFactory.createInclude(objectName, dataObjectInfo);
+ IncludeObject includeObject = dataObjectFactory.createInclude(objectName, dataObjectInfo);
dataStream.getCurrentPage().addObject(includeObject);
}
@@ -296,7 +314,7 @@ public class AFPResourceManager {
resourceInfo.setName(resourceName);
resourceInfo.setUri(uri.toASCIIString());
- String objectName = (String)includeNameMap.get(resourceInfo);
+ String objectName = includeNameMap.get(resourceInfo);
if (objectName == null) {
if (log.isDebugEnabled()) {
log.debug("Adding included resource: " + resourceName);
@@ -334,7 +352,7 @@ public class AFPResourceManager {
resourceInfo.setName(resourceName);
resourceInfo.setUri(uri.toASCIIString());
- String resource = (String)includeNameMap.get(resourceInfo);
+ String resource = includeNameMap.get(resourceInfo);
if (resource == null) {
ResourceGroup resourceGroup = streamer.getResourceGroup(resourceLevel);
@@ -343,6 +361,7 @@ public class AFPResourceManager {
//The included resource may already be wrapped in a resource object
AbstractNamedAFPObject resourceObject = new AbstractNamedAFPObject(null) {
+ @Override
protected void writeContent(OutputStream os) throws IOException {
InputStream inputStream = null;
try {
@@ -355,8 +374,10 @@ public class AFPResourceManager {
}
//bypass super.writeStart
+ @Override
protected void writeStart(OutputStream os) throws IOException { }
//bypass super.writeEnd
+ @Override
protected void writeEnd(OutputStream os) throws IOException { }
};
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPStreamer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPStreamer.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPStreamer.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPStreamer.java Thu Apr 5 16:19:19 2012
@@ -174,6 +174,14 @@ public class AFPStreamer implements Stre
outputStream.close();
+
+ if (documentOutputStream != null) {
+ documentOutputStream.close();
+ }
+
+ if (documentFile != null) {
+ documentFile.close();
+ }
// delete temporary file
tempFile.delete();
}
@@ -213,4 +221,4 @@ public class AFPStreamer implements Stre
// long end = System.currentTimeMillis();
// log.debug("writing time " + (end - start) + "ms");
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPTextDataInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPTextDataInfo.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPTextDataInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/AFPTextDataInfo.java Thu Apr 5 16:19:19 2012
@@ -229,4 +229,4 @@ public class AFPTextDataInfo {
+ ", textEncoding=" + textEncoding
+ "}";
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/DataStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/DataStream.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/DataStream.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/DataStream.java Thu Apr 5 16:19:19 2012
@@ -595,7 +595,13 @@ public class DataStream {
* byte data
*/
public void createNoOperation(String content) {
- currentPage.createNoOperation(content);
+ if (currentPage != null) {
+ currentPage.createNoOperation(content);
+ } else if (currentPageGroup != null) {
+ currentPageGroup.createNoOperation(content);
+ } else {
+ document.createNoOperation(content);
+ }
}
/**
@@ -639,9 +645,9 @@ public class DataStream {
currentPageGroup.endPageGroup();
tleSequence = currentPageGroup.getTleSequence();
document.addPageGroup(currentPageGroup);
- document.writeToStream(outputStream);
currentPageGroup = null;
}
+ document.writeToStream(outputStream); //Flush objects
}
/**
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/StructuredData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/StructuredData.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/StructuredData.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/StructuredData.java Thu Apr 5 16:19:19 2012
@@ -30,4 +30,4 @@ public interface StructuredData {
* @return the data length of this structured field
*/
int getDataLength();
-}
\ No newline at end of file
+}
Propchange: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/apps/
------------------------------------------------------------------------------
Merged /xmlgraphics/fop/branches/Temp_PDF_ObjectStreams/src/java/org/apache/fop/afp/apps:r1303414-1305418
Merged /xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/afp/apps:r956535-1069429
Merged /xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/apps:r1040963-1307575
Merged /xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/afp/apps:r1187234-1242827
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java Thu Apr 5 16:19:19 2012
@@ -55,9 +55,10 @@ public class FontPatternExtractor {
UnparsedStructuredField strucField;
while ((strucField = parser.readNextStructuredField()) != null) {
if (strucField.getSfTypeID() == 0xD3EE89) {
+ byte[] sfData = strucField.getData();
println(strucField.toString());
- HexDump.dump(strucField.getData(), 0, printStream, 0);
- baout.write(strucField.getData());
+ HexDump.dump(sfData, 0, printStream, 0);
+ baout.write(sfData);
}
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java Thu Apr 5 16:19:19 2012
@@ -19,6 +19,7 @@
package org.apache.fop.afp.fonts;
+import org.apache.fop.afp.AFPEventProducer;
import org.apache.fop.fonts.Base14Font;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontCollection;
@@ -40,6 +41,15 @@ import org.apache.fop.fonts.base14.Times
*/
public class AFPBase12FontCollection implements FontCollection {
+ private final AFPEventProducer eventProducer;
+
+ /**
+ * @param eventProducer the AFP-specific event producer
+ */
+ public AFPBase12FontCollection(AFPEventProducer eventProducer) {
+ this.eventProducer = eventProducer;
+ }
+
/** standard raster font sizes */
private static final int[] RASTER_SIZES = {6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 30, 36};
@@ -52,7 +62,7 @@ public class AFPBase12FontCollection imp
int size = RASTER_SIZES[i] * 1000;
FopCharacterSet characterSet = new FopCharacterSet(
CharacterSet.DEFAULT_CODEPAGE, CharacterSet.DEFAULT_ENCODING,
- charsetName + CHARSET_REF[i], base14);
+ charsetName + CHARSET_REF[i], base14, eventProducer);
font.addCharacterSet(size, characterSet);
}
}
@@ -108,22 +118,22 @@ public class AFPBase12FontCollection imp
"Times New Roman", "TimesNewRoman", "serif", "any"};
font = createReferencedRasterFont("Times Roman");
- addCharacterSet(font, "CON200", new TimesRoman());
+ addCharacterSet(font, "C0N200", new TimesRoman());
num = addFontProperties(fontInfo, font, timesNames,
Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, num);
font = createReferencedRasterFont("Times Roman Italic");
- addCharacterSet(font, "CON300", new TimesItalic());
+ addCharacterSet(font, "C0N300", new TimesItalic());
num = addFontProperties(fontInfo, font, timesNames,
Font.STYLE_ITALIC, Font.WEIGHT_NORMAL, num);
font = createReferencedRasterFont("Times Roman Bold");
- addCharacterSet(font, "CON400", new TimesBold());
+ addCharacterSet(font, "C0N400", new TimesBold());
num = addFontProperties(fontInfo, font, timesNames,
Font.STYLE_NORMAL, Font.WEIGHT_BOLD, num);
font = createReferencedRasterFont("Times Roman Italic Bold");
- addCharacterSet(font, "CON500", new TimesBoldItalic());
+ addCharacterSet(font, "C0N500", new TimesBoldItalic());
num = addFontProperties(fontInfo, font, timesNames,
Font.STYLE_ITALIC, Font.WEIGHT_BOLD, num);
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFont.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFont.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFont.java Thu Apr 5 16:19:19 2012
@@ -129,4 +129,4 @@ public abstract class AFPFont extends Ty
public String toString() {
return "name=" + name;
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java Thu Apr 5 16:19:19 2012
@@ -19,7 +19,6 @@
package org.apache.fop.afp.fonts;
-import java.util.Iterator;
import java.util.List;
import org.apache.fop.afp.AFPEventProducer;
@@ -34,9 +33,9 @@ import org.apache.fop.fonts.FontTriplet;
*/
public class AFPFontCollection implements FontCollection {
- private final EventBroadcaster eventBroadcaster;
+ private final AFPEventProducer eventProducer;
- private final List/*<AFPFontInfo>*/ fontInfoList;
+ private final List<AFPFontInfo> fontInfoList;
/**
* Main constructor
@@ -44,49 +43,40 @@ public class AFPFontCollection implement
* @param eventBroadcaster the event broadcaster
* @param fontInfoList the font info list
*/
- public AFPFontCollection(EventBroadcaster eventBroadcaster,
- List/*<AFPFontInfo>*/ fontInfoList) {
- this.eventBroadcaster = eventBroadcaster;
+ public AFPFontCollection(EventBroadcaster eventBroadcaster, List<AFPFontInfo> fontInfoList) {
+ this.eventProducer = AFPEventProducer.Provider.get(eventBroadcaster);
this.fontInfoList = fontInfoList;
}
/** {@inheritDoc} */
public int setup(int start, FontInfo fontInfo) {
int num = 1;
- AFPEventProducer eventProducer = AFPEventProducer.Provider.get(eventBroadcaster);
if (fontInfoList != null && fontInfoList.size() > 0) {
- for (Iterator it = fontInfoList.iterator(); it.hasNext();) {
- AFPFontInfo afpFontInfo = (AFPFontInfo)it.next();
+ for (AFPFontInfo afpFontInfo : fontInfoList) {
AFPFont afpFont = afpFontInfo.getAFPFont();
- List/*<FontTriplet>*/ tripletList = afpFontInfo.getFontTriplets();
- for (Iterator it2 = tripletList.iterator(); it2.hasNext();) {
- FontTriplet triplet = (FontTriplet)it2.next();
+ List<FontTriplet> tripletList = afpFontInfo.getFontTriplets();
+ for (FontTriplet triplet : tripletList) {
fontInfo.addMetrics("F" + num, afpFont);
fontInfo.addFontProperties("F" + num,
triplet.getName(), triplet.getStyle(), triplet.getWeight());
num++;
}
}
- checkDefaultFontAvailable(fontInfo, eventProducer,
- Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
- checkDefaultFontAvailable(fontInfo, eventProducer,
- Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
- checkDefaultFontAvailable(fontInfo, eventProducer,
- Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
- checkDefaultFontAvailable(fontInfo, eventProducer,
- Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+ checkDefaultFontAvailable(fontInfo, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ checkDefaultFontAvailable(fontInfo, Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ checkDefaultFontAvailable(fontInfo, Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ checkDefaultFontAvailable(fontInfo, Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
} else {
eventProducer.warnDefaultFontSetup(this);
// Go with a default base 12 configuration for AFP environments
- FontCollection base12FontCollection = new AFPBase12FontCollection();
+ FontCollection base12FontCollection = new AFPBase12FontCollection(eventProducer);
num = base12FontCollection.setup(num, fontInfo);
}
return num;
}
- private void checkDefaultFontAvailable(FontInfo fontInfo, AFPEventProducer eventProducer,
- String style, int weight) {
+ private void checkDefaultFontAvailable(FontInfo fontInfo, String style, int weight) {
if (!fontInfo.hasFont("any", style, weight)) {
eventProducer.warnMissingDefaultFont(this, style, weight);
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java Thu Apr 5 16:19:19 2012
@@ -21,6 +21,8 @@ package org.apache.fop.afp.fonts;
import java.util.List;
+import org.apache.fop.fonts.FontTriplet;
+
/**
* FontInfo contains meta information on fonts
@@ -28,7 +30,7 @@ import java.util.List;
public class AFPFontInfo {
private AFPFont font;
- private List/*<FontTriplet>*/ tripletList;
+ private List<FontTriplet> tripletList;
/**
* Main constructor
@@ -36,7 +38,7 @@ public class AFPFontInfo {
* @param afpFont The AFP Font
* @param tripletList List of font triplets to associate with this font
*/
- public AFPFontInfo(AFPFont afpFont, List/*<FontTriplet>*/ tripletList) {
+ public AFPFontInfo(AFPFont afpFont, List<FontTriplet> tripletList) {
this.font = afpFont;
this.tripletList = tripletList;
}
@@ -55,7 +57,7 @@ public class AFPFontInfo {
*
* @return List of font triplets
*/
- public List/*<FontTriplet>*/ getFontTriplets() {
+ public List<FontTriplet> getFontTriplets() {
return tripletList;
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPPageFonts.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPPageFonts.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPPageFonts.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AFPPageFonts.java Thu Apr 5 16:19:19 2012
@@ -61,4 +61,4 @@ public class AFPPageFonts extends java.u
}
return afpFontAttributes;
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java Thu Apr 5 16:19:19 2012
@@ -174,4 +174,4 @@ public abstract class AbstractOutlineFon
return charSet.getEncoding();
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSet.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSet.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSet.java Thu Apr 5 16:19:19 2012
@@ -19,23 +19,18 @@
package org.apache.fop.afp.fonts;
-import java.io.File;
import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CodingErrorAction;
-import java.nio.charset.UnsupportedCharsetException;
+import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.afp.AFPConstants;
+import org.apache.fop.afp.AFPEventProducer;
+import org.apache.fop.afp.fonts.CharactersetEncoder.EncodedChars;
import org.apache.fop.afp.util.ResourceAccessor;
-import org.apache.fop.afp.util.SimpleResourceAccessor;
import org.apache.fop.afp.util.StringUtils;
/**
@@ -70,59 +65,46 @@ public class CharacterSet {
/** The code page to which the character set relates */
- protected String codePage;
+ protected final String codePage;
/** The encoding used for the code page */
- protected String encoding;
+ protected final String encoding;
- /** The charset encoder corresponding to this encoding */
- private CharsetEncoder encoder;
+ /** The characterset encoder corresponding to this encoding */
+ private final CharactersetEncoder encoder;
/** The character set relating to the font */
- protected String name;
+ protected final String name;
/** The path to the installed fonts */
- private ResourceAccessor accessor;
+ private final ResourceAccessor accessor;
/** The current orientation (currently only 0 is supported by FOP) */
private final String currentOrientation = "0";
/** The collection of objects for each orientation */
- private Map characterSetOrientations = null;
+ private final Map<String, CharacterSetOrientation> characterSetOrientations;
/** The nominal vertical size (in millipoints) for bitmap fonts. 0 for outline fonts. */
- private int nominalVerticalSize = 0;
+ private int nominalVerticalSize;
/**
- * Constructor for the CharacterSetMetric object, the character set is used
- * to load the font information from the actual AFP font.
- *
- * @param codePage the code page identifier
- * @param encoding the encoding of the font
- * @param name the character set name
- * @param path the path to the installed afp fonts
- * @deprecated Please use
- * {@link #CharacterSet(String, String, String, ResourceAccessor)} instead.
- */
- public CharacterSet(String codePage, String encoding, String name, String path) {
- this(codePage, encoding, name,
- new SimpleResourceAccessor(path != null ? new File(path) : null));
- }
-
- /**
- * Constructor for the CharacterSetMetric object, the character set is used
- * to load the font information from the actual AFP font.
+ * Constructor for the CharacterSetMetric object, the character set is used to load the font
+ * information from the actual AFP font.
*
* @param codePage the code page identifier
* @param encoding the encoding of the font
+ * @param isEBDCS if this is an EBCDIC double byte character set.
* @param name the character set name
* @param accessor the resource accessor to load resource with
+ * @param eventProducer for handling AFP related events
*/
- CharacterSet(String codePage, String encoding, String name, ResourceAccessor accessor) {
+ CharacterSet(String codePage, String encoding, boolean isEBDCS, String name,
+ ResourceAccessor accessor, AFPEventProducer eventProducer) {
if (name.length() > MAX_NAME_LEN) {
String msg = "Character set name '" + name + "' must be a maximum of "
+ MAX_NAME_LEN + " characters";
- LOG.error("Constructor:: " + msg);
+ eventProducer.characterSetNameInvalid(this, msg);
throw new IllegalArgumentException(msg);
}
@@ -133,17 +115,10 @@ public class CharacterSet {
}
this.codePage = codePage;
this.encoding = encoding;
- try {
- this.encoder = Charset.forName(encoding).newEncoder();
- this.encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
- } catch (UnsupportedCharsetException uce) {
- //No nio-capable encoder available
- //This may happen with "Cp500" on Sun Java 1.4.2
- this.encoder = null;
- }
+ this.encoder = CharactersetEncoder.newInstance(encoding, isEBDCS);
this.accessor = accessor;
- this.characterSetOrientations = new java.util.HashMap(4);
+ this.characterSetOrientations = new HashMap<String, CharacterSetOrientation>(4);
}
/**
@@ -152,9 +127,7 @@ public class CharacterSet {
* @param cso the metrics for the orientation
*/
public void addCharacterSetOrientation(CharacterSetOrientation cso) {
- characterSetOrientations.put(
- String.valueOf(cso.getOrientation()),
- cso);
+ characterSetOrientations.put(String.valueOf(cso.getOrientation()), cso);
}
/**
@@ -357,32 +330,8 @@ public class CharacterSet {
* @return the encoded characters
* @throws CharacterCodingException if the encoding operation fails
*/
- public byte[] encodeChars(CharSequence chars) throws CharacterCodingException {
- if (encoder != null) {
- ByteBuffer bb;
- // encode method is not thread safe
- synchronized (encoder) {
- bb = encoder.encode(CharBuffer.wrap(chars));
- }
- if (bb.hasArray()) {
- return bb.array();
- } else {
- bb.rewind();
- byte[] bytes = new byte[bb.remaining()];
- bb.get(bytes);
- return bytes;
- }
- } else {
- //Sun Java 1.4.2 compatibility
- byte[] bytes;
- try {
- bytes = chars.toString().getBytes(this.encoding);
- return bytes;
- } catch (UnsupportedEncodingException uee) {
- throw new UnsupportedOperationException(
- "Unsupported encoding: " + uee.getMessage());
- }
- }
+ public EncodedChars encodeChars(CharSequence chars) throws CharacterCodingException {
+ return encoder.encode(chars);
}
/**
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java Thu Apr 5 16:19:19 2012
@@ -24,6 +24,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
@@ -34,6 +37,7 @@ import org.apache.commons.logging.LogFac
import org.apache.xmlgraphics.image.loader.util.SoftMapCache;
import org.apache.fop.afp.AFPConstants;
+import org.apache.fop.afp.AFPEventProducer;
import org.apache.fop.afp.util.ResourceAccessor;
import org.apache.fop.afp.util.StructuredFieldReader;
import org.apache.fop.fonts.Typeface;
@@ -58,7 +62,7 @@ import org.apache.fop.fonts.Typeface;
* formatted object. <p/>
*
*/
-public class CharacterSetBuilder {
+public abstract class CharacterSetBuilder {
/**
* Static logging instance
@@ -66,11 +70,6 @@ public class CharacterSetBuilder {
protected static final Log LOG = LogFactory.getLog(CharacterSetBuilder.class);
/**
- * Singleton reference
- */
- private static CharacterSetBuilder instance;
-
- /**
* Template used to convert lists to arrays.
*/
private static final CharacterSetOrientation[] EMPTY_CSO_ARRAY = new CharacterSetOrientation[0];
@@ -106,8 +105,8 @@ public class CharacterSetBuilder {
/**
* The collection of code pages
*/
- private final Map/*<String, Map<String, String>>*/ codePagesCache
- = new WeakHashMap/*<String, Map<String, String>>*/();
+ private final Map<String, Map<String, String>> codePagesCache
+ = Collections.synchronizedMap(new WeakHashMap<String, Map<String, String>>());
/**
* Cache of charactersets
@@ -115,18 +114,15 @@ public class CharacterSetBuilder {
private final SoftMapCache characterSetsCache = new SoftMapCache(true);
/** Default constructor. */
- protected CharacterSetBuilder() {
+ private CharacterSetBuilder() {
}
/**
* Factory method for the single-byte implementation of AFPFontReader.
* @return AFPFontReader
*/
- public static CharacterSetBuilder getInstance() {
- if (instance == null) {
- instance = new CharacterSetBuilder();
- }
- return instance;
+ public static CharacterSetBuilder getSingleByteInstance() {
+ return SingleByteLoader.getInstance();
}
/**
@@ -134,7 +130,7 @@ public class CharacterSetBuilder {
* @return AFPFontReader
*/
public static CharacterSetBuilder getDoubleByteInstance() {
- return new DoubleByteLoader();
+ return DoubleByteLoader.getInstance();
}
@@ -143,11 +139,13 @@ public class CharacterSetBuilder {
*
* * @param accessor the resource accessor
* @param filename the file name
+ * @param eventProducer for handling AFP related events
* @return an inputStream
*
* @throws IOException in the event that an I/O exception of some sort has occurred
*/
- protected InputStream openInputStream(ResourceAccessor accessor, String filename)
+ protected InputStream openInputStream(ResourceAccessor accessor, String filename,
+ AFPEventProducer eventProducer)
throws IOException {
URI uri;
try {
@@ -181,30 +179,76 @@ public class CharacterSetBuilder {
}
/**
- * Load the font details and metrics into the CharacterSetMetric object,
- * this will use the actual afp code page and character set files to load
- * the object with the necessary metrics.
+ * Load the font details and metrics into the CharacterSetMetric object, this will use the
+ * actual afp code page and character set files to load the object with the necessary metrics.
+ *
* @param characterSetName name of the characterset
* @param codePageName name of the code page file
* @param encoding encoding name
* @param accessor used to load codepage and characterset
+ * @param eventProducer for handling AFP related events
* @return CharacterSet object
* @throws IOException if an I/O error occurs
*/
- public CharacterSet build(String characterSetName, String codePageName,
- String encoding, ResourceAccessor accessor) throws IOException {
+ public CharacterSet build(String characterSetName, String codePageName, String encoding,
+ ResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
+ return processFont(characterSetName, codePageName, encoding, false, accessor,
+ eventProducer);
+ }
+
+ /**
+ * Load the font details and metrics into the CharacterSetMetric object, this will use the
+ * actual afp code page and character set files to load the object with the necessary metrics.
+ * This method is to be used for double byte character sets (DBCS).
+ *
+ * @param characterSetName name of the characterset
+ * @param codePageName name of the code page file
+ * @param encoding encoding name
+ * @param isEDBCS if this is an EBCDIC double byte character set (DBCS)
+ * @param accessor used to load codepage and characterset
+ * @param eventProducer for handling AFP related events
+ * @return CharacterSet object
+ * @throws IOException if an I/O error occurs
+ */
+ public CharacterSet buildDBCS(String characterSetName, String codePageName, String encoding,
+ boolean isEDBCS, ResourceAccessor accessor, AFPEventProducer eventProducer)
+ throws IOException {
+ return processFont(characterSetName, codePageName, encoding, isEDBCS, accessor,
+ eventProducer);
+ }
+
+ /**
+ * Load the font details and metrics into the CharacterSetMetric object, this will use the
+ * actual afp code page and character set files to load the object with the necessary metrics.
+ *
+ * @param characterSetName the CharacterSetMetric object to populate
+ * @param codePageName the name of the code page to use
+ * @param encoding name of the encoding in use
+ * @param typeface base14 font name
+ * @param eventProducer for handling AFP related events
+ * @return CharacterSet object
+ * @throws IOException if an I/O error occurs
+ */
+ public CharacterSet build(String characterSetName, String codePageName, String encoding,
+ Typeface typeface, AFPEventProducer eventProducer) throws IOException {
+ return new FopCharacterSet(codePageName, encoding, characterSetName, typeface,
+ eventProducer);
+ }
+ private CharacterSet processFont(String characterSetName, String codePageName, String encoding,
+ boolean isEDBCS, ResourceAccessor accessor, AFPEventProducer eventProducer)
+ throws IOException {
// check for cached version of the characterset
String descriptor = characterSetName + "_" + encoding + "_" + codePageName;
- CharacterSet characterSet = (CharacterSet)characterSetsCache.get(descriptor);
+ CharacterSet characterSet = (CharacterSet) characterSetsCache.get(descriptor);
if (characterSet != null) {
return characterSet;
}
// characterset not in the cache, so recreating
- characterSet = new CharacterSet(
- codePageName, encoding, characterSetName, accessor);
+ characterSet = new CharacterSet(codePageName, encoding, isEDBCS, characterSetName,
+ accessor, eventProducer);
InputStream inputStream = null;
@@ -215,16 +259,17 @@ public class CharacterSetBuilder {
* information to map the unicode character id to the graphic
* chracter global identifier.
*/
-
- Map/*<String,String>*/ codePage
- = (Map/*<String,String>*/)codePagesCache.get(codePageName);
-
- if (codePage == null) {
- codePage = loadCodePage(codePageName, encoding, accessor);
- codePagesCache.put(codePageName, codePage);
+ Map<String, String> codePage;
+ synchronized (codePagesCache) {
+ codePage = codePagesCache.get(codePageName);
+
+ if (codePage == null) {
+ codePage = loadCodePage(codePageName, encoding, accessor, eventProducer);
+ codePagesCache.put(codePageName, codePage);
+ }
}
- inputStream = openInputStream(accessor, characterSetName);
+ inputStream = openInputStream(accessor, characterSetName, eventProducer);
StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream);
@@ -268,23 +313,6 @@ public class CharacterSetBuilder {
}
characterSetsCache.put(descriptor, characterSet);
return characterSet;
-
- }
-
- /**
- * Load the font details and metrics into the CharacterSetMetric object,
- * this will use the actual afp code page and character set files to load
- * the object with the necessary metrics.
- *
- * @param characterSetName the CharacterSetMetric object to populate
- * @param codePageName the name of the code page to use
- * @param encoding name of the encoding in use
- * @param typeface base14 font name
- * @return CharacterSet object
- */
- public CharacterSet build(String characterSetName, String codePageName,
- String encoding, Typeface typeface) {
- return new FopCharacterSet(codePageName, encoding, characterSetName, typeface);
}
/**
@@ -296,18 +324,19 @@ public class CharacterSetBuilder {
* @param encoding
* the encoding to use for the character decoding
* @param accessor the resource accessor
+ * @param eventProducer for handling AFP related events
* @return a code page mapping (key: GCGID, value: Unicode character)
* @throws IOException if an I/O exception of some sort has occurred.
*/
- protected Map/*<String,String>*/ loadCodePage(String codePage, String encoding,
- ResourceAccessor accessor) throws IOException {
+ protected Map<String, String> loadCodePage(String codePage, String encoding,
+ ResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
// Create the HashMap to store code page information
- Map/*<String,String>*/ codePages = new java.util.HashMap/*<String,String>*/();
+ Map<String, String> codePages = new HashMap<String, String>();
InputStream inputStream = null;
try {
- inputStream = openInputStream(accessor, codePage.trim());
+ inputStream = openInputStream(accessor, codePage.trim(), eventProducer);
StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream);
byte[] data = structuredFieldReader.getNext(CHARACTER_TABLE_SF);
@@ -338,6 +367,8 @@ public class CharacterSetBuilder {
position++;
}
}
+ } catch (FileNotFoundException e) {
+ eventProducer.codePageNotFound(this, e);
} finally {
closeInputStream(inputStream);
}
@@ -408,7 +439,7 @@ public class CharacterSetBuilder {
int position = 0;
byte[] fnoData = new byte[26];
- List orientations = new java.util.ArrayList();
+ List<CharacterSetOrientation> orientations = new ArrayList<CharacterSetOrientation>();
// Read data, ignoring bytes 0 - 2
for (int index = 3; index < data.length; index++) {
@@ -508,8 +539,8 @@ public class CharacterSetBuilder {
* @throws IOException if an I/O exception of some sort has occurred.
*/
protected void processFontIndex(StructuredFieldReader structuredFieldReader,
- CharacterSetOrientation cso, Map/*<String,String>*/ codepage,
- double metricNormalizationFactor)
+ CharacterSetOrientation cso, Map<String, String> codepage,
+ double metricNormalizationFactor)
throws IOException {
byte[] data = structuredFieldReader.getNext(FONT_INDEX_SF);
@@ -652,20 +683,42 @@ public class CharacterSetBuilder {
}
}
+ private static final class SingleByteLoader extends CharacterSetBuilder {
+
+ private static final SingleByteLoader INSTANCE = new SingleByteLoader();
+
+ private SingleByteLoader() {
+ super();
+ }
+
+ private static SingleByteLoader getInstance() {
+ return INSTANCE;
+ }
+ }
+
/**
* Double-byte (CID Keyed font (Type 0)) implementation of AFPFontReader.
*/
- private static class DoubleByteLoader extends CharacterSetBuilder {
+ private static final class DoubleByteLoader extends CharacterSetBuilder {
- protected Map/*<String,String>*/ loadCodePage(String codePage, String encoding,
- ResourceAccessor accessor) throws IOException {
+ private static final DoubleByteLoader INSTANCE = new DoubleByteLoader();
+
+ private DoubleByteLoader() {
+ }
+
+ static DoubleByteLoader getInstance() {
+ return INSTANCE;
+ }
+
+ protected Map<String, String> loadCodePage(String codePage, String encoding,
+ ResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
// Create the HashMap to store code page information
- Map/*<String,String>*/ codePages = new java.util.HashMap/*<String,String>*/();
+ Map<String, String> codePages = new HashMap<String, String>();
InputStream inputStream = null;
try {
- inputStream = openInputStream(accessor, codePage.trim());
+ inputStream = openInputStream(accessor, codePage.trim(), eventProducer);
StructuredFieldReader structuredFieldReader
= new StructuredFieldReader(inputStream);
@@ -695,13 +748,13 @@ public class CharacterSetBuilder {
AFPConstants.EBCIDIC_ENCODING);
String charString = new String(charBytes, encoding);
codePages.put(gcgiString, charString);
-
- }
- else {
+ } else {
position++;
}
}
}
+ } catch (FileNotFoundException e) {
+ eventProducer.codePageNotFound(this, e);
} finally {
closeInputStream(inputStream);
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java Thu Apr 5 16:19:19 2012
@@ -107,7 +107,7 @@ public class CharacterSetOrientation {
* a character rotation other than 0, ascender height loses its
* meaning when the character is lying on its side or is upside down
* with respect to normal viewing orientation. For the general case,
- * Ascender Height is the character�s most positive y-axis value.
+ * Ascender Height is the character's most positive y-axis value.
* For bounded character boxes, for a given character having an
* ascender, ascender height and baseline offset are equal.
* @return the ascender value in millipoints
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java Thu Apr 5 16:19:19 2012
@@ -19,6 +19,7 @@
package org.apache.fop.afp.fonts;
+import org.apache.fop.afp.AFPEventProducer;
import org.apache.fop.afp.util.ResourceAccessor;
import org.apache.fop.fonts.Typeface;
@@ -37,14 +38,11 @@ public class FopCharacterSet extends Cha
* @param encoding the encoding of the font
* @param name the character set name
* @param charSet the fop character set
+ * @param eventProducer for handling AFP related events
*/
- public FopCharacterSet(
- String codePage,
- String encoding,
- String name,
- Typeface charSet) {
-
- super(codePage, encoding, name, (ResourceAccessor)null);
+ public FopCharacterSet(String codePage, String encoding, String name, Typeface charSet,
+ AFPEventProducer eventProducer) {
+ super(codePage, encoding, false, name, (ResourceAccessor) null, eventProducer);
this.charSet = charSet;
}
@@ -55,7 +53,7 @@ public class FopCharacterSet extends Cha
* a character rotation other than 0, ascender height loses its
* meaning when the character is lying on its side or is upside down
* with respect to normal viewing orientation. For the general case,
- * Ascender Height is the character�s most positive y-axis value.
+ * Ascender Height is the character's most positive y-axis value.
* For bounded character boxes, for a given character having an
* ascender, ascender height and baseline offset are equal.
* @return the ascender value in millipoints
@@ -135,4 +133,4 @@ public class FopCharacterSet extends Cha
return charSet.mapChar(c);
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/OutlineFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/OutlineFont.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/OutlineFont.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/OutlineFont.java Thu Apr 5 16:19:19 2012
@@ -33,4 +33,4 @@ public class OutlineFont extends Abstrac
super(name, charSet);
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/RasterFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/RasterFont.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/RasterFont.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/fonts/RasterFont.java Thu Apr 5 16:19:19 2012
@@ -70,14 +70,14 @@ public class RasterFont extends AFPFont
/**
* Get the character set metrics for the specified point size.
*
- * @param size the point size (in mpt)
+ * @param sizeInMpt the point size (in mpt)
* @return the character set metrics
*/
- public CharacterSet getCharacterSet(int size) {
+ public CharacterSet getCharacterSet(int sizeInMpt) {
- //TODO: replace with Integer.valueOf() once we switch to Java 5
- Integer requestedSize = new Integer(size);
+ Integer requestedSize = Integer.valueOf(sizeInMpt);
CharacterSet csm = (CharacterSet) charSets.get(requestedSize);
+ double sizeInPt = sizeInMpt / 1000.0;
if (csm != null) {
return csm;
@@ -101,10 +101,10 @@ public class RasterFont extends AFPFont
Integer fontSize;
if (!smallerSizes.isEmpty()
- && (size - smallerSize) <= (largerSize - size)) {
- fontSize = new Integer(smallerSize);
+ && (sizeInMpt - smallerSize) <= (largerSize - sizeInMpt)) {
+ fontSize = Integer.valueOf(smallerSize);
} else {
- fontSize = new Integer(largerSize);
+ fontSize = Integer.valueOf(largerSize);
}
csm = (CharacterSet) charSets.get(fontSize);
@@ -115,16 +115,18 @@ public class RasterFont extends AFPFont
substitutionCharSets = new HashMap();
}
substitutionCharSets.put(requestedSize, csm);
- String msg = "No " + (size / 1000f) + "pt font " + getFontName()
- + " found, substituted with " + fontSize.intValue() / 1000f + "pt font";
- LOG.warn(msg);
+ // do not output the warning if the font size is closer to an integer less than 0.1
+ if (!(Math.abs(fontSize.intValue() / 1000.0 - sizeInPt) < 0.1)) {
+ String msg = "No " + sizeInPt + "pt font " + getFontName()
+ + " found, substituted with " + fontSize.intValue() / 1000f + "pt font";
+ LOG.warn(msg);
+ }
}
}
if (csm == null) {
// Still no match -> error
- String msg = "No font found for font " + getFontName()
- + " with point size " + size / 1000f;
+ String msg = "No font found for font " + getFontName() + " with point size " + sizeInPt;
LOG.error(msg);
throw new FontRuntimeException(msg);
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java Thu Apr 5 16:19:19 2012
@@ -147,4 +147,4 @@ public abstract class AbstractGraphicsCo
protected boolean isRelative() {
return this.relative;
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsBox.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsBox.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsBox.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsBox.java Thu Apr 5 16:19:19 2012
@@ -60,4 +60,4 @@ public final class GraphicsBox extends A
os.write(data);
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java Thu Apr 5 16:19:19 2012
@@ -33,6 +33,8 @@ public final class GraphicsChainedSegmen
protected static final int MAX_DATA_LEN = 8192;
private byte[] predecessorNameBytes;
+ private boolean appended;
+ private boolean prologPresent;
/**
* Main constructor
@@ -41,7 +43,7 @@ public final class GraphicsChainedSegmen
* the name of this graphics segment
*/
public GraphicsChainedSegment(String name) {
- super(name);
+ this(name, null, false, false);
}
/**
@@ -51,24 +53,35 @@ public final class GraphicsChainedSegmen
* the name of this graphics segment
* @param predecessorNameBytes
* the name of the predecessor in this chain
+ * @param appended true if this segment is appended to the previous one
+ * @param prologPresent true if this segment starts with a prolog
*/
- public GraphicsChainedSegment(String name, byte[] predecessorNameBytes) {
+ public GraphicsChainedSegment(String name, byte[] predecessorNameBytes,
+ boolean appended, boolean prologPresent) {
super(name);
- this.predecessorNameBytes = predecessorNameBytes;
+ if (predecessorNameBytes != null) {
+ this.predecessorNameBytes = new byte[predecessorNameBytes.length];
+ System.arraycopy(predecessorNameBytes, 0,
+ this.predecessorNameBytes, 0, predecessorNameBytes.length);
+ }
+ this.appended = appended;
+ this.prologPresent = prologPresent;
}
/** {@inheritDoc} */
+ @Override
public int getDataLength() {
return 14 + super.getDataLength();
}
private static final byte APPEND_NEW_SEGMENT = 0;
-// private static final byte PROLOG = 4;
-// private static final byte APPEND_TO_EXISING = 48;
+ private static final byte APPEND_TO_EXISING = 6;
+ private static final byte PROLOG = 0x10;
private static final int NAME_LENGTH = 4;
/** {@inheritDoc} */
+ @Override
protected int getNameLength() {
return NAME_LENGTH;
}
@@ -78,6 +91,7 @@ public final class GraphicsChainedSegmen
}
/** {@inheritDoc} */
+ @Override
public void writeToStream(OutputStream os) throws IOException {
byte[] data = new byte[14];
data[0] = getOrderCode(); // BEGIN_SEGMENT
@@ -88,7 +102,12 @@ public final class GraphicsChainedSegmen
System.arraycopy(nameBytes, 0, data, 2, NAME_LENGTH);
data[6] = 0x00; // FLAG1 (ignored)
- data[7] = APPEND_NEW_SEGMENT;
+
+ //FLAG2
+ data[7] |= this.appended ? APPEND_TO_EXISING : APPEND_NEW_SEGMENT;
+ if (this.prologPresent) {
+ data[7] |= PROLOG;
+ }
int dataLength = super.getDataLength();
byte[] len = BinaryUtils.convert(dataLength, 2);
@@ -105,7 +124,8 @@ public final class GraphicsChainedSegmen
}
/** {@inheritDoc} */
+ @Override
public String toString() {
- return "GraphicsChainedSegment(name=" + super.getName() + ")";
+ return "GraphicsChainedSegment(name=" + super.getName() + ", len: " + getDataLength() + ")";
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java Thu Apr 5 16:19:19 2012
@@ -22,8 +22,9 @@ package org.apache.fop.afp.goca;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.nio.charset.CharacterCodingException;
-import org.apache.fop.afp.AFPConstants;
+import org.apache.fop.afp.fonts.CharacterSet;
/**
* A GOCA graphics string
@@ -34,7 +35,12 @@ public class GraphicsCharacterString ext
protected static final int MAX_STR_LEN = 255;
/** the string to draw */
- protected final String str;
+ private final String str;
+
+ /**
+ * The character set encoding to use
+ */
+ private final CharacterSet charSet;
/**
* Constructor (absolute positioning)
@@ -42,20 +48,12 @@ public class GraphicsCharacterString ext
* @param str the character string
* @param x the x coordinate
* @param y the y coordinate
+ * @param charSet the character set
*/
- public GraphicsCharacterString(String str, int x, int y) {
+ public GraphicsCharacterString(String str, int x, int y, CharacterSet charSet) {
super(x, y);
this.str = truncate(str, MAX_STR_LEN);
- }
-
- /**
- * Constructor (relative positioning)
- *
- * @param str the character string
- */
- public GraphicsCharacterString(String str) {
- super(null);
- this.str = truncate(str, MAX_STR_LEN);
+ this.charSet = charSet;
}
/** {@inheritDoc} */
@@ -84,9 +82,11 @@ public class GraphicsCharacterString ext
* Returns the text string as an encoded byte array
*
* @return the text string as an encoded byte array
+ * @throws UnsupportedEncodingException, CharacterCodingException
*/
- private byte[] getStringAsBytes() throws UnsupportedEncodingException {
- return str.getBytes(AFPConstants.EBCIDIC_ENCODING);
+ private byte[] getStringAsBytes() throws UnsupportedEncodingException,
+ CharacterCodingException {
+ return charSet.encodeChars(str).getBytes();
}
/** {@inheritDoc} */
@@ -95,4 +95,4 @@ public class GraphicsCharacterString ext
+ (coords != null ? "x=" + coords[0] + ", y=" + coords[1] : "")
+ "str='" + str + "'" + "}";
}
-}
\ No newline at end of file
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org