[FOray-commit] SF.net SVN: foray: [9692] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-06-02 22:44:23
|
Revision: 9692
http://svn.sourceforge.net/foray/?rev=9692&view=rev
Author: victormote
Date: 2007-06-02 15:44:25 -0700 (Sat, 02 Jun 2007)
Log Message:
-----------
1. Conform to axsl changes allowing suppression of kerning.
2. Use new methods to suppress kerning for dot leaders.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/ExternalGraphicArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/ForeignObjectArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/InlineArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/InlineContainerArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java
trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/ExternalGraphicArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/ExternalGraphicArea.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/ExternalGraphicArea.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -215,4 +215,12 @@
return 0;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean kern() {
+ /* Kerning is not applicable for this inline element. */
+ return true;
+ }
+
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/ForeignObjectArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/ForeignObjectArea.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/ForeignObjectArea.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -224,4 +224,12 @@
return 0;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean kern() {
+ /* Kerning is not applicable for this inline element. */
+ return true;
+ }
+
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/InlineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/InlineArea.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/InlineArea.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -287,4 +287,12 @@
return 0;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean kern() {
+ /* Kerning is not applicable for this inline element. */
+ return true;
+ }
+
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/InlineContainerArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/InlineContainerArea.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/InlineContainerArea.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -166,4 +166,12 @@
return 0;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean kern() {
+ /* Kerning is not applicable for this inline element. */
+ return true;
+ }
+
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -544,4 +544,19 @@
return (Leader) this.getLinkage().getFONode();
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean kern() {
+ if (this.traitLeaderPattern() == LeaderPattern.USE_CONTENT) {
+ return true;
+ }
+ /* This is meaningless for all other types except LeaderPattern.DOTS,
+ * For DOTS, we adjust the word spacing to handle the actual size of the
+ * space between the dots. If we left that intact, we would have to
+ * adjust the space more to compensate for any kerning, which would
+ * make no sense. */
+ return false;
+ }
+
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -183,4 +183,11 @@
return 0;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean kern() {
+ return true;
+ }
+
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -206,4 +206,11 @@
return 0;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean kern() {
+ return true;
+ }
+
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -159,4 +159,12 @@
return 0;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean kern() {
+ /* Kerning is not applicable for this inline element. */
+ return true;
+ }
+
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -786,4 +786,11 @@
return this.generatedBy;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean kern() {
+ return true;
+ }
+
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -128,13 +128,13 @@
/**
* {@inheritDoc}
*/
- public synchronized void drawText(final String text) {
+ public synchronized void drawText(final String text, final boolean kern) {
if (text.length() < 1) {
return;
}
openTextObject();
final PDFString pdfString = new PDFString(this.getPDFDocument(), text,
- this.getGS().getFont());
+ this.getGS().getFont(), kern);
add(pdfString.toPDF());
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -53,17 +53,23 @@
/** The Font that should be used to render this String. */
private PDFFont font;
+ /** Indicates whether the text in this string should be kerned or not. */
+ private boolean kerningActive;
+
/**
* Constructor.
* @param doc The parent PDF document.
* @param string The String being encapsulated.
* @param font The font in which this String should be written.
+ * @param kerningActive Indicates whether the text in this string should be
+ * kerned or not.
*/
public PDFString(final PDFDocument doc, final String string,
- final PDFFont font) {
+ final PDFFont font, final boolean kerningActive) {
super(doc);
this.theString = string;
this.font = font;
+ this.kerningActive = kerningActive;
}
/**
@@ -144,6 +150,9 @@
*/
private void addKerning(final Font font, final char char1, final char char2,
final StringBuilder buf) {
+ if (! this.kerningActive) {
+ return;
+ }
final int kernAmount = font.kern(char1, char2);
if (kernAmount == 0) {
return;
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -816,7 +816,8 @@
currentStream.write("1 0 0 -1 0 0 Tm ");
final PDFFont pdfFont = new PDFFont(this.pdfDoc, font);
- final PDFString pdfString = new PDFString(this.pdfDoc, s, pdfFont);
+ final PDFString pdfString = new PDFString(this.pdfDoc, s, pdfFont,
+ true);
final String outputString = pdfString.toPDF();
currentStream.write(outputString);
Modified: trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2007-06-02 22:06:43 UTC (rev 9691)
+++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2007-06-02 22:44:25 UTC (rev 9692)
@@ -325,7 +325,8 @@
if (newFont != currentFont) {
/* Font has changed. Write the text so far. */
final int size = i - startIndex;
- paintText(area, currentFont, text, startIndex, size);
+ paintText(area, currentFont, text, startIndex, size,
+ area.kern());
if (size > 0) {
startIndex = i;
}
@@ -334,7 +335,7 @@
}
if (startIndex < text.length) {
paintText(area, currentFont, text, startIndex,
- text.length - startIndex);
+ text.length - startIndex, area.kern());
}
}
@@ -388,9 +389,11 @@
* @param startIndex The starting index into <code>text</code> which should
* be rendered.
* @param size The size of <code>text</code> which should be rendered.
+ * @param kern Indicates whether the text should be kerned.
*/
private void paintText(final GeneralInlineArea area, final FontUse fontUse,
- final char[] text, final int startIndex, final int size) {
+ final char[] text, final int startIndex, final int size,
+ final boolean kern) {
if (size < 1) {
return;
}
@@ -400,7 +403,7 @@
/* Paint the text. */
final String textToWrite = new String(text, startIndex, size);
- getContentStream().drawText(textToWrite);
+ getContentStream().drawText(textToWrite, kern);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|