[FOray-commit] SF.net SVN: foray: [10215] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-09-28 19:46:44
|
Revision: 10215
http://foray.svn.sourceforge.net/foray/?rev=10215&view=rev
Author: victormote
Date: 2007-09-28 12:46:47 -0700 (Fri, 28 Sep 2007)
Log Message:
-----------
Add unimplemented test for centered text with word-spacing.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
Added Paths:
-----------
trunk/foray/resource/test/fo/block-004.fo
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-09-25 17:46:16 UTC (rev 10214)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-09-28 19:46:47 UTC (rev 10215)
@@ -218,6 +218,7 @@
/**
* Test of fo/block-003.fo.
+ * This is a test of simple centering of a text-area on a line.
* @throws FOrayException For errors creating the FO Tree or Area Tree.
*/
public void testBlock003() throws FOrayException {
@@ -256,11 +257,17 @@
assertTrue(node instanceof TextArea);
final TextArea textArea = (TextArea) node;
- /* The text is "Test of Centering". From the Helvetica AFM file, the
- * widths are as follows: T(611) + e(556) + s(500) + t(278) + space(278)
- * + o(556) + f(278) + space(278) + C(722) + e(556) + n(556) + t(278)
- * + e(556) + r(333) + i(222) + n(556) + g(556) = 7,670. If these are
- * scaled to 12 points, the millipoints used are 7670 * 12 = 92,040. */
+ /* The text is "Test of Centering".
+ * From the Helvetica AFM file, the widths are as follows:
+ * T(611) + e(556) + s(500) + t(278)
+ * + space(278)
+ * + o(556) + f(278)
+ * + space(278)
+ * + C(722) + e(556) + n(556) + t(278) + e(556) + r(333) + i(222)
+ * + n(556) + g(556)
+ * = 7,670.
+ * If these are scaled to 12 points, the millipoints used are 7670 * 12
+ * = 92,040. */
assertEquals(92040, textArea.crIpd());
/* The x value of the text area content rectangle should be at the x
@@ -275,4 +282,76 @@
assertEquals(718800, textArea.crOriginY());
}
+ /**
+ * Test of fo/block-004.fo.
+ * This is a test of centering of a text-area on a line, where the text-area
+ * has word-spacing = ".3em".
+ * @throws FOrayException For errors creating the FO Tree or Area Tree.
+ */
+ public void testBlock004() throws FOrayException {
+ final AreaTreeCreator creator = AreaTreeCreator.getInstance();
+ final AreaTree areaTree = creator.buildAreaTree(
+ "fo/block-004.fo");
+ final NormalFlowRA firstNormalFlowArea = this.getFirstNormalFlowArea(
+ areaTree);
+
+ /* Test location and dimensions of the block area. */
+ AreaNode node = firstNormalFlowArea.getChildAt(0);
+ assertTrue(node instanceof NormalBlockArea);
+ final NormalBlockArea blockArea = (NormalBlockArea) node;
+ /* 1 inch left margin. */
+ assertEquals(72000, blockArea.crOriginX());
+ /* 10 inches from bottom (11 inches high, 1 inch top margin). */
+ assertEquals(720000, blockArea.crOriginY());
+ /* Page is 8.5 inches wide, with 2 inches total margin.
+ * 6.5 * 72,000 = 468,000. */
+ assertEquals(468000, blockArea.crIpd());
+
+ /* Test location and dimensions of the line area. */
+ node = blockArea.getChildAt(0);
+ assertTrue(node instanceof LineArea);
+ final LineArea lineArea = (LineArea) node;
+ /* x same as the parent block. */
+ assertEquals(72000, lineArea.crOriginX());
+ /* y adjusted for half-leading = 12,000 * .2 * .5 = 1200. */
+ assertEquals(718800, lineArea.crOriginY());
+ /* ipd same as parent block. */
+ assertEquals(468000, lineArea.crIpd());
+
+ /* Test location and dimensions of the text area. The key thing we are
+ * testing here is that IT IS CENTERED. */
+ node = lineArea.getChildAt(0);
+ assertTrue(node instanceof TextArea);
+ final TextArea textArea = (TextArea) node;
+
+ /* The text is "Centered with Word Spacing".
+ * From the Helvetica AFM file, the widths are as follows:
+ * C(722) + e(556) + n(556) + t(278) + e(556) + r(333) + e(556) + d(556)
+ * + space(278)
+ * + w(722) + i(222) + t(278) + h(556)
+ * + space(278)
+ * + W(944) + o(556) + r(333) + d(556)
+ * + space(278)
+ * + S(556) + p(556) + a(556) + c(500) + i(222) + n(556) + g(556)
+ * = 12,616.
+ * If these are scaled to 12 points, the millipoints used are 12,616
+ * * 12 = 151,392.
+ * The extra word spacing is .3em = .3 * 12000 * 3 occurrences = 10,800.
+ * Total ipd of text-area = 151,392 + 10,800 = */
+
+ /* TODO: Turn these tests back on after the code has been fixed. */
+// assertEquals(162192, textArea.crIpd());
+
+ /* The x value of the text area content rectangle should be at the x
+ * location of the parent line area + 1/2 of the unused area in the
+ * line. Total line area ipd = 468,000. Unused line area ipd =
+ * 468,000 - 92,040 = 375,960. One half of the unused line area ipd =
+ * 187,980. x = 72,000 + 187,980 = 259,980. */
+// assertEquals(259980, textArea.crOriginX());
+
+ /* The y value of the text area content rectangle should be the same as
+ * the parent line area. */
+ assertEquals(718800, textArea.crOriginY());
+ }
+
}
Added: trunk/foray/resource/test/fo/block-004.fo
===================================================================
--- trunk/foray/resource/test/fo/block-004.fo (rev 0)
+++ trunk/foray/resource/test/fo/block-004.fo 2007-09-28 19:46:47 UTC (rev 10215)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+This fo tests centering of a text-area a line, where the text-area has word
+spacing.
+-->
+
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<fo:layout-master-set>
+ <fo:simple-page-master
+ master-name="simple"
+ page-height="11in"
+ page-width="8.5in"
+ margin-top="1in"
+ margin-bottom="1in"
+ margin-left="1in"
+ margin-right="1in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+</fo:layout-master-set>
+
+<fo:page-sequence master-reference="simple">
+<fo:flow flow-name="xsl-region-body">
+
+<fo:block font-family="sans-serif" font-size="12pt" text-align="center"
+word-spacing=".3em">Centered with Word Spacing</fo:block>
+
+</fo:flow>
+</fo:page-sequence>
+</fo:root>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|