foray-commit Mailing List for FOray (Page 32)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2023-01-30 10:21:33
|
Revision: 13100
http://sourceforge.net/p/foray/code/13100
Author: victormote
Date: 2023-01-30 10:21:30 +0000 (Mon, 30 Jan 2023)
Log Message:
-----------
Handle the last line in a paragraph specially, as it may be shorter than the full line width.
Modified Paths:
--------------
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2023-01-30 00:22:03 UTC (rev 13099)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2023-01-30 10:21:30 UTC (rev 13100)
@@ -269,6 +269,11 @@
final int idealGlueSize = getIdealGlueWidth(content, context, lineIndex);
final int totalAdjustment = totalGlueSize - idealGlueSize;
if (totalAdjustment > 0) {
+ if (lineIndex == lineBreakList.size() - 1) {
+ /* If it is the last line and there is more glue than needed, the actual length of the line is shorter
+ * than the capacity of the line, and the ideal glue size should be used in all cases. */
+ return 0;
+ }
final int totalStretchability = getGlueWidthStretchability(content, context, lineIndex);
return (float) totalAdjustment / (float) totalStretchability;
} else if (totalAdjustment < idealGlueSize) {
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-30 00:22:03 UTC (rev 13099)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-30 10:21:30 UTC (rev 13100)
@@ -61,8 +61,8 @@
assertEquals(expectedBreakPosition, lineBreak.getBreakPosition());
final int qtyInterwordGlue = actual.getQtyInterwordGlue(content, context, lineIndex);
assertEquals(expectedQtyInterwordGlue, qtyInterwordGlue);
-// final float r = actual.getAdjustmentRatio(content, context, lineIndex);
-// assertEquals(expectedAdjustment, r, .0005);
+ final float r = actual.getAdjustmentRatio(content, context, lineIndex);
+ assertEquals(expectedAdjustment, r, .0005);
}
/**
@@ -115,7 +115,11 @@
assertLineBreak(para, kpContext, actual, 8, 390_000, 209, 10, .700f); // of the cool
assertLineBreak(para, kpContext, actual, 9, 390_000, 230, 8, 1.360f); // she took a
assertLineBreak(para, kpContext, actual, 10, 390_000, 254, 10, -.650f); // and caught it;
- assertLineBreak(para, kpContext, actual, 11, 390_000, 276, 6, .001f); // play-thing.
+ /* The adjustment ratio recorded in "Knuth, Digital Typography," p. 74
+ * for the next line is .001. We think that by definition that amount
+ * must be 0, that some rounding error must have caused that result.
+ * We have adjusted the following line accordingly. */
+ assertLineBreak(para, kpContext, actual, 11, 390_000, 276, 6, .000f); // play-thing.
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-30 00:22:06
|
Revision: 13099
http://sourceforge.net/p/foray/code/13099
Author: victormote
Date: 2023-01-30 00:22:03 +0000 (Mon, 30 Jan 2023)
Log Message:
-----------
Improvements to computation of adjustment ratio.
Modified Paths:
--------------
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2023-01-29 20:37:07 UTC (rev 13098)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2023-01-30 00:22:03 UTC (rev 13099)
@@ -151,15 +151,15 @@
break;
}
case IDEAL_WIDTH: {
- accumulator += context.getIdealWidth(leaf);
+ accumulator += leaf.getIdealWidth(context);
break;
}
case STRETCHABILITY: {
- accumulator += context.getStretchability(leaf);
+ accumulator += leaf.getStretchability(context);
break;
}
case SHRINKABILITY: {
- accumulator += context.getShrinkability(leaf);
+ accumulator += leaf.getShrinkability(context);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-29 20:37:09
|
Revision: 13098
http://sourceforge.net/p/foray/code/13098
Author: victormote
Date: 2023-01-29 20:37:07 +0000 (Sun, 29 Jan 2023)
Log Message:
-----------
Improvements to testing of KP adjustment values.
Modified Paths:
--------------
trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
Modified: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java
===================================================================
--- trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-28 12:43:10 UTC (rev 13097)
+++ trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-29 20:37:07 UTC (rev 13098)
@@ -50,7 +50,7 @@
public MockMonotypeFont(final boolean adjustToKnuthPlass) {
setCharSet(CharSetExtendedRoman.getInstance());
- /* It is unclear from the table in the Monotype manual what the width of a "normal" space is. Knuth uses 6 in
+ /* It is unclear from Figure 18 in the Monotype manual what the width of a "normal" space is. Knuth uses 6 in
* most cases, but 8 after a period. Since there is no space character in the 8-unit row, we assume that the
* correct value is 6. */
setWidth(' ', 6);
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2023-01-28 12:43:10 UTC (rev 13097)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2023-01-29 20:37:07 UTC (rev 13098)
@@ -28,8 +28,11 @@
package org.foray.linebreak;
+import org.axsl.kp.KpBox;
import org.axsl.kp.KpBranch;
+import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpPenalty;
import org.axsl.kp.KpResult;
import java.util.ArrayList;
@@ -42,6 +45,23 @@
*/
public class LineBreakResult4a implements KpResult {
+ /**
+ * Enumeration of the possible interword glue computations.
+ */
+ private enum GlueComputation {
+ /** Count the number of interword glue instances. */
+ COUNT,
+
+ /** Compute the total ideal width of the interword glue instances. */
+ IDEAL_WIDTH,
+
+ /** Compute the total stretchability of the interword glue instances. */
+ STRETCHABILITY,
+
+ /** Compute the total shrinkability of the interword glue instances. */
+ SHRINKABILITY
+ }
+
/** Result suitable for cases where an empty result should be returned. */
public static final LineBreakResult4a EMPTY_RESULT = new LineBreakResult4a(0) {
@@ -98,14 +118,17 @@
}
/**
- * Count the number of non-adjacent glue leaves for a given line, disregarding any at the beginning or end of the
+ * Iterate over the non-adjacent glue leaves for a given line, disregarding any at the beginning or end of the
* content.
- * Adjacent glue leaves are counted as one glue leaf because there is only one effective interword glue item.
* @param content The content which has been broken into lines.
+ * @param context The context for the width computations.
* @param lineIndex The index to the line being queried.
- * @return The number of non-adjacent interword glue leaves.
+ * @param whichComputation Indicates what value is to be computed by the iteration.
+ * @return Either the total ideal width or total count of the non-adjacent interword glue leaves, depending on
+ * {@code accumulatingWidth}.
*/
- public int getQtyInterwordGlue(final KpBranch content, final int lineIndex) {
+ private int iterateInterwordGlue(final KpBranch content, final KpContext context, final int lineIndex,
+ final GlueComputation whichComputation) {
/* Don't count any glue items until we have hit at least one box item. After that count only the glue items that
* are immediately followed by a box item. */
final int startLeafIndex = lineIndex > 0 ? getBreakPosition(lineIndex - 1) : 0;
@@ -112,8 +135,7 @@
final int endLeafIndex = getBreakPosition(lineIndex);
boolean anyBoxes = false;
-
- int count = 0;
+ int accumulator = 0;
/* Skip the last leaf. It cannot be followed by a box. */
for (int index = startLeafIndex; index < endLeafIndex - 1; index++) {
final KpLeaf leaf = content.kpLeafAt(index);
@@ -123,11 +145,139 @@
&& leaf.getKpLeafType() == KpLeaf.Type.GLUE) {
final KpLeaf next = content.kpLeafAt(index + 1);
if (next.getKpLeafType() == KpLeaf.Type.BOX) {
- count ++;
+ switch (whichComputation) {
+ case COUNT: {
+ accumulator ++;
+ break;
+ }
+ case IDEAL_WIDTH: {
+ accumulator += context.getIdealWidth(leaf);
+ break;
+ }
+ case STRETCHABILITY: {
+ accumulator += context.getStretchability(leaf);
+ break;
+ }
+ case SHRINKABILITY: {
+ accumulator += context.getShrinkability(leaf);
+ }
+ }
}
}
}
- return count;
+ return accumulator;
}
+ /**
+ * Count the number of non-adjacent glue leaves for a given line, disregarding any at the beginning or end of the
+ * content.
+ * Adjacent glue leaves are counted as one glue leaf because there is only one effective interword glue item.
+ * @param content The content which has been broken into lines.
+ * @param context The context for the width computations.
+ * @param lineIndex The index to the line being queried.
+ * @return The number of non-adjacent interword glue leaves.
+ */
+ public int getQtyInterwordGlue(final KpBranch content, final KpContext context, final int lineIndex) {
+ return iterateInterwordGlue(content, context, lineIndex, GlueComputation.COUNT);
+ }
+
+ /**
+ * Computes the total amount of ideal interword glue width for a given line, disregarding any at the beginning or
+ * end of the content.
+ * Adjacent glue leaves are counted as one glue leaf because there is only one effective interword glue item.
+ * @param content The content which has been broken into lines.
+ * @param context The context for the width computations.
+ * @param lineIndex The index to the line being queried.
+ * @return The number of non-adjacent interword glue leaves.
+ */
+ public int getIdealGlueWidth(final KpBranch content, final KpContext context, final int lineIndex) {
+ return iterateInterwordGlue(content, context, lineIndex, GlueComputation.IDEAL_WIDTH);
+ }
+
+ /**
+ * Computes the total amount of interword glue stretchability for a given line, disregarding any at the beginning
+ * or end of the content.
+ * Adjacent glue leaves are counted as one glue leaf because there is only one effective interword glue item.
+ * @param content The content which has been broken into lines.
+ * @param context The context for the width computations.
+ * @param lineIndex The index to the line being queried.
+ * @return The number of non-adjacent interword glue leaves.
+ */
+ public int getGlueWidthStretchability(final KpBranch content, final KpContext context, final int lineIndex) {
+ return iterateInterwordGlue(content, context, lineIndex, GlueComputation.STRETCHABILITY);
+ }
+
+ /**
+ * Computes the total amount of interword glue shrinkability for a given line, disregarding any at the beginning
+ * or end of the content.
+ * Adjacent glue leaves are counted as one glue leaf because there is only one effective interword glue item.
+ * @param content The content which has been broken into lines.
+ * @param context The context for the width computations.
+ * @param lineIndex The index to the line being queried.
+ * @return The number of non-adjacent interword glue leaves.
+ */
+ public int getGlueWidthShrinkability(final KpBranch content, final KpContext context, final int lineIndex) {
+ return iterateInterwordGlue(content, context, lineIndex, GlueComputation.SHRINKABILITY);
+ }
+
+
+ /**
+ * Returns the sum of the ideal widths of the box content on a given line.
+ * @param content The content being evaluated.
+ * @param context The context for the width computations.
+ * @param lineIndex The index to the line being queried.
+ * @return The sum of the ideal widths of all {@link KpLeaf.Type#BOX} items on the line.
+ */
+ public int getIdealBoxWidth(final KpBranch content, final KpContext context, final int lineIndex) {
+ final int startLeafIndex = lineIndex > 0 ? getBreakPosition(lineIndex - 1) : 0;
+ final int endLeafIndex = getBreakPosition(lineIndex);
+ int width = 0;
+ for (int index = startLeafIndex; index < endLeafIndex; index++) {
+ final KpBox box = KpLeaf.Type.asBox(content.kpLeafAt(index));
+ if (box != null) {
+ width += box.getIdealWidth(context);
+ }
+ }
+ return width;
+ }
+
+ /**
+ * Returns the width of any penalty that ends a given line.
+ * @param content The content being evaluated.
+ * @param context The context for the width computations.
+ * @param lineIndex The index to the line being queried.
+ * @return The width of any penalty that ends the line at {@code lineIndex}.
+ */
+ public int getPenaltyWidth(final KpBranch content, final KpContext context, final int lineIndex) {
+ final int endLeafIndex = getBreakPosition(lineIndex);
+ final KpPenalty penalty = KpLeaf.Type.asPenalty(content.kpLeafAt(endLeafIndex - 1));
+ return penalty == null ? 0 : penalty.getPenaltyWidth(context);
+ }
+
+ /**
+ * Computes the <em>adjustment ratio</em> for a given line.
+ * @param content The content being evaluated.
+ * @param context The context for the width computations.
+ * @param lineIndex The index to the line being queried.
+ * @return The adjustment ratio for line {@code lineIndex}.
+ * @see "Digital Typography, Knuth, 1999, p. 76, Desirability Criteria."
+ */
+ public float getAdjustmentRatio(final KpBranch content, final KpContext context, final int lineIndex) {
+ int totalGlueSize = getLineLength(lineIndex);
+ totalGlueSize -= getIdealBoxWidth(content, context, lineIndex);
+ totalGlueSize -= getPenaltyWidth(content, context, lineIndex);
+ final int idealGlueSize = getIdealGlueWidth(content, context, lineIndex);
+ final int totalAdjustment = totalGlueSize - idealGlueSize;
+ if (totalAdjustment > 0) {
+ final int totalStretchability = getGlueWidthStretchability(content, context, lineIndex);
+ return (float) totalAdjustment / (float) totalStretchability;
+ } else if (totalAdjustment < idealGlueSize) {
+ final int totalShrinkability = getGlueWidthShrinkability(content, context, lineIndex);
+ return (float) totalAdjustment / (float) totalShrinkability;
+ } else {
+ /* The adjustment is zero and therefore so is the ratio. */
+ return 0;
+ }
+ }
+
}
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-28 12:43:10 UTC (rev 13097)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-29 20:37:07 UTC (rev 13098)
@@ -45,6 +45,7 @@
/**
* Method making assertions about individual {@link LineBreak} items.
* @param content The paragraph that was broken into lines.
+ * @param context The context for the width computations.
* @param actual The result instance about which assertions are being made.
* @param lineIndex The index into {@code actual} for the line being tested.
* @param expectedLineLength The expected line length for {@code actual}.
@@ -52,14 +53,16 @@
* @param expectedQtyInterwordGlue The expected number of interword leaves for {@code actual}.
* @param expectedAdjustment The expected interword space adjustment.
*/
- public void assertLineBreak(final KpBranch content, final LineBreakResult4a actual, final int lineIndex,
- final int expectedLineLength, final int expectedBreakPosition, final int expectedQtyInterwordGlue,
- final float expectedAdjustment) {
+ public void assertLineBreak(final KpBranch content, final KpContext context, final LineBreakResult4a actual,
+ final int lineIndex, final int expectedLineLength, final int expectedBreakPosition,
+ final int expectedQtyInterwordGlue, final float expectedAdjustment) {
final LineBreak lineBreak = actual.getLineBreak(lineIndex);
assertEquals(expectedLineLength, lineBreak.getLineLength());
assertEquals(expectedBreakPosition, lineBreak.getBreakPosition());
- final int qtyInterwordGlue = actual.getQtyInterwordGlue(content, lineIndex);
+ final int qtyInterwordGlue = actual.getQtyInterwordGlue(content, context, lineIndex);
assertEquals(expectedQtyInterwordGlue, qtyInterwordGlue);
+// final float r = actual.getAdjustmentRatio(content, context, lineIndex);
+// assertEquals(expectedAdjustment, r, .0005);
}
/**
@@ -78,7 +81,7 @@
final LineBreakResult4a actual = out.breakIntoLines(para, paraContext, lineBreakTarget);
assertEquals(1, actual.getQtyLines());
- assertLineBreak(para, actual, 0, 468_000, 3, 1, 0);
+ assertLineBreak(para, kpContext, actual, 0, 468_000, 3, 1, 0);
}
/**
@@ -101,18 +104,18 @@
* The expected quantity of interword glue items was computed by visually counting such items at Figure 1.
* The expected interword adjustment factor was copied from Figure 1. */
- assertLineBreak(para, actual, 0, 390_000, 19, 7, .857f); // helped one,
- assertLineBreak(para, actual, 1, 390_000, 42, 8, -.750f); // all beau-ti-
- assertLineBreak(para, actual, 2, 390_000, 68, 9, -.824f); // that the sun
- assertLineBreak(para, actual, 3, 390_000, 90, 7, 1.087f); // aston-ished
- assertLineBreak(para, actual, 4, 390_000, 113, 9, -.235f); // by the king’s
- assertLineBreak(para, actual, 5, 390_000, 138, 9, .607f); // un-der an old
- assertLineBreak(para, actual, 6, 390_000, 164, 9, .500f); // and when the
- assertLineBreak(para, actual, 7, 390_000, 185, 9, -.500f); // went out into
- assertLineBreak(para, actual, 8, 390_000, 209, 10, .700f); // of the cool
- assertLineBreak(para, actual, 9, 390_000, 230, 8, 1.360f); // she took a
- assertLineBreak(para, actual, 10, 390_000, 254, 10, -.650f); // and caught it;
- assertLineBreak(para, actual, 11, 390_000, 276, 6, .001f); // play-thing.
+ assertLineBreak(para, kpContext, actual, 0, 390_000, 19, 7, .857f); // helped one,
+ assertLineBreak(para, kpContext, actual, 1, 390_000, 42, 8, -.750f); // all beau-ti-
+ assertLineBreak(para, kpContext, actual, 2, 390_000, 68, 9, -.824f); // that the sun
+ assertLineBreak(para, kpContext, actual, 3, 390_000, 90, 7, 1.087f); // aston-ished
+ assertLineBreak(para, kpContext, actual, 4, 390_000, 113, 9, -.235f); // by the king’s
+ assertLineBreak(para, kpContext, actual, 5, 390_000, 138, 9, .607f); // un-der an old
+ assertLineBreak(para, kpContext, actual, 6, 390_000, 164, 9, .500f); // and when the
+ assertLineBreak(para, kpContext, actual, 7, 390_000, 185, 9, -.500f); // went out into
+ assertLineBreak(para, kpContext, actual, 8, 390_000, 209, 10, .700f); // of the cool
+ assertLineBreak(para, kpContext, actual, 9, 390_000, 230, 8, 1.360f); // she took a
+ assertLineBreak(para, kpContext, actual, 10, 390_000, 254, 10, -.650f); // and caught it;
+ assertLineBreak(para, kpContext, actual, 11, 390_000, 276, 6, .001f); // play-thing.
}
}
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-28 12:43:10 UTC (rev 13097)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-29 20:37:07 UTC (rev 13098)
@@ -28,6 +28,7 @@
package org.foray.linebreak;
+import org.foray.font.fixture.MockFont;
import org.foray.font.fixture.MockFontUse;
import org.foray.font.fixture.MockMonotypeFont;
import org.foray.orthography.Punctuation4a;
@@ -37,11 +38,13 @@
import org.axsl.kp.KpBranchTf;
import org.axsl.kp.KpContext;
import org.axsl.kp.KpGlue;
+import org.axsl.kp.KpGlueTf;
import org.axsl.kp.KpPenalty;
import org.axsl.kp.KpPenaltyTf;
import org.axsl.kp.KpUserAgent;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.BeforeAll;
import org.mockito.Mockito;
/**
@@ -84,7 +87,53 @@
"triangles whose generator is unity. But I leave out many more than I include; it is extraordinary how " +
"fertile in properties this triangle is. Everyone can try his hand.";
+ /** The font being used for each test. */
+ private static MockFont font;
+
+ /** The font use being used for each test. */
+ private static MockFontUse fontUse;
+
+ /** Glue to be used for spaces immediately following a comma. */
+ private static KpGlue kpSpaceAfterComma;
+
+ /** Glue to be used for spaces immediately following a semicolon. */
+ private static KpGlue kpSpaceAfterSemicolon;
+
+ /** Glue to be used for spaces immediately following a period. */
+ private static KpGlue kpSpaceAfterPeriod;
+
/**
+ * Initialize the class.
+ */
+ @BeforeAll
+ public static void initializeClass() {
+ font = new MockMonotypeFont(true);
+ fontUse = new MockFontUse();
+ fontUse.setFont(font);
+ /* Set up the same glue items used by Knuth-Plass, so that our computations of adjustments can be compared.
+ * See "Knuth, Digital Typography, p. 75" for values. */
+ kpSpaceAfterComma = createSpecialGlue(font, 6, 4, 2);
+ kpSpaceAfterSemicolon = createSpecialGlue(font, 6, 4, 1);
+ kpSpaceAfterPeriod = createSpecialGlue(font, 8, 6, 1);
+ }
+
+ /**
+ * Helper method that creates special glue items.
+ * @param font The font being used to convert native values to millipoints.
+ * @param nativeIdealWidth The ideal width, in native font units.
+ * @param nativeStretchability The stretchability, in native font units.
+ * @param nativeShrinkability The shrinkability, in native font units.
+ * @return The glue representing these hard-coded values.
+ */
+ private static KpGlue createSpecialGlue(final MockFont font, final int nativeIdealWidth,
+ final int nativeStretchability, final int nativeShrinkability) {
+ final int idealWidth = font.toMillipoints(nativeIdealWidth, LineBreaker4aTests.GRIMM_FONT_SIZE);
+ final int stretchability = font.toMillipoints(nativeStretchability, LineBreaker4aTests.GRIMM_FONT_SIZE);
+ final int shrinkability = font.toMillipoints(nativeShrinkability, LineBreaker4aTests.GRIMM_FONT_SIZE);
+ return new KpGlueTf(idealWidth, stretchability, shrinkability);
+ }
+
+ /**
* Creates the tokenized content of {@link #TEST_STRING_01}.
* We could use the orthography system to build this, but the line-breaking logic is independent of that, so we
* manually build it in this method.
@@ -114,7 +163,7 @@
para.addSpace(); // 16 1 6 342
para.addWord("one"); // 17 1 27 369 9+10+8
para.addNode(Punctuation4a.COMMA); // 18 1 5 374
- para.addSpace(); // 19 1 6 380
+ para.addNode(kpSpaceAfterComma); // 19 1 6 380
para.addWord("there"); // 20 1 40 420 7+10+8+7+8
para.addSpace(); // 21 1 6 426
para.addWord("lived"); // 22 1 37 463 5+5+9+8+10
@@ -133,7 +182,7 @@
para.addSpace(); // 37 1 6 727
para.addWord("beau-ti-ful"); // 38 5 70 797 10+8+9+10 7+5 6+10+5
para.addNode(Punctuation4a.SEMICOLON); // 43 1 5 802
- para.addSpace(); // 44 1 6 808
+ para.addNode(kpSpaceAfterSemicolon); // 44 1 6 808
para.addWord("and"); // 45 1 29 837 9+10+10
para.addSpace(); // 46 1 6 843
para.addWord("the"); // 47 1 25 868 7+10+8
@@ -154,7 +203,7 @@
para.addSpace(); // 68 1 6 1186
para.addWord("it-self"); // 69 3 38 1224 5+7 7+8+5+6
para.addNode(Punctuation4a.COMMA); // 72 1 5 1229
- para.addSpace(); // 73 1 6 1235
+ para.addNode(kpSpaceAfterComma); // 73 1 6 1235
para.addWord("which"); // 74 1 46 1281 13+10+5+8+10
para.addSpace(); // 75 1 6 1287
para.addWord("has"); // 76 1 26 1313 10+9+7
@@ -165,7 +214,7 @@
para.addSpace(); // 81 1 6 1380
para.addWord("much"); // 82 1 43 1423 15+10+8+10
para.addNode(Punctuation4a.COMMA); // 83 1 5 1428
- para.addSpace(); // 84 1 6 1434
+ para.addNode(kpSpaceAfterComma); // 84 1 6 1434
para.addWord("was"); // 85 1 29 1463 13+9+7
para.addSpace(); // 86 1 6 1469
para.addWord("aston-ished"); // 87 3 82 1551 9+7+7+9+10 5+7+10+8+10
@@ -182,7 +231,7 @@
para.addSpace(); // 102 1 6 1756
para.addWord("face"); // 103 1 31 1787 6+9+8+8
para.addNode(Punctuation4a.PERIOD); // 104 1 5 1792
- para.addSpace(); // 105 1 6 1798
+ para.addNode(kpSpaceAfterPeriod); // 105 1 6 1798
para.addWord("Close"); // 106 1 42 1840 13+5+9+7+8
para.addSpace(); // 107 1 6 1846
para.addWord("by"); // 108 1 20 1866 10+10
@@ -203,7 +252,7 @@
para.addSpace(); // 123 1 6 2138
para.addWord("for-est"); // 124 3 44 2182 6+9+7 8+7+7
para.addNode(Punctuation4a.COMMA); // 127 1 5 2187
- para.addSpace(); // 128 1 6 2193
+ para.addNode(kpSpaceAfterComma); // 128 1 6 2193
para.addWord("and"); // 129 1 29 2222 9+10+10
para.addSpace(); // 130 1 6 2228
para.addWord("un-der"); // 131 3 45 2273 10+10 10+8+7
@@ -229,7 +278,7 @@
para.addSpace(); // 155 1 6 2561
para.addWord("well"); // 156 1 31 2592 13+8+5+5
para.addNode(Punctuation4a.COMMA); // 157 1 5 2597
- para.addSpace(); // 158 1 6 2603
+ para.addNode(kpSpaceAfterComma); // 158 1 6 2603
para.addWord("and"); // 159 1 29 2632 9+10+10
para.addSpace(); // 160 1 6 2638
para.addWord("when"); // 161 1 41 2679 13+10+8+10
@@ -244,7 +293,7 @@
para.addSpace(); // 170 1 6 2826
para.addWord("warm"); // 171 1 44 2870 13+9+7+15
para.addNode(Punctuation4a.COMMA); // 172 1 5 2875
- para.addSpace(); // 173 1 6 2881
+ para.addNode(kpSpaceAfterComma); // 173 1 6 2881
para.addWord("the"); // 174 1 25 2906 7+10+8
para.addSpace(); // 175 1 6 2912
para.addWord("king’s"); // 176 1 46 2958 10+5+10+9+5+7
@@ -281,7 +330,7 @@
para.addSpace(); // 209 1 6 3496
para.addWord("foun-tain"); // 210 3 66 3562 6+9+10+10 7+9+5+10
para.addNode(Punctuation4a.SEMICOLON); // 213 1 5 3567
- para.addSpace(); // 214 1 6 3573
+ para.addNode(kpSpaceAfterSemicolon); // 214 1 6 3573
para.addWord("and"); // 215 1 29 3602 9+10+10
para.addSpace(); // 216 1 6 3608
para.addWord("when"); // 217 1 41 3649 13+10+8+10
@@ -302,7 +351,7 @@
para.addSpace(); // 232 1 6 3915
para.addWord("ball"); // 233 1 29 3944 10+9+5+5
para.addNode(Punctuation4a.COMMA); // 234 1 5 3949
- para.addSpace(); // 235 1 6 3955
+ para.addNode(kpSpaceAfterComma); // 235 1 6 3955
para.addWord("and"); // 236 1 29 3984 9+10+10
para.addSpace(); // 237 1 6 3990
para.addWord("threw"); // 238 1 45 4035 7+10+7+8+13
@@ -321,7 +370,7 @@
para.addSpace(); // 251 1 6 4244
para.addWord("it"); // 252 1 12 4256 5+7
para.addNode(Punctuation4a.SEMICOLON); // 253 1 5 4261
- para.addSpace(); // 254 1 6 4267
+ para.addNode(kpSpaceAfterSemicolon); // 254 1 6 4267
para.addWord("and"); // 255 1 29 4296 9+10+10
para.addSpace(); // 256 1 6 4302
para.addWord("this"); // 257 1 29 4331 7+10+5+7
@@ -370,9 +419,6 @@
* @return The Monotype paragraph configuration.
*/
public KpContext4a createGrimmParaConfig() {
- final MockMonotypeFont font = new MockMonotypeFont(true);
- final MockFontUse fontUse = new MockFontUse();
- fontUse.setFont(font);
/* Stretchability and shrinkability come from the interword values in Table 1. Note that different values are
* set if the space follows a comma, semicolon, or period. This may affect our test results, as we don't have
* a way to make such adjustments. However, we could hard-code the values into the paragraph itself. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-28 12:43:13
|
Revision: 13097
http://sourceforge.net/p/foray/code/13097
Author: victormote
Date: 2023-01-28 12:43:10 +0000 (Sat, 28 Jan 2023)
Log Message:
-----------
Add logic and tests to counter interword glue.
Modified Paths:
--------------
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreak.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2023-01-27 17:02:21 UTC (rev 13096)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2023-01-28 12:43:10 UTC (rev 13097)
@@ -73,15 +73,12 @@
/** Initial list size for "provisional" items, chosen as being unlikely to be exceeded. */
private static final int PROVISIONAL_LIST_SIZE = 20;
+ /** The length, in millipoints, of the lines onto which the content is being laid out. */
+ private IntArrayBuilder lineLengths = new IntArrayBuilder(BREAKPOINTS_INIT_SIZE);
+
/** The array of breakpoints for the paragraph. */
private IntArrayBuilder breakpoints = new IntArrayBuilder(BREAKPOINTS_INIT_SIZE);
- /** The 1-based line number of the layout for this paragraph. */
- private int currentLineNumber;
-
- /** The length, in millipoints, of the lines onto which the content is being laid out. */
- private IntArrayBuilder lineLengths = new IntArrayBuilder(BREAKPOINTS_INIT_SIZE);
-
/** The accepted content of the current line. */
private List<KpLeaf> currentLineContent = new ArrayList<KpLeaf>(LINE_CONTENT_INIT_SIZE);
@@ -131,8 +128,7 @@
private State(final KpUserAgent paraContext, final LineBreakContext lbContext) {
this.paraContext = paraContext;
this.lineBreakTarget = lbContext;
- this.currentLineNumber = 1;
- this.lineLengths.append(this.lineBreakTarget.getLineLength(currentLineNumber));
+ this.lineLengths.append(this.lineBreakTarget.getLineLength(this.breakpoints.length() + 1));
}
/**
@@ -229,8 +225,7 @@
this.currentLineIdealWidth = 0;
this.currentLineShrinkability = 0;
this.currentLineStretchability = 0;
- this.currentLineNumber ++;
- this.lineLengths.append(this.lineBreakTarget.getLineLength(currentLineNumber));
+ this.lineLengths.append(this.lineBreakTarget.getLineLength(this.breakpoints.length() + 1));
}
/**
@@ -274,7 +269,7 @@
private LineBreakResult4a createResult() {
final LineBreakResult4a result = new LineBreakResult4a(lineLengths.length());
for (int index = 0; index < lineLengths.length(); index ++) {
- final LineBreak lineBreak = new LineBreak(lineLengths.intAt(index), breakpoints.intAt(index), 0, 0);
+ final LineBreak lineBreak = new LineBreak(lineLengths.intAt(index), breakpoints.intAt(index), 0);
result.addLineBreak(lineBreak);
}
return result;
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreak.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreak.java 2023-01-27 17:02:21 UTC (rev 13096)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreak.java 2023-01-28 12:43:10 UTC (rev 13097)
@@ -39,9 +39,6 @@
/** The break position for this line. */
private int breakPosition;
- /** The quantity of glue leaves for this line. */
- private int qtyGlueLeaves;
-
/** The net interword adjustment value for this line. */
private int interwordAdjustment;
@@ -49,14 +46,11 @@
* Constructor.
* @param lineLength The line length, in millipoints.
* @param breakPosition The break position for this line.
- * @param qtyGlueLeaves The quantity of glue leaves for this line.
* @param interwordAdjustment The net interword adjustment value for this line.
*/
- public LineBreak(final int lineLength, final int breakPosition, final int qtyGlueLeaves,
- final int interwordAdjustment) {
+ public LineBreak(final int lineLength, final int breakPosition, final int interwordAdjustment) {
this.lineLength = lineLength;
this.breakPosition = breakPosition;
- this.qtyGlueLeaves = qtyGlueLeaves;
this.interwordAdjustment = interwordAdjustment;
}
@@ -77,15 +71,6 @@
}
/**
- * Returns the number of glue leaves on a given line, not including any at the beginning or end of the line.
- * In other words, the number of interword glue items on the line.
- * @return The quantity of glue leaves for this line.
- */
- public int getQtyGlueLeaves() {
- return qtyGlueLeaves;
- }
-
- /**
* Returns the total net word-spacing adjustment for the line, in millipoints.
* A zero indicates ideal word-spacing, a positive value indicates stretch (looseness) and a negative value
* indicates shrink (tightness).
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2023-01-27 17:02:21 UTC (rev 13096)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2023-01-28 12:43:10 UTC (rev 13097)
@@ -28,6 +28,8 @@
package org.foray.linebreak;
+import org.axsl.kp.KpBranch;
+import org.axsl.kp.KpLeaf;
import org.axsl.kp.KpResult;
import java.util.ArrayList;
@@ -95,4 +97,37 @@
return lineBreak.getBreakPosition();
}
+ /**
+ * Count the number of non-adjacent glue leaves for a given line, disregarding any at the beginning or end of the
+ * content.
+ * Adjacent glue leaves are counted as one glue leaf because there is only one effective interword glue item.
+ * @param content The content which has been broken into lines.
+ * @param lineIndex The index to the line being queried.
+ * @return The number of non-adjacent interword glue leaves.
+ */
+ public int getQtyInterwordGlue(final KpBranch content, final int lineIndex) {
+ /* Don't count any glue items until we have hit at least one box item. After that count only the glue items that
+ * are immediately followed by a box item. */
+ final int startLeafIndex = lineIndex > 0 ? getBreakPosition(lineIndex - 1) : 0;
+ final int endLeafIndex = getBreakPosition(lineIndex);
+ boolean anyBoxes = false;
+
+
+ int count = 0;
+ /* Skip the last leaf. It cannot be followed by a box. */
+ for (int index = startLeafIndex; index < endLeafIndex - 1; index++) {
+ final KpLeaf leaf = content.kpLeafAt(index);
+ if (leaf.getKpLeafType() == KpLeaf.Type.BOX) {
+ anyBoxes = true;
+ } else if (anyBoxes
+ && leaf.getKpLeafType() == KpLeaf.Type.GLUE) {
+ final KpLeaf next = content.kpLeafAt(index + 1);
+ if (next.getKpLeafType() == KpLeaf.Type.BOX) {
+ count ++;
+ }
+ }
+ }
+ return count;
+ }
+
}
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-27 17:02:21 UTC (rev 13096)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-28 12:43:10 UTC (rev 13097)
@@ -29,6 +29,7 @@
package org.foray.linebreak;
import org.axsl.context.LineBreakContext;
+import org.axsl.kp.KpBranch;
import org.axsl.kp.KpBranchTf;
import org.axsl.kp.KpContext;
import org.axsl.kp.KpUserAgent;
@@ -42,6 +43,26 @@
public class FirstFitLbTests extends LineBreaker4aTests {
/**
+ * Method making assertions about individual {@link LineBreak} items.
+ * @param content The paragraph that was broken into lines.
+ * @param actual The result instance about which assertions are being made.
+ * @param lineIndex The index into {@code actual} for the line being tested.
+ * @param expectedLineLength The expected line length for {@code actual}.
+ * @param expectedBreakPosition The expected break position for {@code actual}.
+ * @param expectedQtyInterwordGlue The expected number of interword leaves for {@code actual}.
+ * @param expectedAdjustment The expected interword space adjustment.
+ */
+ public void assertLineBreak(final KpBranch content, final LineBreakResult4a actual, final int lineIndex,
+ final int expectedLineLength, final int expectedBreakPosition, final int expectedQtyInterwordGlue,
+ final float expectedAdjustment) {
+ final LineBreak lineBreak = actual.getLineBreak(lineIndex);
+ assertEquals(expectedLineLength, lineBreak.getLineLength());
+ assertEquals(expectedBreakPosition, lineBreak.getBreakPosition());
+ final int qtyInterwordGlue = actual.getQtyInterwordGlue(content, lineIndex);
+ assertEquals(expectedQtyInterwordGlue, qtyInterwordGlue);
+ }
+
+ /**
* Test of an extremely short line that should return no line breaks.
*/
@Test
@@ -48,15 +69,16 @@
public void firstFitTestSingleLine() {
final KpContext kpContext = createGrimmParaConfig();
final ParaBranch4aTestFixture para = new ParaBranch4aTestFixture(kpContext, '-');
- para.addWord("Hello World!");
+ para.addWord("Hello");
para.addSpace();
+ para.addWord("World!");
final KpUserAgent paraContext = createUserAgent();
final LineBreakContext lineBreakTarget = createLineBreakTarget(-1);
final FirstFitLb out = new FirstFitLb();
final LineBreakResult4a actual = out.breakIntoLines(para, paraContext, lineBreakTarget);
+
assertEquals(1, actual.getQtyLines());
- assertEquals(468000, actual.getLineLength(0));
- assertEquals(2, actual.getBreakPosition(0));
+ assertLineBreak(para, actual, 0, 468_000, 3, 1, 0);
}
/**
@@ -73,33 +95,24 @@
final FirstFitLb out = new FirstFitLb();
final LineBreakResult4a actual = out.breakIntoLines(para, paraContext, lbContext);
assertEquals(12, actual.getQtyLines());
- assertEquals(390_000, actual.getLineLength(0));
- assertEquals(390_000, actual.getLineLength(1));
- assertEquals(390_000, actual.getLineLength(2));
- assertEquals(390_000, actual.getLineLength(3));
- assertEquals(390_000, actual.getLineLength(4));
- assertEquals(390_000, actual.getLineLength(5));
- assertEquals(390_000, actual.getLineLength(6));
- assertEquals(390_000, actual.getLineLength(7));
- assertEquals(390_000, actual.getLineLength(8));
- assertEquals(390_000, actual.getLineLength(9));
- assertEquals(390_000, actual.getLineLength(10));
- assertEquals(390_000, actual.getLineLength(11));
- /* Breakpoints verified against paragraph built at LineBreaker4aTests.createPara and Figure 1 (see method
- * javadoc). */
- assertEquals(19, actual.getBreakPosition(0)); // helped one,
- assertEquals(42, actual.getBreakPosition(1)); // all beau-ti-
- assertEquals(68, actual.getBreakPosition(2)); // that the sun
- assertEquals(90, actual.getBreakPosition(3)); // aston-ished
- assertEquals(113, actual.getBreakPosition(4)); // by the king’s
- assertEquals(138, actual.getBreakPosition(5)); // un-der an old
- assertEquals(164, actual.getBreakPosition(6)); // and when the
- assertEquals(185, actual.getBreakPosition(7)); // went out into
- assertEquals(209, actual.getBreakPosition(8)); // of the cool
- assertEquals(230, actual.getBreakPosition(9)); // she took a
- assertEquals(254, actual.getBreakPosition(10)); // and caught it;
- assertEquals(276, actual.getBreakPosition(11)); // play-thing.
+ /* The following expected breakpoints were verified against the paragraph built at
+ * LineBreaker4aTests.createPara and Figure 1 (see method javadoc).
+ * The expected quantity of interword glue items was computed by visually counting such items at Figure 1.
+ * The expected interword adjustment factor was copied from Figure 1. */
+
+ assertLineBreak(para, actual, 0, 390_000, 19, 7, .857f); // helped one,
+ assertLineBreak(para, actual, 1, 390_000, 42, 8, -.750f); // all beau-ti-
+ assertLineBreak(para, actual, 2, 390_000, 68, 9, -.824f); // that the sun
+ assertLineBreak(para, actual, 3, 390_000, 90, 7, 1.087f); // aston-ished
+ assertLineBreak(para, actual, 4, 390_000, 113, 9, -.235f); // by the king’s
+ assertLineBreak(para, actual, 5, 390_000, 138, 9, .607f); // un-der an old
+ assertLineBreak(para, actual, 6, 390_000, 164, 9, .500f); // and when the
+ assertLineBreak(para, actual, 7, 390_000, 185, 9, -.500f); // went out into
+ assertLineBreak(para, actual, 8, 390_000, 209, 10, .700f); // of the cool
+ assertLineBreak(para, actual, 9, 390_000, 230, 8, 1.360f); // she took a
+ assertLineBreak(para, actual, 10, 390_000, 254, 10, -.650f); // and caught it;
+ assertLineBreak(para, actual, 11, 390_000, 276, 6, .001f); // play-thing.
}
}
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-27 17:02:21 UTC (rev 13096)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-28 12:43:10 UTC (rev 13097)
@@ -336,7 +336,7 @@
para.addSpace(); // 268 1 6 4504
para.addWord("play-thing"); // 269 3 75 4579 10+5+9+10 7+10+5+10+9
para.addNode(Punctuation4a.PERIOD); // 272 1 5 4584
- para.addNode(KpPenaltyTf.DISALLOWED_BREAK); // 273 1 0 4584
+ para.addNode(KpPenalty.DISALLOWED_BREAK); // 273 1 0 4584
para.addNode(KpGlue.FINISHING_GLUE); // 274 1 0 4584
para.addNode(KpPenalty.FORCED_BREAK); // 275 1 0 4584
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-27 17:02:25
|
Revision: 13096
http://sourceforge.net/p/foray/code/13096
Author: victormote
Date: 2023-01-27 17:02:21 +0000 (Fri, 27 Jan 2023)
Log Message:
-----------
Refactor line-break data into a class, and add some metrics to be eventually used for testing.
Modified Paths:
--------------
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java
Added Paths:
-----------
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreak.java
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java 2023-01-27 15:41:39 UTC (rev 13095)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java 2023-01-27 17:02:21 UTC (rev 13096)
@@ -41,7 +41,7 @@
@Override
public LineBreakResult4a breakIntoLines(final KpBranch paragraph, final KpUserAgent paraContext,
final LineBreakContext lbContext) {
- return new LineBreakResult4a(null, null);
+ return LineBreakResult4a.EMPTY_RESULT;
}
}
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2023-01-27 15:41:39 UTC (rev 13095)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2023-01-27 17:02:21 UTC (rev 13096)
@@ -272,7 +272,12 @@
* @return The result.
*/
private LineBreakResult4a createResult() {
- return new LineBreakResult4a(lineLengths.toArray(), breakpoints.toArray());
+ final LineBreakResult4a result = new LineBreakResult4a(lineLengths.length());
+ for (int index = 0; index < lineLengths.length(); index ++) {
+ final LineBreak lineBreak = new LineBreak(lineLengths.intAt(index), breakpoints.intAt(index), 0, 0);
+ result.addLineBreak(lineBreak);
+ }
+ return result;
}
}
Added: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreak.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreak.java (rev 0)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreak.java 2023-01-27 17:02:21 UTC (rev 13096)
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2023 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.linebreak;
+
+/**
+ * A resolved line break, storing the size of the line, the content index at which it ends, and metrics for it.
+ */
+public class LineBreak {
+
+ /** The line length, in millipoints, for this line. */
+ private int lineLength;
+
+ /** The break position for this line. */
+ private int breakPosition;
+
+ /** The quantity of glue leaves for this line. */
+ private int qtyGlueLeaves;
+
+ /** The net interword adjustment value for this line. */
+ private int interwordAdjustment;
+
+ /**
+ * Constructor.
+ * @param lineLength The line length, in millipoints.
+ * @param breakPosition The break position for this line.
+ * @param qtyGlueLeaves The quantity of glue leaves for this line.
+ * @param interwordAdjustment The net interword adjustment value for this line.
+ */
+ public LineBreak(final int lineLength, final int breakPosition, final int qtyGlueLeaves,
+ final int interwordAdjustment) {
+ this.lineLength = lineLength;
+ this.breakPosition = breakPosition;
+ this.qtyGlueLeaves = qtyGlueLeaves;
+ this.interwordAdjustment = interwordAdjustment;
+ }
+
+ /**
+ * Returns the line length, in millipoints, for this line.
+ * @return The line length, in millipoints, for this line.
+ */
+ public int getLineLength() {
+ return lineLength;
+ }
+
+ /**
+ * Returns the break position for this line.
+ * @return The break position for this line.
+ */
+ public int getBreakPosition() {
+ return breakPosition;
+ }
+
+ /**
+ * Returns the number of glue leaves on a given line, not including any at the beginning or end of the line.
+ * In other words, the number of interword glue items on the line.
+ * @return The quantity of glue leaves for this line.
+ */
+ public int getQtyGlueLeaves() {
+ return qtyGlueLeaves;
+ }
+
+ /**
+ * Returns the total net word-spacing adjustment for the line, in millipoints.
+ * A zero indicates ideal word-spacing, a positive value indicates stretch (looseness) and a negative value
+ * indicates shrink (tightness).
+ * @return The net interword adjustment value for this line.
+ */
+ public int getInterwordAdjustment() {
+ return interwordAdjustment;
+ }
+
+}
Property changes on: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreak.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2023-01-27 15:41:39 UTC (rev 13095)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2023-01-27 17:02:21 UTC (rev 13096)
@@ -30,7 +30,8 @@
import org.axsl.kp.KpResult;
-import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
/**
* The results of a line-breaking computation.
@@ -37,44 +38,61 @@
* See {@link KpResult} interface documentation for more details.
* Instances of this class are immutable.
*/
-public final class LineBreakResult4a implements KpResult {
+public class LineBreakResult4a implements KpResult {
- /** Result suitable for cases an empty result should be returned. */
- public static final LineBreakResult4a EMPTY_RESULT = new LineBreakResult4a(new int[0], new int[0]);
+ /** Result suitable for cases where an empty result should be returned. */
+ public static final LineBreakResult4a EMPTY_RESULT = new LineBreakResult4a(0) {
- /** The array of line lengths, in millipoints, for the paragraph. */
- private int[] lineLengths;
+ @Override
+ public void addLineBreak(final LineBreak lineBreak) {
+ throw new UnsupportedOperationException("Cannot add a line break to the empty result.");
+ }
- /** The array of breakpoints for the paragraph. */
- private int[] breakPositions;
+ };
+ /** The list of line-break instances in this result. */
+ private List<LineBreak> lineBreakList;
+
/**
* Constructor.
- * @param lineLengths The array of line lengths, in millipoints, for this result.
- * @param breakPositions The array of break positions for this result.
+ * @param expectedSize The expected number of lines to be added to this result.
*/
- public LineBreakResult4a(final int[] lineLengths, final int[] breakPositions) {
- if (lineLengths.length != breakPositions.length) {
- throw new IllegalArgumentException("Line length and breakpoint arrays must be of equal length.");
- }
- /* Copy to ensure immutability. */
- this.lineLengths = Arrays.copyOf(lineLengths, lineLengths.length);
- this.breakPositions = Arrays.copyOf(breakPositions, breakPositions.length);
+ public LineBreakResult4a(final int expectedSize) {
+ this.lineBreakList = new ArrayList<LineBreak>(expectedSize);
}
+ /**
+ * Add a line to this result.
+ * @param lineBreak The line-break information to be added to this result.
+ */
+ public void addLineBreak(final LineBreak lineBreak) {
+ this.lineBreakList.add(lineBreak);
+ }
+
@Override
public int getQtyLines() {
- return this.lineLengths.length;
+ return this.lineBreakList.size();
}
+ /**
+ * Returns a given {@link LineBreak} instance from this result.
+ * @param lineIndex The index to the desired line-break instance.
+ * @return The {@link LineBreak} instance at {@code lineIndex}.
+ */
+ public LineBreak getLineBreak(final int lineIndex) {
+ return this.lineBreakList.get(lineIndex);
+ }
+
@Override
public int getLineLength(final int lineIndex) {
- return this.lineLengths[lineIndex];
+ final LineBreak lineBreak = this.lineBreakList.get(lineIndex);
+ return lineBreak.getLineLength();
}
@Override
public int getBreakPosition(final int lineIndex) {
- return this.breakPositions[lineIndex];
+ final LineBreak lineBreak = this.lineBreakList.get(lineIndex);
+ return lineBreak.getBreakPosition();
}
}
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java 2023-01-27 15:41:39 UTC (rev 13095)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java 2023-01-27 17:02:21 UTC (rev 13096)
@@ -101,7 +101,7 @@
public LineBreakResult4a breakIntoLines(final KpBranch paragraph, final KpUserAgent paraContext,
final LineBreakContext lbContext) {
if (paragraph == null) {
- return new LineBreakResult4a(new int[0], new int[0]);
+ return LineBreakResult4a.EMPTY_RESULT;
}
/* TODO: KpContext used to be passed in as a parameter to this method, but the API changed. This class needs to
@@ -110,7 +110,6 @@
this.paragraph = paragraph;
this.paraContext = paraContext;
this.lbContext = lbContext;
- final IntArrayBuilder returnValue = new IntArrayBuilder();
/* Initialize the data structures. */
this.branchStack = new Stack<KpBranch>();
@@ -141,7 +140,12 @@
// for (LbBreakpoint bp : this.activeNodes) {
// returnValue.add(bp.getNodeWrapper().getPath());
// }
- return new LineBreakResult4a(new int[0], returnValue.toArray());
+ final LineBreakResult4a result = new LineBreakResult4a(0);
+// for (int index = 0; index < lineLengths.length(); index ++) {
+// final LineBreak lineBreak = new LineBreak(lineLengths.intAt(index), breakpoints.intAt(index), 0, 0);
+// result.addLineBreak(lineBreak);
+// }
+ return result;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-27 15:41:42
|
Revision: 13095
http://sourceforge.net/p/foray/code/13095
Author: victormote
Date: 2023-01-27 15:41:39 +0000 (Fri, 27 Jan 2023)
Log Message:
-----------
Doc changes only.
Modified Paths:
--------------
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-27 12:47:16 UTC (rev 13094)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-27 15:41:39 UTC (rev 13095)
@@ -61,6 +61,7 @@
/**
* A test of the Grimm paragraph.
+ * @see "Digital Typography, Donald Knuth, 1999, page 74, Figure 1."
*/
@Test
public void firstFitTestGrimm() {
@@ -84,18 +85,21 @@
assertEquals(390_000, actual.getLineLength(9));
assertEquals(390_000, actual.getLineLength(10));
assertEquals(390_000, actual.getLineLength(11));
- assertEquals(19, actual.getBreakPosition(0));
- assertEquals(42, actual.getBreakPosition(1));
- assertEquals(68, actual.getBreakPosition(2));
- assertEquals(90, actual.getBreakPosition(3));
- assertEquals(113, actual.getBreakPosition(4));
- assertEquals(138, actual.getBreakPosition(5));
- assertEquals(164, actual.getBreakPosition(6));
- assertEquals(185, actual.getBreakPosition(7));
- assertEquals(209, actual.getBreakPosition(8));
- assertEquals(230, actual.getBreakPosition(9));
- assertEquals(254, actual.getBreakPosition(10));
- assertEquals(276, actual.getBreakPosition(11));
+
+ /* Breakpoints verified against paragraph built at LineBreaker4aTests.createPara and Figure 1 (see method
+ * javadoc). */
+ assertEquals(19, actual.getBreakPosition(0)); // helped one,
+ assertEquals(42, actual.getBreakPosition(1)); // all beau-ti-
+ assertEquals(68, actual.getBreakPosition(2)); // that the sun
+ assertEquals(90, actual.getBreakPosition(3)); // aston-ished
+ assertEquals(113, actual.getBreakPosition(4)); // by the king’s
+ assertEquals(138, actual.getBreakPosition(5)); // un-der an old
+ assertEquals(164, actual.getBreakPosition(6)); // and when the
+ assertEquals(185, actual.getBreakPosition(7)); // went out into
+ assertEquals(209, actual.getBreakPosition(8)); // of the cool
+ assertEquals(230, actual.getBreakPosition(9)); // she took a
+ assertEquals(254, actual.getBreakPosition(10)); // and caught it;
+ assertEquals(276, actual.getBreakPosition(11)); // play-thing.
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-27 12:47:19
|
Revision: 13094
http://sourceforge.net/p/foray/code/13094
Author: victormote
Date: 2023-01-27 12:47:16 +0000 (Fri, 27 Jan 2023)
Log Message:
-----------
Remove no-longer-needed method.
Modified Paths:
--------------
trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java
Modified: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java
===================================================================
--- trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java 2023-01-27 12:29:54 UTC (rev 13093)
+++ trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java 2023-01-27 12:47:16 UTC (rev 13094)
@@ -28,7 +28,6 @@
package org.foray.font.fixture;
-import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
import org.axsl.font.Panose;
import org.axsl.ps.BoundingBox;
@@ -98,18 +97,6 @@
this.widths[metricIndex] = width;
}
- /**
- * Sets the width of a given code point, using the Monotype "unit" system.
- * @param codePoint The code point for which the new width is to be set.
- * @param monotypeUnits The number of Monotype "units" for {@code codePoint}.
- * @see <a href="https://books.google.com/books/download/The_monotype_system.pdf?id=6kU5AAAAMAAJ&output=pdf">1912,
- * The Monotype System, Philadelphia, Lanston Monotype Machine Co.</a>
- */
- public void setMonotypeWidth(final int codePoint, final int monotypeUnits) {
- final int width = (int) (monotypeUnits * TypographicConstants.MILLIPOINTS_PER_MONOTYPE_UNIT);
- setWidth(codePoint, width);
- }
-
@Override
public boolean isEmbeddable() {
// TODO Auto-generated method stub
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-27 12:29:57
|
Revision: 13093
http://sourceforge.net/p/foray/code/13093
Author: victormote
Date: 2023-01-27 12:29:54 +0000 (Fri, 27 Jan 2023)
Log Message:
-----------
Improvements to line-breaking tests and related font code.
Modified Paths:
--------------
trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java
trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java
Modified: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java
===================================================================
--- trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java 2023-01-26 21:38:12 UTC (rev 13092)
+++ trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java 2023-01-27 12:29:54 UTC (rev 13093)
@@ -78,8 +78,8 @@
@Override
public int getNativeWidth(final int codePoint) {
- // TODO Auto-generated method stub
- return 0;
+ final int metricIndex = metricIndex(codePoint);
+ return this.widths[metricIndex];
}
@Override
@@ -88,12 +88,6 @@
return 0;
}
- @Override
- public int width(final int codePoint, final int fontSize) {
- final int metricIndex = metricIndex(codePoint);
- return this.widths[metricIndex] * fontSize / TypographicConstants.MILLIPOINTS_PER_POINT;
- }
-
/**
* Sets the width of the glyph for a given code point.
* @param codePoint The code point for which the new width is to be set.
Modified: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java
===================================================================
--- trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-26 21:38:12 UTC (rev 13092)
+++ trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-27 12:29:54 UTC (rev 13093)
@@ -36,12 +36,6 @@
* Note that the values in the "Digital Typography" article do not exactly match those in the Monotype manual.
* Some values may need to be adjusted to match the Knuth-Plass computations.</p>
*
- * <p>CAVEAT: This font stores its widths in Monotype units, which can be converted to millipoints by using
- * {@link org.axsl.constants.TypographicConstants#MILLIPOINTS_PER_MONOTYPE_UNIT}.
- * However, this conversion is not done in the {@link #width(int, int)} or related methods.
- * TODO: Fix this by adding a method that returns the units of a font in its native value and fixing the width method
- * in this class.</p>
- *
* @see <a href="https://books.google.com/books/download/The_monotype_system.pdf?id=6kU5AAAAMAAJ&output=pdf">1912,
* The Monotype System, Philadelphia, Lanston Monotype Machine Co.</a>
* @see "1999, Digital Typography, Chapter 3, page 75, table 1, for the values documented by Knuth-Plass."
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2023-01-26 21:38:12 UTC (rev 13092)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2023-01-27 12:29:54 UTC (rev 13093)
@@ -143,8 +143,8 @@
provisionalNonGlue.add(leaf);
/* Do not include the width of penalty items. */
if (leaf.getKpLeafType() == KpLeaf.Type.BOX) {
- final int leafWidth = leaf.getIdealWidth(this.leafIterator.getNearestContext());
- provisionalNonGlueIdealWidth += leafWidth;
+ final int idealWidth = leaf.getIdealWidth(this.leafIterator.getNearestContext());
+ provisionalNonGlueIdealWidth += idealWidth;
}
}
@@ -155,9 +155,12 @@
private void addProvisionalGlue(final KpGlue glue) {
provisionalGlue.add(glue);
final KpContext context = this.leafIterator.getNearestContext();
- provisionalGlueIdealWidth += glue.getIdealWidth(context);
- provisionalGlueShrinkability += glue.getShrinkability(context);
- provisionalGlueStretchability += glue.getStretchability(context);
+ final int idealWidth = glue.getIdealWidth(context);
+ provisionalGlueIdealWidth += idealWidth;
+ final int shrinkability = glue.getShrinkability(context);
+ provisionalGlueShrinkability += shrinkability;
+ final int stretchability = glue.getStretchability(context);
+ provisionalGlueStretchability += stretchability;
}
/**
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-26 21:38:12 UTC (rev 13092)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-27 12:29:54 UTC (rev 13093)
@@ -34,7 +34,6 @@
import org.axsl.kp.KpUserAgent;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -64,30 +63,27 @@
* A test of the Grimm paragraph.
*/
@Test
- @Disabled
public void firstFitTestGrimm() {
- final KpContext kpContext = createGrimmParaConfig();
- final KpBranchTf para = this.createPara(kpContext);
- /* Line width obtained from "Digital Typography," p. 73. We leave it expressed here in Monotype "units". */
- final int lineWidth = 390;
+ final KpContext4a kpContext = createGrimmParaConfig();
+ final KpBranchTf para = createPara(kpContext);
+ final LineBreakContext lbContext = createGrimmLineBreakContext(kpContext);
final KpUserAgent paraContext = createUserAgent();
- final LineBreakContext lbContext = createLineBreakTarget(lineWidth);
final FirstFitLb out = new FirstFitLb();
final LineBreakResult4a actual = out.breakIntoLines(para, paraContext, lbContext);
assertEquals(12, actual.getQtyLines());
- assertEquals(390, actual.getLineLength(0));
- assertEquals(390, actual.getLineLength(1));
- assertEquals(390, actual.getLineLength(2));
- assertEquals(390, actual.getLineLength(3));
- assertEquals(390, actual.getLineLength(4));
- assertEquals(390, actual.getLineLength(5));
- assertEquals(390, actual.getLineLength(6));
- assertEquals(390, actual.getLineLength(7));
- assertEquals(390, actual.getLineLength(8));
- assertEquals(390, actual.getLineLength(9));
- assertEquals(390, actual.getLineLength(10));
- assertEquals(390, actual.getLineLength(11));
+ assertEquals(390_000, actual.getLineLength(0));
+ assertEquals(390_000, actual.getLineLength(1));
+ assertEquals(390_000, actual.getLineLength(2));
+ assertEquals(390_000, actual.getLineLength(3));
+ assertEquals(390_000, actual.getLineLength(4));
+ assertEquals(390_000, actual.getLineLength(5));
+ assertEquals(390_000, actual.getLineLength(6));
+ assertEquals(390_000, actual.getLineLength(7));
+ assertEquals(390_000, actual.getLineLength(8));
+ assertEquals(390_000, actual.getLineLength(9));
+ assertEquals(390_000, actual.getLineLength(10));
+ assertEquals(390_000, actual.getLineLength(11));
assertEquals(19, actual.getBreakPosition(0));
assertEquals(42, actual.getBreakPosition(1));
assertEquals(68, actual.getBreakPosition(2));
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java 2023-01-26 21:38:12 UTC (rev 13092)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java 2023-01-27 12:29:54 UTC (rev 13093)
@@ -101,4 +101,12 @@
return this.fontUse.getFont().width(this.hyphenationCharacter, this.fontSize);
}
+ /**
+ * Returns the font use for this context.
+ * @return The font use.
+ */
+ public FontUse getFontUse() {
+ return this.fontUse;
+ }
+
}
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-26 21:38:12 UTC (rev 13092)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-27 12:29:54 UTC (rev 13093)
@@ -49,9 +49,11 @@
*/
public abstract class LineBreaker4aTests {
- /** The font size, in millipoints, to be used for the "Grimm" tests. We want the computations to be for one point
- * so that the Monotype units are what is returned by the sizing mechanisms. */
- public static final int GRIMM_FONT_SIZE = 1_000;
+ /** The font size, in millipoints, to be used for the "Grimm" tests.
+ * The font size should not affect the validity of the computations.
+ * Since the glyph-units in the font are 18 per em, setting the font size to 18 points will give a weight of 1000
+ * millipoints per glyph-unit, making debugging a bit easier to follow. */
+ public static final int GRIMM_FONT_SIZE = 18_000;
/** A string used for testing line-breaking. This example is used in Knuth, "Digital Typography," 1999, Chapter 3,
* "Breaking Paragraphs into Lines," p. 74 et seq. Knuth cites his source as "Grimm's Fairy Tales." By using an
@@ -86,8 +88,7 @@
* Creates the tokenized content of {@link #TEST_STRING_01}.
* We could use the orthography system to build this, but the line-breaking logic is independent of that, so we
* manually build it in this method.
- * Where effort has been expended to manually compute indexes and widths, that work is shown, as it may be useful
- * for testing or debugging in the future.
+ * The manual computation of indexes and widths is shown in comments as an aid to testing and debugging.
* @param kpContext The context to be used by descendant leaves.
* @return The tokenized content of {@link #TEST_STRING_01}.
*/
@@ -96,7 +97,7 @@
// ----Leaf--- Ideal Cumul
// Index Qty Width Width
// ------ --- ----- -----
- para.addNode(new KpBoxTf(18)); // 0 1 18 18 Empty box (indent)
+ para.addNode(new KpBoxTf(18_000)); // 0 1 18 18 Empty box (indent)
para.addWord("In"); // 1 1 18 36 8+10
para.addSpace(); // 2 1 6 42
para.addWord("olden"); // 3 1 42 84 9+5+10+8+10
@@ -375,8 +376,8 @@
/* Stretchability and shrinkability come from the interword values in Table 1. Note that different values are
* set if the space follows a comma, semicolon, or period. This may affect our test results, as we don't have
* a way to make such adjustments. However, we could hard-code the values into the paragraph itself. */
- final int stretchability = 3;
- final int shrinkability = 2;
+ final int stretchability = font.toMillipoints(3, GRIMM_FONT_SIZE);
+ final int shrinkability = font.toMillipoints(2, GRIMM_FONT_SIZE);
final KpContext4a paraConfig = new KpContext4a(fontUse, GRIMM_FONT_SIZE, null, stretchability, shrinkability);
return paraConfig;
}
@@ -408,4 +409,18 @@
return lbContext;
}
+ /**
+ * Creates a LineBreakContext to be used for testing the Grimm paragraphy.
+ * @param kpContext The context to be used for computing the line size.
+ * @return The line-breaking context.
+ */
+ protected LineBreakContext createGrimmLineBreakContext(final KpContext4a kpContext) {
+ /* Line width of 390 Monotype "units" is obtained from "Digital Typography," p. 73.
+ * We convert to millipoints to match the line-breaking logic. */
+ final int lineWidth = kpContext.getFontUse().getFont().toMillipoints(390, GRIMM_FONT_SIZE);
+ assertEquals(390_000, lineWidth);
+ final LineBreakContext lbContext = createLineBreakTarget(lineWidth);
+ return lbContext;
+ }
+
}
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java 2023-01-26 21:38:12 UTC (rev 13092)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java 2023-01-27 12:29:54 UTC (rev 13093)
@@ -30,10 +30,10 @@
import org.axsl.context.LineBreakContext;
import org.axsl.kp.KpBranchTf;
-import org.axsl.kp.KpContext;
import org.axsl.kp.KpUserAgent;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -45,17 +45,17 @@
* A test.
*/
@Test
+ @Disabled
public void totalFitTest1() {
/* TODO: THE CLASS BEING TESTED IS VERY INCOMPLETE, AND SO IS THIS TEST !!!!!! */
- final KpContext kpContext = createGrimmParaConfig();
+ final KpContext4a kpContext = createGrimmParaConfig();
final KpBranchTf para = createPara(kpContext);
final KpUserAgent paraContext = createUserAgent();
- /* Line width obtained from "Digital Typography," p. 73.*/
- final LineBreakContext lineBreakTarget = createLineBreakTarget(390_000);
+ final LineBreakContext lbContext = createGrimmLineBreakContext(kpContext);
final TotalFitLb out = new TotalFitLb();
- final LineBreakResult4a actual = out.breakIntoLines(para, paraContext, lineBreakTarget);
+ final LineBreakResult4a actual = out.breakIntoLines(para, paraContext, lbContext);
assertEquals(0, actual.getQtyLines());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-26 21:38:15
|
Revision: 13092
http://sourceforge.net/p/foray/code/13092
Author: victormote
Date: 2023-01-26 21:38:12 +0000 (Thu, 26 Jan 2023)
Log Message:
-----------
Move font fixture code from axsl-font and foray-font into new foray-font-tf project, to workaround eclipse test fixture problem and to clarify dependencies.
Modified Paths:
--------------
trunk/foray/foray-00-master/config/checkstyle/checkstyle-suppressions.xml
trunk/foray/foray-font/build.gradle
trunk/foray/foray-font-tf/build.gradle
trunk/foray/foray-linebreak/build.gradle
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
Added Paths:
-----------
trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java
trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFontUse.java
trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java
trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/package-info.java
Removed Paths:
-------------
trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java
trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/package-info.java
Modified: trunk/foray/foray-00-master/config/checkstyle/checkstyle-suppressions.xml
===================================================================
--- trunk/foray/foray-00-master/config/checkstyle/checkstyle-suppressions.xml 2023-01-26 17:04:26 UTC (rev 13091)
+++ trunk/foray/foray-00-master/config/checkstyle/checkstyle-suppressions.xml 2023-01-26 21:38:12 UTC (rev 13092)
@@ -20,16 +20,18 @@
<suppress checks="DeclarationOrder"
files="src.main.java.org.foray.orthography.zzarchive.PatGen.*"/>
- <!-- Permanently suppress some tests in the test directories. -->
+ <!-- Permanently suppress some tests in the test and test fixture directories. -->
<!-- Permanently suppress Javadoc package documentation for test directories. -->
<suppress checks="JavadocPackage" files="src.test.java.*"/>
<suppress checks="JavadocPackage" files="src.testFixtures.java.*"/>
- <!-- Permanently suppress Magic Number check for test directories. -->
+ <!-- Permanently suppress Magic Number check for tests and test fixtures directories. -->
<suppress checks="MagicNumber" files="src.test.java.*"/>
<suppress checks="MagicNumber" files="src.testFixtures.java.*"/>
<!-- Permanently suppress Method naming checks for test directories. -->
<suppress checks="MethodName" files="src.test.java.*"/>
+ <!-- Permanently suppress Magic Number check for test fixture projects. -->
+ <suppress checks="MagicNumber" files="foray-font-tf.src.main.java.*"/>
<!-- Permanently suppress checks in resources, data, and archives. -->
<suppress checks=".*" files="src.main.resources.*"/>
Modified: trunk/foray/foray-font/build.gradle
===================================================================
--- trunk/foray/foray-font/build.gradle 2023-01-26 17:04:26 UTC (rev 13091)
+++ trunk/foray/foray-font/build.gradle 2023-01-26 21:38:12 UTC (rev 13092)
@@ -1,7 +1,6 @@
plugins {
id 'foray.library-conventions'
id 'foray.test-conventions'
- id 'foray.test-fixtures-conventions'
id 'foray.logging-conventions'
}
@@ -24,11 +23,9 @@
api (project(':foray-xml'))
api (project(':foray-ps-data'))
-// FIX THIS!
+// TODO: FIX THIS!
// testRuntimeOnly (project(':foray-ps'))
api (project(':foray-ps'))
-
- testFixturesApi (testFixtures(group: 'org.axsl', name: 'axsl-font', version: versions.axsl))
}
Deleted: trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java
===================================================================
--- trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-26 17:04:26 UTC (rev 13091)
+++ trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-26 21:38:12 UTC (rev 13092)
@@ -1,140 +0,0 @@
-/*
- * Copyright 2023 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.font.fixture;
-
-import org.foray.ps.encode.CharSetExtendedRoman;
-
-import org.axsl.font.fixture.MockFont;
-
-/**
- * <p>Mock font containing the font metrics for a Monotype system font.
- * Instances of this class may be useful for testing Knuth-Plass algorithms that reference such a font.
- * Note that the values in the "Digital Typography" article do not exactly match those in the Monotype manual.
- * Some values may need to be adjusted to match the Knuth-Plass computations.</p>
- *
- * <p>CAVEAT: This font stores its widths in Monotype units, which can be converted to millipoints by using
- * {@link org.axsl.constants.TypographicConstants#MILLIPOINTS_PER_MONOTYPE_UNIT}.
- * However, this conversion is not done in the {@link #width(int, int)} or related methods.
- * TODO: Fix this by adding a method that returns the units of a font in its native value and fixing the width method
- * in this class.</p>
- *
- * @see <a href="https://books.google.com/books/download/The_monotype_system.pdf?id=6kU5AAAAMAAJ&output=pdf">1912,
- * The Monotype System, Philadelphia, Lanston Monotype Machine Co.</a>
- * @see "1999, Digital Typography, Chapter 3, page 75, table 1, for the values documented by Knuth-Plass."
- */
-public class MockMonotypeFont extends MockFont {
-
- /**
- * Constructor.
- * @param adjustToKnuthPlass Set to true to use the values in the "Digital Typography" article.
- * Set to false to use the native values from the Monotype manual.
- */
- public MockMonotypeFont(final boolean adjustToKnuthPlass) {
- setCharSet(CharSetExtendedRoman.getInstance());
-
- /* It is unclear from the table in the Monotype manual what the width of a "normal" space is. Knuth uses 6 in
- * most cases, but 8 after a period. Since there is no space character in the 8-unit row, we assume that the
- * correct value is 6. */
- setWidth(' ', 6);
- setWidth('’', 5);
- setWidth(',', 5);
- setWidth('-', 5); // 6 per Knuth-Plass below.
- setWidth('.', 5);
- setWidth(';', 6); // 5 per Knuth-Plass below.
-
- setWidth('A', 13);
- setWidth('B', 13);
- setWidth('C', 13);
- setWidth('D', 14);
- setWidth('E', 13);
- setWidth('F', 12);
- setWidth('G', 14);
- setWidth('H', 15);
- setWidth('I', 8); // 6 per Knuth-Plass below.
- setWidth('J', 9);
- setWidth('K', 15);
- setWidth('L', 12);
- setWidth('M', 18);
- setWidth('N', 15);
- setWidth('O', 13);
- setWidth('P', 12);
- setWidth('Q', 13);
- setWidth('R', 14);
- setWidth('S', 10);
- setWidth('T', 13);
- setWidth('U', 14);
- setWidth('V', 13);
- setWidth('W', 18);
- setWidth('X', 15);
- setWidth('Y', 14);
- setWidth('Z', 11);
-
- setWidth('a', 9);
- setWidth('b', 10);
- setWidth('c', 8);
- setWidth('d', 10);
- setWidth('e', 8);
- setWidth('f', 6);
- setWidth('g', 9);
- setWidth('h', 10);
- setWidth('i', 5);
- setWidth('j', 6);
- setWidth('k', 10);
- setWidth('l', 5);
- setWidth('m', 15);
- setWidth('n', 10);
- setWidth('o', 9);
- setWidth('p', 10);
- setWidth('q', 10);
- setWidth('r', 7);
- setWidth('s', 7);
- setWidth('t', 7);
- setWidth('u', 10);
- setWidth('v', 10); // 9 per Knuth-Plass below.
- setWidth('w', 13);
- setWidth('x', 9); // 10 per Knuth-Plass below.
- setWidth('y', 10);
- setWidth('z', 8);
-
-
- if (adjustToKnuthPlass) {
- setWidth('-', 6);
- setWidth(';', 5);
- setWidth('I', 6);
- setWidth('v', 9);
- setWidth('x', 10);
- }
- }
-
- @Override
- public int getUnitsPerEm() {
- return 18;
- }
-
-}
Deleted: trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/package-info.java
===================================================================
--- trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/package-info.java 2023-01-26 17:04:26 UTC (rev 13091)
+++ trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/package-info.java 2023-01-26 21:38:12 UTC (rev 13092)
@@ -1,32 +0,0 @@
-/*
- * Copyright 2023 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-/**
- * Test fixtures related to foray-font.
- */
-package org.foray.font.fixture;
Modified: trunk/foray/foray-font-tf/build.gradle
===================================================================
--- trunk/foray/foray-font-tf/build.gradle 2023-01-26 17:04:26 UTC (rev 13091)
+++ trunk/foray/foray-font-tf/build.gradle 2023-01-26 21:38:12 UTC (rev 13092)
@@ -7,9 +7,12 @@
dependencies {
api (group: 'org.axsl', name: 'axsl-font', version: versions.axsl)
+ api (group: 'org.axsl', name: 'axsl-orthography', version: versions.axsl)
+ implementation (group: 'org.axsl', name: 'axsl-constants', version: versions.axsl)
+ api (group: 'org.axsl', name: 'axsl-primitive', version: versions.axsl)
+ api (project(':foray-ps-data'))
}
-
javadoc {
options.windowTitle = "FOray Font Test Fixtures API"
options.docTitle = "FOray Font Test Fixtures API"
Added: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java
===================================================================
--- trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java (rev 0)
+++ trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java 2023-01-26 21:38:12 UTC (rev 13092)
@@ -0,0 +1,332 @@
+/*
+ * Copyright 2023 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.fixture;
+
+import org.axsl.constants.TypographicConstants;
+import org.axsl.font.Font;
+import org.axsl.font.Panose;
+import org.axsl.ps.BoundingBox;
+import org.axsl.ps.CharSet;
+import org.axsl.ps.Encoding;
+
+/**
+ * A mock implementation of {@link Font}, useful for tests.
+ */
+public class MockFont implements Font {
+
+ /** The character set. */
+ private CharSet charSet;
+
+ /** The array of glyph widths. */
+ private int[] widths;
+
+ @Override
+ public int getAscender(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getDescender(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getCapHeight(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getXheight(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int widthUndefinedGlyph() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getNativeWidth(final int codePoint) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getUnitsPerEm() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int width(final int codePoint, final int fontSize) {
+ final int metricIndex = metricIndex(codePoint);
+ return this.widths[metricIndex] * fontSize / TypographicConstants.MILLIPOINTS_PER_POINT;
+ }
+
+ /**
+ * Sets the width of the glyph for a given code point.
+ * @param codePoint The code point for which the new width is to be set.
+ * @param width The new width, in millipoints, for {@code codePoint}.
+ */
+ public void setWidth(final int codePoint, final int width) {
+ final int metricIndex = metricIndex(codePoint);
+ this.widths[metricIndex] = width;
+ }
+
+ /**
+ * Sets the width of a given code point, using the Monotype "unit" system.
+ * @param codePoint The code point for which the new width is to be set.
+ * @param monotypeUnits The number of Monotype "units" for {@code codePoint}.
+ * @see <a href="https://books.google.com/books/download/The_monotype_system.pdf?id=6kU5AAAAMAAJ&output=pdf">1912,
+ * The Monotype System, Philadelphia, Lanston Monotype Machine Co.</a>
+ */
+ public void setMonotypeWidth(final int codePoint, final int monotypeUnits) {
+ final int width = (int) (monotypeUnits * TypographicConstants.MILLIPOINTS_PER_MONOTYPE_UNIT);
+ setWidth(codePoint, width);
+ }
+
+ @Override
+ public boolean isEmbeddable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isSubsettable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public java.awt.Font getAwtFont(final int fontSize) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean usableInPostScriptOutput() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String getFamilyName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getFontName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getPostscriptName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Encoding getInternalEncoding() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Complexity getFontComplexity() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Format getFontFormat() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public float getItalicAngle() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getStemV() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getDefaultWidth() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean isPdfStandardFont() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public int underlineSize(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int underlinePosition(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int overlineSize(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int overlinePosition(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int strikeoutSize(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int strikeoutPosition(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Panose getPanose() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BoundingBox getBoundingBox() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getFlags() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public BoundingBox getGlyphBoundingBox(final int glyphIndex, final int fontSize) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Sets the character set.
+ * @param charSet The new character set.
+ */
+ public void setCharSet(final CharSet charSet) {
+ this.charSet = charSet;
+ this.widths = new int[charSet.size()];
+ }
+
+ /**
+ * Returns the metric index for a given code point.
+ * @param codePoint The code point for which a metric index is needed.
+ * @return The metric index for {@code codePoint}.
+ */
+ public int metricIndex(final int codePoint) {
+ final int metricIndex = this.charSet.getIndex(codePoint);
+ if (metricIndex < 0) {
+ throw new IllegalArgumentException("Character contains no index for code point: " + codePoint);
+ }
+ return metricIndex;
+ }
+
+ @Override
+ public Source getFontSource() {
+ return Source.FREE_STANDING;
+ }
+
+ @Override
+ public int widthEstimate(final int codePoint) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int kern(final int glyphIndex1, final int glyphIndex2) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public float normalLineHeightFactor(final LineHeightAlgorithm algorithm) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int baselineOffset(final WritingMode writingMode, final Baseline baselineType, final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Baseline baseline(final String script) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int subscriptShift(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int superscriptShift(final int fontSize) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+}
Property changes on: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFontUse.java
===================================================================
--- trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFontUse.java (rev 0)
+++ trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFontUse.java 2023-01-26 21:38:12 UTC (rev 13092)
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2023 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.fixture;
+
+import org.axsl.font.Font;
+import org.axsl.font.Font.Stretch;
+import org.axsl.font.FontConsumer;
+import org.axsl.font.FontContext;
+import org.axsl.font.FontUse;
+import org.axsl.orthography.Orthography;
+import org.axsl.primitive.sequence.ByteSequence;
+import org.axsl.primitive.sequence.IntSequence;
+import org.axsl.primitive.sequence.ShortSequence;
+import org.axsl.ps.Encoding;
+
+import java.math.BigDecimal;
+
+/**
+ * A mock implementation of {@link FontUse}, useful for tests.
+ */
+public class MockFontUse implements FontUse {
+
+ /** The font. */
+ private Font font;
+
+ @Override
+ public Font getFont() {
+ return this.font;
+ }
+
+ /**
+ * Set the font.
+ * @param font The new font.
+ */
+ public void setFont(final Font font) {
+ this.font = font;
+ }
+
+ @Override
+ public FontConsumer getFontConsumer() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Encoding getEncoding() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int encode(final int codePoint) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public IntSequence encode(final CharSequence chars, final int offset, final int length, final FontContext options,
+ final Orthography orthography) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int unavailableChar(final CharSequence chars, final int beginIndex) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public IntSequence unavailableChars(final CharSequence chars, final int beginIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean glyphAvailable(final int codePoint) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public FontUse nextBolderFont() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public FontUse nextLighterFont() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BigDecimal simulateSmallCaps() {
+ return null;
+ }
+
+ @Override
+ public int smallCapsSize(final int fontSize) {
+ return fontSize;
+ }
+
+ @Override
+ public BigDecimal simulateOblique() {
+ return null;
+ }
+
+ @Override
+ public BigDecimal simulateBackslant() {
+ return null;
+ }
+
+ @Override
+ public BigDecimal simulateStretch(final Stretch stretch) {
+ return null;
+ }
+
+ @Override
+ public String getPostscriptName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void registerCharUsed(final int codePoint) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void registerCharsUsed(final CharSequence charSequence) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean wasUsed() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public ShortSequence getWidths() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CharSequence getCharsUsed() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ByteSequence getContent() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getEmbeddableLength1() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getEmbeddableLength2() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getEmbeddableLength3() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public ByteSequence getContentPostScriptHex() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CharSequence textToPdf(final CharSequence theString, final FontContext fontOptions,
+ final Orthography orthography) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFontUse.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java
===================================================================
--- trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java (rev 0)
+++ trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-26 21:38:12 UTC (rev 13092)
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2023 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.fixture;
+
+import org.foray.ps.encode.CharSetExtendedRoman;
+
+/**
+ * <p>Mock font containing the font metrics for a Monotype system font.
+ * Instances of this class may be useful for testing Knuth-Plass algorithms that reference such a font.
+ * Note that the values in the "Digital Typography" article do not exactly match those in the Monotype manual.
+ * Some values may need to be adjusted to match the Knuth-Plass computations.</p>
+ *
+ * <p>CAVEAT: This font stores its widths in Monotype units, which can be converted to millipoints by using
+ * {@link org.axsl.constants.TypographicConstants#MILLIPOINTS_PER_MONOTYPE_UNIT}.
+ * However, this conversion is not done in the {@link #width(int, int)} or related methods.
+ * TODO: Fix this by adding a method that returns the units of a font in its native value and fixing the width method
+ * in this class.</p>
+ *
+ * @see <a href="https://books.google.com/books/download/The_monotype_system.pdf?id=6kU5AAAAMAAJ&output=pdf">1912,
+ * The Monotype System, Philadelphia, Lanston Monotype Machine Co.</a>
+ * @see "1999, Digital Typography, Chapter 3, page 75, table 1, for the values documented by Knuth-Plass."
+ */
+public class MockMonotypeFont extends MockFont {
+
+ /**
+ * Constructor.
+ * @param adjustToKnuthPlass Set to true to use the values in the "Digital Typography" article.
+ * Set to false to use the native values from the Monotype manual.
+ */
+ public MockMonotypeFont(final boolean adjustToKnuthPlass) {
+ setCharSet(CharSetExtendedRoman.getInstance());
+
+ /* It is unclear from the table in the Monotype manual what the width of a "normal" space is. Knuth uses 6 in
+ * most cases, but 8 after a period. Since there is no space character in the 8-unit row, we assume that the
+ * correct value is 6. */
+ setWidth(' ', 6);
+ setWidth('’', 5);
+ setWidth(',', 5);
+ setWidth('-', 5); // 6 per Knuth-Plass below.
+ setWidth('.', 5);
+ setWidth(';', 6); // 5 per Knuth-Plass below.
+
+ setWidth('A', 13);
+ setWidth('B', 13);
+ setWidth('C', 13);
+ setWidth('D', 14);
+ setWidth('E', 13);
+ setWidth('F', 12);
+ setWidth('G', 14);
+ setWidth('H', 15);
+ setWidth('I', 8); // 6 per Knuth-Plass below.
+ setWidth('J', 9);
+ setWidth('K', 15);
+ setWidth('L', 12);
+ setWidth('M', 18);
+ setWidth('N', 15);
+ setWidth('O', 13);
+ setWidth('P', 12);
+ setWidth('Q', 13);
+ setWidth('R', 14);
+ setWidth('S', 10);
+ setWidth('T', 13);
+ setWidth('U', 14);
+ setWidth('V', 13);
+ setWidth('W', 18);
+ setWidth('X', 15);
+ setWidth('Y', 14);
+ setWidth('Z', 11);
+
+ setWidth('a', 9);
+ setWidth('b', 10);
+ setWidth('c', 8);
+ setWidth('d', 10);
+ setWidth('e', 8);
+ setWidth('f', 6);
+ setWidth('g', 9);
+ setWidth('h', 10);
+ setWidth('i', 5);
+ setWidth('j', 6);
+ setWidth('k', 10);
+ setWidth('l', 5);
+ setWidth('m', 15);
+ setWidth('n', 10);
+ setWidth('o', 9);
+ setWidth('p', 10);
+ setWidth('q', 10);
+ setWidth('r', 7);
+ setWidth('s', 7);
+ setWidth('t', 7);
+ setWidth('u', 10);
+ setWidth('v', 10); // 9 per Knuth-Plass below.
+ setWidth('w', 13);
+ setWidth('x', 9); // 10 per Knuth-Plass below.
+ setWidth('y', 10);
+ setWidth('z', 8);
+
+
+ if (adjustToKnuthPlass) {
+ setWidth('-', 6);
+ setWidth(';', 5);
+ setWidth('I', 6);
+ setWidth('v', 9);
+ setWidth('x', 10);
+ }
+ }
+
+ @Override
+ public int getUnitsPerEm() {
+ return 18;
+ }
+
+}
Property changes on: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockMonotypeFont.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/package-info.java
===================================================================
--- trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/package-info.java (rev 0)
+++ trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/package-info.java 2023-01-26 21:38:12 UTC (rev 13092)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2023 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/**
+ * Test fixtures related to foray-font.
+ */
+package org.foray.font.fixture;
Property changes on: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/package-info.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-linebreak/build.gradle
===================================================================
--- trunk/foray/foray-linebreak/build.gradle 2023-01-26 17:04:26 UTC (rev 13091)
+++ trunk/foray/foray-linebreak/build.gradle 2023-01-26 21:38:12 UTC (rev 13092)
@@ -18,10 +18,9 @@
testImplementation (group: "org.axsl", name: "axsl-orthography", version: versions.axsl)
testImplementation (group: "org.axsl", name: "axsl-ps", version: versions.axsl)
testImplementation (project(":foray-ps-data"))
+ testImplementation (project(":foray-font-tf"))
- testImplementation (testFixtures(group: "org.axsl", name: "axsl-font", version: versions.axsl))
testImplementation (testFixtures(group: "org.axsl", name: "axsl-kp-model", version: versions.axsl))
- testImplementation (testFixtures(project(":foray-font")))
}
javadoc {
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-26 17:04:26 UTC (rev 13091)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-26 21:38:12 UTC (rev 13092)
@@ -28,11 +28,11 @@
package org.foray.linebreak;
+import org.foray.font.fixture.MockFontUse;
import org.foray.font.fixture.MockMonotypeFont;
import org.foray.orthography.Punctuation4a;
import org.axsl.context.LineBreakContext;
-import org.axsl.font.fixture.MockFontUse;
import org.axsl.kp.KpBoxTf;
import org.axsl.kp.KpBranchTf;
import org.axsl.kp.KpContext;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-26 17:04:29
|
Revision: 13091
http://sourceforge.net/p/foray/code/13091
Author: victormote
Date: 2023-01-26 17:04:26 +0000 (Thu, 26 Jan 2023)
Log Message:
-----------
Rough-in new foray-font-tf project.
Modified Paths:
--------------
trunk/foray/settings.gradle
Added Paths:
-----------
trunk/foray/foray-font-tf/
trunk/foray/foray-font-tf/build.gradle
trunk/foray/foray-font-tf/src/
trunk/foray/foray-font-tf/src/main/
trunk/foray/foray-font-tf/src/main/java/
trunk/foray/foray-font-tf/src/main/java/org/
trunk/foray/foray-font-tf/src/main/java/org/foray/
trunk/foray/foray-font-tf/src/main/java/org/foray/font/
trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/
Added: trunk/foray/foray-font-tf/build.gradle
===================================================================
--- trunk/foray/foray-font-tf/build.gradle (rev 0)
+++ trunk/foray/foray-font-tf/build.gradle 2023-01-26 17:04:26 UTC (rev 13091)
@@ -0,0 +1,19 @@
+plugins {
+ id 'foray.library-conventions'
+}
+
+description = 'foray-font-tf'
+
+
+dependencies {
+ api (group: 'org.axsl', name: 'axsl-font', version: versions.axsl)
+}
+
+
+javadoc {
+ options.windowTitle = "FOray Font Test Fixtures API"
+ options.docTitle = "FOray Font Test Fixtures API"
+ options.header = "FOray Font Test Fixtures API ${version}"
+}
+
+/* Last line of script. */
Property changes on: trunk/foray/foray-font-tf/build.gradle
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/settings.gradle
===================================================================
--- trunk/foray/settings.gradle 2023-01-25 22:20:55 UTC (rev 13090)
+++ trunk/foray/settings.gradle 2023-01-26 17:04:26 UTC (rev 13091)
@@ -25,4 +25,7 @@
include 'foray-xml'
include 'foray-zz-attic'
+/* Test fixture projects. */
+include 'foray-font-tf'
+
/* Last line of script. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-25 22:20:57
|
Revision: 13090
http://sourceforge.net/p/foray/code/13090
Author: victormote
Date: 2023-01-25 22:20:55 +0000 (Wed, 25 Jan 2023)
Log Message:
-----------
Improvements to linebreak test infrastructure.
Modified Paths:
--------------
trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
Modified: trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java
===================================================================
--- trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-24 14:11:31 UTC (rev 13089)
+++ trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-25 22:20:55 UTC (rev 13090)
@@ -64,9 +64,9 @@
setWidth(' ', 6);
setWidth('’', 5);
setWidth(',', 5);
- setWidth('-', 5);
+ setWidth('-', 5); // 6 per Knuth-Plass below.
setWidth('.', 5);
- setWidth(';', 6);
+ setWidth(';', 6); // 5 per Knuth-Plass below.
setWidth('A', 13);
setWidth('B', 13);
@@ -76,7 +76,7 @@
setWidth('F', 12);
setWidth('G', 14);
setWidth('H', 15);
- setWidth('I', 8);
+ setWidth('I', 8); // 6 per Knuth-Plass below.
setWidth('J', 9);
setWidth('K', 15);
setWidth('L', 12);
@@ -116,9 +116,9 @@
setWidth('s', 7);
setWidth('t', 7);
setWidth('u', 10);
- setWidth('v', 10);
+ setWidth('v', 10); // 9 per Knuth-Plass below.
setWidth('w', 13);
- setWidth('x', 9);
+ setWidth('x', 9); // 10 per Knuth-Plass below.
setWidth('y', 10);
setWidth('z', 8);
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-24 14:11:31 UTC (rev 13089)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-25 22:20:55 UTC (rev 13090)
@@ -32,7 +32,6 @@
import org.foray.orthography.Punctuation4a;
import org.axsl.context.LineBreakContext;
-import org.axsl.font.fixture.MockFont;
import org.axsl.font.fixture.MockFontUse;
import org.axsl.kp.KpBoxTf;
import org.axsl.kp.KpBranchTf;
@@ -98,247 +97,247 @@
// Index Qty Width Width
// ------ --- ----- -----
para.addNode(new KpBoxTf(18)); // 0 1 18 18 Empty box (indent)
- para.addWord("In"); // 1 1 16 34 6+10
- para.addSpace(); // 2 1 6 40
- para.addWord("olden"); // 3 1 42 82 9+5+10+8+10
- para.addSpace(); // 4 1 6 88
- para.addWord("times"); // 5 1 42 130 7+5+15+8+7
- para.addSpace(); // 6 1 6 136
- para.addWord("when"); // 7 1 41 177 13+10+8+10
- para.addSpace(); // 8 1 6 183
- para.addWord("wish-ing"); // 9 3 59 242 13+5+7+10 5+10+9
- para.addSpace(); // 12 1 6 248
- para.addWord("still"); // 13 1 29 277 7+7+5+5+5
- para.addSpace(); // 14 1 6 283
- para.addWord("helped"); // 15 1 51 334 10+8+5+10+8+10
- para.addSpace(); // 16 1 6 340
- para.addWord("one"); // 17 1 27 367 9+10+8
- para.addNode(Punctuation4a.COMMA); // 18 1 5 372
- para.addSpace(); // 19 1 6 378
- para.addWord("there"); // 20 1 40 418 7+10+8+7+8
- para.addSpace(); // 21 1 6 424
- para.addWord("lived"); // 22 1 37 461 5+5+9+8+10
- para.addSpace(); // 23 1 6 467
- para.addWord("a"); // 24 1 9 476 9
- para.addSpace(); // 25 1 6 482
- para.addWord("king"); // 26 1 34 516 10+5+10+9
- para.addSpace(); // 27 1 6 522
- para.addWord("whose"); // 28 1 47 569 13+10+9+7+8
- para.addSpace(); // 29 1 6 575
- para.addWord("daugh-ters"); // 30 3 77 652 10+9+10+9+10 7+8+7+7
- para.addSpace(); // 33 1 6 658
- para.addWord("were"); // 34 1 36 694 13+8+7+8
- para.addSpace(); // 35 1 6 700
- para.addWord("all"); // 36 1 19 719 9+5+5
- para.addSpace(); // 37 1 6 725
- para.addWord("beau-ti-ful"); // 38 5 70 795 10+8+9+10 7+5 6+10+5
- para.addNode(Punctuation4a.SEMICOLON); // 43 1 5 800
- para.addSpace(); // 44 1 6 806
- para.addWord("and"); // 45 1 29 835 9+10+10
- para.addSpace(); // 46 1 6 841
- para.addWord("the"); // 47 1 25 866 7+10+8
- para.addSpace(); // 48 1 6 872
- para.addWord("young-est"); // 49 3 60 932 10+9+10+10+9 8+7+7
- para.addSpace(); // 52 1 6 938
- para.addWord("was"); // 53 1 29 967 13+9+7
- para.addSpace(); // 54 1 6 973
- para.addWord("so"); // 55 1 16 989 7+9
- para.addSpace(); // 56 1 6 995
- para.addWord("beau-ti-ful"); // 57 5 70 1065 10+8+9+10 7+5 6+10+5
- para.addSpace(); // 62 1 6 1071
- para.addWord("that"); // 63 1 33 1104 7+10+9+7
- para.addSpace(); // 64 1 6 1110
- para.addWord("the"); // 65 1 25 1135 7+10+8
- para.addSpace(); // 66 1 6 1141
- para.addWord("sun"); // 67 1 27 1168 7+10+10
- para.addSpace(); // 68 1 6 1174
- para.addWord("it-self"); // 69 3
- para.addNode(Punctuation4a.COMMA); // 72 1
- para.addSpace(); // 73 1 6
- para.addWord("which"); // 74 1
- para.addSpace(); // 75 1 6
- para.addWord("has"); // 76 1
- para.addSpace(); // 77 1 6
- para.addWord("seen"); // 78 1
- para.addSpace(); // 79 1 6
- para.addWord("so"); // 80 1
- para.addSpace(); // 81 1 6
- para.addWord("much"); // 82 1
- para.addNode(Punctuation4a.COMMA); // 83 1
- para.addSpace(); // 84 1 6
- para.addWord("was"); // 85 1
- para.addSpace(); // 86 1 6
- para.addWord("aston-ished"); // 87 3
- para.addSpace(); // 90 1 6
- para.addWord("when-ever"); // 91 3
- para.addSpace(); // 94 1 6
- para.addWord("it"); // 95 1
- para.addSpace(); // 96 1 6
- para.addWord("shone"); // 97 1
- para.addSpace(); // 98 1 6
- para.addWord("in"); // 99 1
- para.addSpace(); // 100 1 6
- para.addWord("her"); // 101 1
- para.addSpace(); // 102 1 6
- para.addWord("face"); // 103 1
- para.addNode(Punctuation4a.PERIOD); // 104 1
- para.addSpace(); // 105 1 6
- para.addWord("Close"); // 106 1
- para.addSpace(); // 107 1 6
- para.addWord("by"); // 108 1
- para.addSpace(); // 109 1 6
- para.addWord("the"); // 110 1
- para.addSpace(); // 111 1 6
- para.addWord("king’s"); // 112 1
- para.addSpace(); // 113 1 6
- para.addWord("castle"); // 114 1
- para.addSpace(); // 115 1 6
- para.addWord("lay"); // 116 1
- para.addSpace(); // 117 1 6
- para.addWord("a"); // 118 1
- para.addSpace(); // 119 1 6
- para.addWord("great"); // 120 1
- para.addSpace(); // 121 1 6
- para.addWord("dark"); // 122 1
- para.addSpace(); // 123 1 6
- para.addWord("for-est"); // 124 3
- para.addNode(Punctuation4a.COMMA); // 127 1
- para.addSpace(); // 128 1 6
- para.addWord("and"); // 129 1
- para.addSpace(); // 130 1 6
- para.addWord("un-der"); // 131 3
- para.addSpace(); // 134 1 6
- para.addWord("an"); // 135 1
- para.addSpace(); // 136 1 6
- para.addWord("old"); // 137 1
- para.addSpace(); // 138 1 6
- para.addWord("lime"); // 139 1
- para.addNode(Punctuation4a.MANDATORY_HYPHEN); // 140 1
- para.addNode(new KpPenaltyTf(0, 50, true)); // 141 1
- para.addWord("tree"); // 142 1
- para.addSpace(); // 143 1 6
- para.addWord("in"); // 144 1
- para.addSpace(); // 145 1 6
- para.addWord("the"); // 146 1
- para.addSpace(); // 147 1 6
- para.addWord("for-est"); // 148 3
- para.addSpace(); // 151 1 6
- para.addWord("was"); // 152 1
- para.addSpace(); // 153 1 6
- para.addWord("a"); // 154 1
- para.addSpace(); // 155 1 6
- para.addWord("well"); // 156 1
- para.addNode(Punctuation4a.COMMA); // 157 1
- para.addSpace(); // 158 1 6
- para.addWord("and"); // 159 1
- para.addSpace(); // 160 1 6
- para.addWord("when"); // 161 1
- para.addSpace(); // 162 1 6
- para.addWord("the"); // 163 1
- para.addSpace(); // 164 1 6
- para.addWord("day"); // 165 1
- para.addSpace(); // 166 1 6
- para.addWord("was"); // 167 1
- para.addSpace(); // 168 1 6
- para.addWord("very"); // 169 1
- para.addSpace(); // 170 1 6
- para.addWord("warm"); // 171 1
- para.addNode(Punctuation4a.COMMA); // 172 1
- para.addSpace(); // 173 1 6
- para.addWord("the"); // 174 1
- para.addSpace(); // 175 1 6
- para.addWord("king’s"); // 176 1
- para.addSpace(); // 177 1 6
- para.addWord("child"); // 178 1
- para.addSpace(); // 179 1 6
- para.addWord("went"); // 180 1
- para.addSpace(); // 181 1 6
- para.addWord("out"); // 182 1
- para.addSpace(); // 183 1 6
- para.addWord("into"); // 184 1
- para.addSpace(); // 185 1 6
- para.addWord("the"); // 186 1
- para.addSpace(); // 187 1 6
- para.addWord("for-est"); // 188 3
- para.addSpace(); // 191 1 6
- para.addWord("and"); // 192 1
- para.addSpace(); // 193 1 6
- para.addWord("sat"); // 194 1
- para.addSpace(); // 195 1 6
- para.addWord("down"); // 196 1
- para.addSpace(); // 197 1 6
- para.addWord("by"); // 198 1
- para.addSpace(); // 199 1 6
- para.addWord("the"); // 200 1
- para.addSpace(); // 201 1 6
- para.addWord("side"); // 202 1
- para.addSpace(); // 203 1 6
- para.addWord("of"); // 204 1
- para.addSpace(); // 205 1 6
- para.addWord("the"); // 206 1
- para.addSpace(); // 207 1 6
- para.addWord("cool"); // 208 1
- para.addSpace(); // 209 1 6
- para.addWord("foun-tain"); // 210 3
- para.addNode(Punctuation4a.SEMICOLON); // 213 1
- para.addSpace(); // 214 1 6
- para.addWord("and"); // 215 1
- para.addSpace(); // 216 1 6
- para.addWord("when"); // 217 1
- para.addSpace(); // 218 1 6
- para.addWord("she"); // 219 1
- para.addSpace(); // 220 1 6
- para.addWord("was"); // 221 1
- para.addSpace(); // 222 1 6
- para.addWord("bored"); // 223 1
- para.addSpace(); // 224 1 6
- para.addWord("she"); // 225 1
- para.addSpace(); // 226 1 6
- para.addWord("took"); // 227 1
- para.addSpace(); // 228 1 6
- para.addWord("a"); // 229 1
- para.addSpace(); // 230 1 6
- para.addWord("golden"); // 231 1
- para.addSpace(); // 232 1 6
- para.addWord("ball"); // 233 1
- para.addNode(Punctuation4a.COMMA); // 234 1
- para.addSpace(); // 235 1 6
- para.addWord("and"); // 236 1
- para.addSpace(); // 237 1 6
- para.addWord("threw"); // 238 1
- para.addSpace(); // 239 1 6
- para.addWord("it"); // 240 1
- para.addSpace(); // 241 1 6
- para.addWord("up"); // 242 1
- para.addSpace(); // 243 1 6
- para.addWord("on"); // 244 1
- para.addSpace(); // 245 1 6
- para.addWord("high"); // 246 1
- para.addSpace(); // 247 1 6
- para.addWord("and"); // 248 1
- para.addSpace(); // 249 1 6
- para.addWord("caught"); // 250 1
- para.addSpace(); // 251 1 6
- para.addWord("it"); // 252 1
- para.addNode(Punctuation4a.SEMICOLON); // 253 1
- para.addSpace(); // 254 1 6
- para.addWord("and"); // 255 1
- para.addSpace(); // 256 1 6
- para.addWord("this"); // 257 1
- para.addSpace(); // 258 1 6
- para.addWord("ball"); // 259 1
- para.addSpace(); // 260 1 6
- para.addWord("was"); // 261 1
- para.addSpace(); // 262 1 6
- para.addWord("her"); // 263 1
- para.addSpace(); // 264 1 6
- para.addWord("favor-ite"); // 265 3
- para.addSpace(); // 268 1 6
- para.addWord("play-thing"); // 269 3
- para.addNode(Punctuation4a.PERIOD); // 272 1
- para.addNode(KpPenaltyTf.DISALLOWED_BREAK); // 273 1
- para.addNode(KpGlue.FINISHING_GLUE); // 274 1
- para.addNode(KpPenalty.FORCED_BREAK); // 275 1
+ para.addWord("In"); // 1 1 18 36 8+10
+ para.addSpace(); // 2 1 6 42
+ para.addWord("olden"); // 3 1 42 84 9+5+10+8+10
+ para.addSpace(); // 4 1 6 90
+ para.addWord("times"); // 5 1 42 132 7+5+15+8+7
+ para.addSpace(); // 6 1 6 138
+ para.addWord("when"); // 7 1 41 179 13+10+8+10
+ para.addSpace(); // 8 1 6 185
+ para.addWord("wish-ing"); // 9 3 59 244 13+5+7+10 5+10+9
+ para.addSpace(); // 12 1 6 250
+ para.addWord("still"); // 13 1 29 279 7+7+5+5+5
+ para.addSpace(); // 14 1 6 285
+ para.addWord("helped"); // 15 1 51 336 10+8+5+10+8+10
+ para.addSpace(); // 16 1 6 342
+ para.addWord("one"); // 17 1 27 369 9+10+8
+ para.addNode(Punctuation4a.COMMA); // 18 1 5 374
+ para.addSpace(); // 19 1 6 380
+ para.addWord("there"); // 20 1 40 420 7+10+8+7+8
+ para.addSpace(); // 21 1 6 426
+ para.addWord("lived"); // 22 1 37 463 5+5+9+8+10
+ para.addSpace(); // 23 1 6 469
+ para.addWord("a"); // 24 1 9 478 9
+ para.addSpace(); // 25 1 6 484
+ para.addWord("king"); // 26 1 34 518 10+5+10+9
+ para.addSpace(); // 27 1 6 524
+ para.addWord("whose"); // 28 1 47 571 13+10+9+7+8
+ para.addSpace(); // 29 1 6 577
+ para.addWord("daugh-ters"); // 30 3 77 654 10+9+10+9+10 7+8+7+7
+ para.addSpace(); // 33 1 6 660
+ para.addWord("were"); // 34 1 36 696 13+8+7+8
+ para.addSpace(); // 35 1 6 702
+ para.addWord("all"); // 36 1 19 721 9+5+5
+ para.addSpace(); // 37 1 6 727
+ para.addWord("beau-ti-ful"); // 38 5 70 797 10+8+9+10 7+5 6+10+5
+ para.addNode(Punctuation4a.SEMICOLON); // 43 1 5 802
+ para.addSpace(); // 44 1 6 808
+ para.addWord("and"); // 45 1 29 837 9+10+10
+ para.addSpace(); // 46 1 6 843
+ para.addWord("the"); // 47 1 25 868 7+10+8
+ para.addSpace(); // 48 1 6 874
+ para.addWord("young-est"); // 49 3 70 944 10+9+10+10+9 8+7+7
+ para.addSpace(); // 52 1 6 950
+ para.addWord("was"); // 53 1 29 979 13+9+7
+ para.addSpace(); // 54 1 6 985
+ para.addWord("so"); // 55 1 16 1001 7+9
+ para.addSpace(); // 56 1 6 1007
+ para.addWord("beau-ti-ful"); // 57 5 70 1077 10+8+9+10 7+5 6+10+5
+ para.addSpace(); // 62 1 6 1083
+ para.addWord("that"); // 63 1 33 1116 7+10+9+7
+ para.addSpace(); // 64 1 6 1122
+ para.addWord("the"); // 65 1 25 1147 7+10+8
+ para.addSpace(); // 66 1 6 1153
+ para.addWord("sun"); // 67 1 27 1180 7+10+10
+ para.addSpace(); // 68 1 6 1186
+ para.addWord("it-self"); // 69 3 38 1224 5+7 7+8+5+6
+ para.addNode(Punctuation4a.COMMA); // 72 1 5 1229
+ para.addSpace(); // 73 1 6 1235
+ para.addWord("which"); // 74 1 46 1281 13+10+5+8+10
+ para.addSpace(); // 75 1 6 1287
+ para.addWord("has"); // 76 1 26 1313 10+9+7
+ para.addSpace(); // 77 1 6 1319
+ para.addWord("seen"); // 78 1 33 1352 7+8+8+10
+ para.addSpace(); // 79 1 6 1358
+ para.addWord("so"); // 80 1 16 1374 7+9
+ para.addSpace(); // 81 1 6 1380
+ para.addWord("much"); // 82 1 43 1423 15+10+8+10
+ para.addNode(Punctuation4a.COMMA); // 83 1 5 1428
+ para.addSpace(); // 84 1 6 1434
+ para.addWord("was"); // 85 1 29 1463 13+9+7
+ para.addSpace(); // 86 1 6 1469
+ para.addWord("aston-ished"); // 87 3 82 1551 9+7+7+9+10 5+7+10+8+10
+ para.addSpace(); // 90 1 6 1557
+ para.addWord("when-ever"); // 91 3 73 1630 13+10+8+10 8+9+8+7
+ para.addSpace(); // 94 1 6 1636
+ para.addWord("it"); // 95 1 12 1648 5+7
+ para.addSpace(); // 96 1 6 1654
+ para.addWord("shone"); // 97 1 44 1698 7+10+9+10+8
+ para.addSpace(); // 98 1 6 1704
+ para.addWord("in"); // 99 1 15 1719 5+10
+ para.addSpace(); // 100 1 6 1725
+ para.addWord("her"); // 101 1 25 1750 10+8+7
+ para.addSpace(); // 102 1 6 1756
+ para.addWord("face"); // 103 1 31 1787 6+9+8+8
+ para.addNode(Punctuation4a.PERIOD); // 104 1 5 1792
+ para.addSpace(); // 105 1 6 1798
+ para.addWord("Close"); // 106 1 42 1840 13+5+9+7+8
+ para.addSpace(); // 107 1 6 1846
+ para.addWord("by"); // 108 1 20 1866 10+10
+ para.addSpace(); // 109 1 6 1872
+ para.addWord("the"); // 110 1 25 1897 7+10+8
+ para.addSpace(); // 111 1 6 1903
+ para.addWord("king’s"); // 112 1 46 1949 10+5+10+9+5+7
+ para.addSpace(); // 113 1 6 1955
+ para.addWord("castle"); // 114 1 44 1999 8+9+7+7+5+8
+ para.addSpace(); // 115 1 6 2005
+ para.addWord("lay"); // 116 1 24 2029 5+9+10
+ para.addSpace(); // 117 1 6 2035
+ para.addWord("a"); // 118 1 9 2044 9
+ para.addSpace(); // 119 1 6 2050
+ para.addWord("great"); // 120 1 40 2090 9+7+8+9+7
+ para.addSpace(); // 121 1 6 2096
+ para.addWord("dark"); // 122 1 36 2132 10+9+7+10
+ para.addSpace(); // 123 1 6 2138
+ para.addWord("for-est"); // 124 3 44 2182 6+9+7 8+7+7
+ para.addNode(Punctuation4a.COMMA); // 127 1 5 2187
+ para.addSpace(); // 128 1 6 2193
+ para.addWord("and"); // 129 1 29 2222 9+10+10
+ para.addSpace(); // 130 1 6 2228
+ para.addWord("un-der"); // 131 3 45 2273 10+10 10+8+7
+ para.addSpace(); // 134 1 6 2279
+ para.addWord("an"); // 135 1 19 2298 9+10
+ para.addSpace(); // 136 1 6 2304
+ para.addWord("old"); // 137 1 24 2328 9+5+10
+ para.addSpace(); // 138 1 6 2334
+ para.addWord("lime"); // 139 1 33 2367 5+5+15+8
+ para.addNode(Punctuation4a.MANDATORY_HYPHEN); // 140 1 6 2373
+ para.addNode(new KpPenaltyTf(0, 50, true)); // 141 1 0 2373
+ para.addWord("tree"); // 142 1 30 2403 7+7+8+8
+ para.addSpace(); // 143 1 6 2409
+ para.addWord("in"); // 144 1 15 2424 5+10
+ para.addSpace(); // 145 1 6 2430
+ para.addWord("the"); // 146 1 25 2455 7+10+8
+ para.addSpace(); // 147 1 6 2461
+ para.addWord("for-est"); // 148 3 44 2505 6+9+7 8+7+7
+ para.addSpace(); // 151 1 6 2511
+ para.addWord("was"); // 152 1 29 2540 13+9+7
+ para.addSpace(); // 153 1 6 2546
+ para.addWord("a"); // 154 1 9 2555 9
+ para.addSpace(); // 155 1 6 2561
+ para.addWord("well"); // 156 1 31 2592 13+8+5+5
+ para.addNode(Punctuation4a.COMMA); // 157 1 5 2597
+ para.addSpace(); // 158 1 6 2603
+ para.addWord("and"); // 159 1 29 2632 9+10+10
+ para.addSpace(); // 160 1 6 2638
+ para.addWord("when"); // 161 1 41 2679 13+10+8+10
+ para.addSpace(); // 162 1 6 2685
+ para.addWord("the"); // 163 1 25 2710 7+10+8
+ para.addSpace(); // 164 1 6 2716
+ para.addWord("day"); // 165 1 29 2745 10+9+10
+ para.addSpace(); // 166 1 6 2751
+ para.addWord("was"); // 167 1 29 2780 13+9+7
+ para.addSpace(); // 168 1 6 2786
+ para.addWord("very"); // 169 1 34 2820 9+8+7+10
+ para.addSpace(); // 170 1 6 2826
+ para.addWord("warm"); // 171 1 44 2870 13+9+7+15
+ para.addNode(Punctuation4a.COMMA); // 172 1 5 2875
+ para.addSpace(); // 173 1 6 2881
+ para.addWord("the"); // 174 1 25 2906 7+10+8
+ para.addSpace(); // 175 1 6 2912
+ para.addWord("king’s"); // 176 1 46 2958 10+5+10+9+5+7
+ para.addSpace(); // 177 1 6 2964
+ para.addWord("child"); // 178 1 38 3002 8+10+5+5+10
+ para.addSpace(); // 179 1 6 3008
+ para.addWord("went"); // 180 1 38 3046 13+8+10+7
+ para.addSpace(); // 181 1 6 3052
+ para.addWord("out"); // 182 1 26 3078 9+10+7
+ para.addSpace(); // 183 1 6 3084
+ para.addWord("into"); // 184 1 31 3115 5+10+7+9
+ para.addSpace(); // 185 1 6 3121
+ para.addWord("the"); // 186 1 25 3146 7+10+8
+ para.addSpace(); // 187 1 6 3152
+ para.addWord("for-est"); // 188 3 44 3196 6+9+7 8+7+7
+ para.addSpace(); // 191 1 6 3202
+ para.addWord("and"); // 192 1 29 3231 9+10+10
+ para.addSpace(); // 193 1 6 3237
+ para.addWord("sat"); // 194 1 23 3260 7+9+7
+ para.addSpace(); // 195 1 6 3266
+ para.addWord("down"); // 196 1 42 3308 10+9+13+10
+ para.addSpace(); // 197 1 6 3314
+ para.addWord("by"); // 198 1 20 3334 10+10
+ para.addSpace(); // 199 1 6 3340
+ para.addWord("the"); // 200 1 25 3365 7+10+8
+ para.addSpace(); // 201 1 6 3371
+ para.addWord("side"); // 202 1 30 3401 7+5+10+8
+ para.addSpace(); // 203 1 6 3407
+ para.addWord("of"); // 204 1 15 3422 9+6
+ para.addSpace(); // 205 1 6 3428
+ para.addWord("the"); // 206 1 25 3453 7+10+8
+ para.addSpace(); // 207 1 6 3459
+ para.addWord("cool"); // 208 1 31 3490 8+9+9+5
+ para.addSpace(); // 209 1 6 3496
+ para.addWord("foun-tain"); // 210 3 66 3562 6+9+10+10 7+9+5+10
+ para.addNode(Punctuation4a.SEMICOLON); // 213 1 5 3567
+ para.addSpace(); // 214 1 6 3573
+ para.addWord("and"); // 215 1 29 3602 9+10+10
+ para.addSpace(); // 216 1 6 3608
+ para.addWord("when"); // 217 1 41 3649 13+10+8+10
+ para.addSpace(); // 218 1 6 3655
+ para.addWord("she"); // 219 1 25 3680 7+10+8
+ para.addSpace(); // 220 1 6 3686
+ para.addWord("was"); // 221 1 29 3715 13+9+7
+ para.addSpace(); // 222 1 6 3721
+ para.addWord("bored"); // 223 1 44 3765 10+9+7+8+10
+ para.addSpace(); // 224 1 6 3771
+ para.addWord("she"); // 225 1 25 3796 7+10+8
+ para.addSpace(); // 226 1 6 3802
+ para.addWord("took"); // 227 1 35 3837 7+9+9+10
+ para.addSpace(); // 228 1 6 3843
+ para.addWord("a"); // 229 1 9 3852 9
+ para.addSpace(); // 230 1 6 3858
+ para.addWord("golden"); // 231 1 51 3909 9+9+5 10+8+10
+ para.addSpace(); // 232 1 6 3915
+ para.addWord("ball"); // 233 1 29 3944 10+9+5+5
+ para.addNode(Punctuation4a.COMMA); // 234 1 5 3949
+ para.addSpace(); // 235 1 6 3955
+ para.addWord("and"); // 236 1 29 3984 9+10+10
+ para.addSpace(); // 237 1 6 3990
+ para.addWord("threw"); // 238 1 45 4035 7+10+7+8+13
+ para.addSpace(); // 239 1 6 4041
+ para.addWord("it"); // 240 1 12 4053 5+7
+ para.addSpace(); // 241 1 6 4059
+ para.addWord("up"); // 242 1 20 4079 10+10
+ para.addSpace(); // 243 1 6 4085
+ para.addWord("on"); // 244 1 19 4104 9+10
+ para.addSpace(); // 245 1 6 4110
+ para.addWord("high"); // 246 1 34 4144 10+5+9+10
+ para.addSpace(); // 247 1 6 4150
+ para.addWord("and"); // 248 1 29 4179 9+10+10
+ para.addSpace(); // 249 1 6 4185
+ para.addWord("caught"); // 250 1 53 4238 8+9+10+9+10+7
+ para.addSpace(); // 251 1 6 4244
+ para.addWord("it"); // 252 1 12 4256 5+7
+ para.addNode(Punctuation4a.SEMICOLON); // 253 1 5 4261
+ para.addSpace(); // 254 1 6 4267
+ para.addWord("and"); // 255 1 29 4296 9+10+10
+ para.addSpace(); // 256 1 6 4302
+ para.addWord("this"); // 257 1 29 4331 7+10+5+7
+ para.addSpace(); // 258 1 6 4337
+ para.addWord("ball"); // 259 1 29 4366 10+9+5+5
+ para.addSpace(); // 260 1 6 4372
+ para.addWord("was"); // 261 1 29 4401 13+9+7
+ para.addSpace(); // 262 1 6 4407
+ para.addWord("her"); // 263 1 25 4432 10+8+7
+ para.addSpace(); // 264 1 6 4438
+ para.addWord("favor-ite"); // 265 3 60 4498 6+9+9+9+7 5+7+8
+ para.addSpace(); // 268 1 6 4504
+ para.addWord("play-thing"); // 269 3 75 4579 10+5+9+10 7+10+5+10+9
+ para.addNode(Punctuation4a.PERIOD); // 272 1 5 4584
+ para.addNode(KpPenaltyTf.DISALLOWED_BREAK); // 273 1 0 4584
+ para.addNode(KpGlue.FINISHING_GLUE); // 274 1 0 4584
+ para.addNode(KpPenalty.FORCED_BREAK); // 275 1 0 4584
/* There are 242 lines of code creating the paragraph.
* Each of them adds exactly one node. */
@@ -370,7 +369,7 @@
* @return The Monotype paragraph configuration.
*/
public KpContext4a createGrimmParaConfig() {
- final MockFont font = new MockMonotypeFont(true);
+ final MockMonotypeFont font = new MockMonotypeFont(true);
final MockFontUse fontUse = new MockFontUse();
fontUse.setFont(font);
/* Stretchability and shrinkability come from the interword values in Table 1. Note that different values are
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-24 14:11:37
|
Revision: 13089
http://sourceforge.net/p/foray/code/13089
Author: victormote
Date: 2023-01-24 14:11:31 +0000 (Tue, 24 Jan 2023)
Log Message:
-----------
Fix and enable tests that failed due to JVM differences.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java 2023-01-24 13:31:06 UTC (rev 13088)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java 2023-01-24 14:11:31 UTC (rev 13089)
@@ -35,10 +35,10 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
@@ -189,31 +189,21 @@
* Test of {@link SegmentDictionaryWord#subSequence(int, int)}.
*/
@Test
- @Disabled
public void subSequenceTests() {
final SegmentDictionaryWord word = dictionary.getWord("ambition", 0);
assertEquals("mbi", word.subSequence(1, 4));
- try {
+
+ assertThrows(IndexOutOfBoundsException.class, () -> {
word.subSequence(-1, 4);
- fail("Expected: " + IndexOutOfBoundsException.class.getName());
- } catch (final IndexOutOfBoundsException e) {
- /* This is the expected path. */
- assertEquals("-1", e.getMessage());
- }
- try {
+ });
+
+ assertThrows(IndexOutOfBoundsException.class, () -> {
word.subSequence(5, 8);
- fail("Expected: " + IndexOutOfBoundsException.class.getName());
- } catch (final IndexOutOfBoundsException e) {
- /* This is the expected path. */
- assertEquals("8", e.getMessage());
- }
- try {
+ });
+
+ assertThrows(IndexOutOfBoundsException.class, () -> {
word.subSequence(4, 1);
- fail("Expected: " + IndexOutOfBoundsException.class.getName());
- } catch (final IndexOutOfBoundsException e) {
- /* This is the expected path. */
- assertEquals("String index out of range: -3", e.getMessage());
- }
+ });
}
/**
@@ -336,7 +326,6 @@
* Test of {@link SegmentDictionaryWord#getWordComponent(int)}.
*/
@Test
- @Disabled
public void getWordComponentTests() {
final SegmentDictionaryWord word = dictionary.getWord("ambition", 0);
assertEquals("am", word.wordComponentAt(0).toString());
@@ -344,20 +333,14 @@
assertEquals("bi", word.wordComponentAt(2).toString());
assertEquals("-", word.wordComponentAt(3).toString());
assertEquals("tion", word.wordComponentAt(4).toString());
- try {
+
+ assertThrows(IndexOutOfBoundsException.class, () -> {
word.wordSegmentAt(-1);
- fail("Expected: " + IndexOutOfBoundsException.class.getName());
- } catch (final IndexOutOfBoundsException e) {
- /* This is the expected path. */
- assertEquals("-1", e.getMessage());
- }
- try {
+ });
+
+ assertThrows(IndexOutOfBoundsException.class, () -> {
word.wordSegmentAt(5);
- fail("Expected: " + IndexOutOfBoundsException.class.getName());
- } catch (final IndexOutOfBoundsException e) {
- /* This is the expected path. */
- assertEquals("5", e.getMessage());
- }
+ });
}
}
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java 2023-01-24 13:31:06 UTC (rev 13088)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java 2023-01-24 14:11:31 UTC (rev 13089)
@@ -36,10 +36,10 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -133,7 +133,6 @@
* Test method for {@link org.foray.orthography.WordWrapper#subSequence(int, int)}.
*/
@Test
- @Disabled
public void testSubSequence() {
assertEquals("moni", this.out.subSequence(3, 7));
try {
@@ -150,13 +149,10 @@
/* This is the expected path. */
assertEquals("13", e.getMessage());
}
- try {
+
+ assertThrows(StringIndexOutOfBoundsException.class, () -> {
this.out.subSequence(4, 1);
- fail("Expected: " + IndexOutOfBoundsException.class.getName());
- } catch (final IndexOutOfBoundsException e) {
- /* This is the expected path. */
- assertEquals("String index out of range: -3", e.getMessage());
- }
+ });
}
/**
@@ -235,7 +231,6 @@
* Test method for {@link org.foray.orthography.WordWrapper#getWordComponent(int)}.
*/
@Test
- @Disabled
public void testGetWordComponent() {
assertEquals("har", this.out.wordComponentAt(0).toString());
assertEquals("-", this.out.wordComponentAt(1).toString());
@@ -244,20 +239,14 @@
assertEquals("ni", this.out.wordComponentAt(4).toString());
assertEquals("-", this.out.wordComponentAt(5).toString());
assertEquals("ous", this.out.wordComponentAt(6).toString());
- try {
+
+ assertThrows(IndexOutOfBoundsException.class, () -> {
this.out.wordSegmentAt(-1);
- fail("Expected: " + IndexOutOfBoundsException.class.getName());
- } catch (final IndexOutOfBoundsException e) {
- /* This is the expected path. */
- assertEquals("-1", e.getMessage());
- }
- try {
+ });
+
+ assertThrows(IndexOutOfBoundsException.class, () -> {
this.out.wordSegmentAt(5);
- fail("Expected: " + IndexOutOfBoundsException.class.getName());
- } catch (final IndexOutOfBoundsException e) {
- /* This is the expected path. */
- assertEquals("5", e.getMessage());
- }
+ });
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-24 13:31:11
|
Revision: 13088
http://sourceforge.net/p/foray/code/13088
Author: victormote
Date: 2023-01-24 13:31:06 +0000 (Tue, 24 Jan 2023)
Log Message:
-----------
Upgrade checkstyle to 10.4. Remove check for unnecessary parentheses. Adjust to checkstyle complaints resulting from the new version.
Modified Paths:
--------------
trunk/foray/buildSrc/src/main/groovy/foray.common-conventions.gradle
trunk/foray/foray-00-master/config/checkstyle/checkstyle-config.xml
trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/ForayEntityResolver.java
trunk/foray/foray-common/src/main/java/org/foray/common/data/BoundingBoxFloat.java
trunk/foray/foray-common/src/main/java/org/foray/common/data/BoundingBoxShort.java
trunk/foray/foray-common/src/main/java/org/foray/common/data/TernaryNodes.java
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfLookupGsub.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/NamespaceNative.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/AbstractIndent.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdBlankOrNotBlank.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtFrequency.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtLength.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtTime.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PdfaNode.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java
trunk/foray/foray-mif/src/main/java/org/foray/mif/MifBook.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Lexer4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/PosUtils.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/NaturalLanguage.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternParser.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/Status.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/CharacterUtils.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/AsciiHexEncodeFilter.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
Modified: trunk/foray/buildSrc/src/main/groovy/foray.common-conventions.gradle
===================================================================
--- trunk/foray/buildSrc/src/main/groovy/foray.common-conventions.gradle 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/buildSrc/src/main/groovy/foray.common-conventions.gradle 2023-01-24 13:31:06 UTC (rev 13088)
@@ -60,11 +60,12 @@
/* See foray-00-master/resources/logger-impl/00-readme.txt for information about logging implementations.
- Bottom line is that logging implementations are not and should not be part of any FOray dependencies. */
+ Bottom line is that logging implementations are not and should not be part of any FOray dependencies.
+ This entry can be uncommented temporarily for short-term testing, but should never be checked in. */
// logbackClassic: '1.3.5', // Latest is 1.3.5 as of 2022-11-26.
/* Build-time-only dependencies that should never be permanently used in build.gradle files. */
- checkstyle: '8.39', // Latest is 10.4 as of 2022-11-26.
+ checkstyle: '10.4', // Latest is 10.6 as of 2023-01-23. See Note 6.
]
/*
* Notes on Dependency Releases (See above for references)
@@ -85,6 +86,9 @@
* 5. Mockito versions from 4.6.0 to 4.9.0 cause breakage at build time for reasons that seem to be related to the
* Java version used to start Gradle. For now, using a JDK that matches the javaTargetCompatibility value above
* seems to solve the problem.
+ *
+ * 6. The current (as of 2023-01-23) Eclipse plugin for checkstyle uses Checkstyle 10.4.
+ * We will use that for now to avoid configuration conflicts between the two versions.
*/
Modified: trunk/foray/foray-00-master/config/checkstyle/checkstyle-config.xml
===================================================================
--- trunk/foray/foray-00-master/config/checkstyle/checkstyle-config.xml 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-00-master/config/checkstyle/checkstyle-config.xml 2023-01-24 13:31:06 UTC (rev 13088)
@@ -261,7 +261,10 @@
<module name="TrailingComment">
<property name="severity" value="ignore"/>
</module>
- <module name="UnnecessaryParentheses"/>
+ <module name="UnnecessaryParentheses">
+ <!-- We can consider adding a subset of these, but the defaults are too strict. -->
+ <property name="severity" value="ignore"/>
+ </module>
<module name="UpperEll"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround">
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -1116,7 +1116,7 @@
private boolean hasSurroundingSpace() {
final LineStackingStrategy lineStackingStrategy
= traitLineStackingStrategy();
- switch(lineStackingStrategy) {
+ switch (lineStackingStrategy) {
case FONT_HEIGHT:
case MAX_HEIGHT: {
return true;
@@ -1312,7 +1312,7 @@
int pd = this.nominalRequestedLrPd();
final LineStackingStrategy lineStackingStrategy
= traitLineStackingStrategy();
- switch(lineStackingStrategy) {
+ switch (lineStackingStrategy) {
case LINE_HEIGHT: {
/* The allocation-rectangle must be at least big enough to enclose
* the expanded-nominal-requested-line-rectangle, which is the
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/ForayEntityResolver.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/ForayEntityResolver.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/ForayEntityResolver.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -130,7 +130,7 @@
* or if the resource cannot be found.
*/
public InputStream getInputStream(final String publicId) {
- switch(publicId) {
+ switch (publicId) {
/* aXSL DTDs. */
case NATURAL_LANGUAGE_PUBLIC_ID: return getAxslDtdAsInputStream("axsl-natural-language.dtd");
case HYPHENATION_PUBLIC_ID: return getAxslDtdAsInputStream("axsl-hyphenation.dtd");
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/data/BoundingBoxFloat.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/data/BoundingBoxFloat.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/data/BoundingBoxFloat.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -88,7 +88,7 @@
@Override
public float getCoordinateAsFloat(final int index) {
- switch(index) {
+ switch (index) {
case BoundingBox.LOWER_LEFT_X_INDEX: return this.llx;
case BoundingBox.LOWER_LEFT_Y_INDEX: return this.lly;
case BoundingBox.UPPER_RIGHT_X_INDEX: return this.urx;
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/data/BoundingBoxShort.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/data/BoundingBoxShort.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/data/BoundingBoxShort.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -97,7 +97,7 @@
@Override
public short getCoordinateAsShort(final int index) {
- switch(index) {
+ switch (index) {
case BoundingBox.LOWER_LEFT_X_INDEX: return this.llx;
case BoundingBox.LOWER_LEFT_Y_INDEX: return this.lly;
case BoundingBox.UPPER_RIGHT_X_INDEX: return this.urx;
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/data/TernaryNodes.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/data/TernaryNodes.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/data/TernaryNodes.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -438,7 +438,7 @@
*/
public TernaryNode.Type getNodeType(final int index) {
final char keyChar = this.keyChar[index];
- switch(keyChar) {
+ switch (keyChar) {
case Character.MIN_VALUE: return TernaryNode.Type.UNCOMPRESSED_VALUE;
case Character.MAX_VALUE: return TernaryNode.Type.COMPRESSED_VALUE;
default: return TernaryNode.Type.CHARACTER;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -318,7 +318,7 @@
*/
public int estimateBaseline(final Font.WritingMode writingMode,
final Font.Baseline baselineType, final int fontSize) {
- switch(baselineType) {
+ switch (baselineType) {
case ALPHABETIC: {
return fontSize + this.getDescender(fontSize);
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -207,7 +207,7 @@
@Override
public void startElement(final String uri, final String localName, final String qName, final Attributes attributes)
throws SAXException {
- switch(localName) {
+ switch (localName) {
case "axsl-font-config": {
parseElementRoot(attributes);
return;
@@ -571,7 +571,7 @@
@Override
public void endElement(final String uri, final String localName, final String qName) {
- switch(localName) {
+ switch (localName) {
case "axsl-font-config": {
return;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfLookupGsub.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfLookupGsub.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfLookupGsub.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -161,9 +161,9 @@
final int formatId = raInput.readUnsignedShort();
- switch(lookupType) {
+ switch (lookupType) {
case SINGLE: {
- switch(formatId) {
+ switch (formatId) {
case FORMAT_1: return OtfLookupGsubx01x01.parse(raInput, offset);
case FORMAT_2: return OtfLookupGsubx01x02.parse(raInput, offset);
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 1: " + formatId);
@@ -170,22 +170,22 @@
}
}
case MULTIPLE:
- switch(formatId) {
+ switch (formatId) {
case FORMAT_1: return OtfLookupGsubx02x01.parse(raInput, offset);
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 2: " + formatId);
}
case ALTERNATE:
- switch(formatId) {
+ switch (formatId) {
case FORMAT_1: return OtfLookupGsubx03x01.parse(raInput, offset);
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 3: " + formatId);
}
case LIGATURE:
- switch(formatId) {
+ switch (formatId) {
case FORMAT_1: return OtfLookupGsubx04x01.parse(raInput, offset);
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 4: " + formatId);
}
case CONTEXT:
- switch(formatId) {
+ switch (formatId) {
case FORMAT_1: return OtfLookupGsubx05x01.parse(raInput, offset);
case FORMAT_2: return OtfLookupGsubx05x02.parse(raInput, offset);
case FORMAT_3: return OtfLookupGsubx05x03.parse(raInput, offset);
@@ -192,7 +192,7 @@
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 5: " + formatId);
}
case CHAINING_CONTEXT:
- switch(formatId) {
+ switch (formatId) {
case FORMAT_1: return OtfLookupGsubx06x01.parse(raInput, offset);
case FORMAT_2: return OtfLookupGsubx06x02.parse(raInput, offset);
case FORMAT_3: return OtfLookupGsubx06x03.parse(raInput, offset);
@@ -199,12 +199,12 @@
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 6: " + formatId);
}
case EXTENSION_SUBSTITUTION:
- switch(formatId) {
+ switch (formatId) {
case FORMAT_1: return OtfLookupGsubx07x01.parse(raInput, offset);
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 7: " + formatId);
}
case REVERSE_CHAINING_CONTEXT_SINGLE:
- switch(formatId) {
+ switch (formatId) {
case FORMAT_1: return OtfLookupGsubx08x01.parse(raInput, offset);
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 8: " + formatId);
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/NamespaceNative.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/NamespaceNative.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/NamespaceNative.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -67,7 +67,7 @@
if (namespaceUri == null) {
return null;
}
- switch(namespaceUri) {
+ switch (namespaceUri) {
case XmlConstants.XSLFO_NS_URI: return NamespaceFo.getInstance();
case javax.xml.XMLConstants.XML_NS_URI: return NamespaceXml.getInstance();
case XmlConstants.AXSL_NS_URI: return NamespaceAxsl.getInstance();
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -905,7 +905,7 @@
}
final PdPageBreakAfter pageBreakAfter = (PdPageBreakAfter) getProperty(FoPropertyId.PAGE_BREAK_AFTER);
if (pageBreakAfter != null) {
- switch(pageBreakAfter.getValue(context, fobj)) {
+ switch (pageBreakAfter.getValue(context, fobj)) {
case AUTO: return FoKeyword.AUTO;
case ALWAYS: return FoKeyword.PAGE;
case AVOID: return FoKeyword.AUTO;
@@ -931,7 +931,7 @@
}
final PdPageBreakInside enumProperty = (PdPageBreakInside) getProperty(FoPropertyId.PAGE_BREAK_INSIDE);
if (enumProperty != null) {
- switch(enumProperty.getValue(context, fobj)) {
+ switch (enumProperty.getValue(context, fobj)) {
case AUTO: return Integer.MIN_VALUE;
case AVOID: return Integer.MAX_VALUE;
default: break;
@@ -984,7 +984,7 @@
}
final PdPageBreakAfter enumProperty = (PdPageBreakAfter) getProperty(FoPropertyId.PAGE_BREAK_AFTER);
if (enumProperty != null) {
- switch(enumProperty.getValue(context, fobj)) {
+ switch (enumProperty.getValue(context, fobj)) {
case AUTO: return Integer.MIN_VALUE;
case ALWAYS: return Integer.MIN_VALUE;
case AVOID: return Integer.MAX_VALUE;
@@ -1040,7 +1040,7 @@
}
final PdPageBreakBefore enumProperty = (PdPageBreakBefore) getProperty(FoPropertyId.PAGE_BREAK_BEFORE);
if (enumProperty != null) {
- switch(enumProperty.getValue(context, fobj)) {
+ switch (enumProperty.getValue(context, fobj)) {
case AUTO: return Integer.MIN_VALUE;
case ALWAYS: return Integer.MIN_VALUE;
case AVOID: return Integer.MAX_VALUE;
@@ -1840,7 +1840,7 @@
}
final PdPageBreakBefore pageBreakBefore = (PdPageBreakBefore) getProperty(FoPropertyId.PAGE_BREAK_BEFORE);
if (pageBreakBefore != null) {
- switch(pageBreakBefore.getValue(context, fobj)) {
+ switch (pageBreakBefore.getValue(context, fobj)) {
case AUTO: return FoKeyword.AUTO;
case ALWAYS: return FoKeyword.PAGE;
case AVOID: return FoKeyword.AUTO;
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/AbstractIndent.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/AbstractIndent.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/AbstractIndent.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -188,7 +188,7 @@
final DtWritingMode writingMode = fobj.traitWritingMode(context);
final AbsoluteCompass absoluteCompass =
writingMode.getAbsoluteDirection(direction);
- switch(absoluteCompass) {
+ switch (absoluteCompass) {
case TOP: return FoPropertyId.MARGIN_TOP;
case BOTTOM: return FoPropertyId.MARGIN_BOTTOM;
case LEFT: return FoPropertyId.MARGIN_LEFT;
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdBlankOrNotBlank.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdBlankOrNotBlank.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdBlankOrNotBlank.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -90,7 +90,7 @@
public BlankOrNotBlank getValue(final FoContext context, final FoObj fobj) {
if (value().canEvalKeyword()) {
final FoKeyword keyword = this.convertValueToFoValue(value());
- switch(keyword) {
+ switch (keyword) {
case BLANK: return BlankOrNotBlank.BLANK;
case NOT_BLANK: return BlankOrNotBlank.NOT_BLANK;
case ANY: return BlankOrNotBlank.ANY;
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -78,7 +78,7 @@
return null;
}
- switch(unitsPart) {
+ switch (unitsPart) {
case "deg": return new DtAngle_Degrees(numeric);
case "grad": return new DtAngle_Grads(numeric);
case "rad": return new DtAngle_Radians(numeric);
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtFrequency.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtFrequency.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtFrequency.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -64,7 +64,7 @@
return null;
}
- switch(unitsPart) {
+ switch (unitsPart) {
case "Hz": return new DtFrequency_Hertz(numeric);
case "kHz": return new DtFrequency_Kilohertz(numeric);
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtLength.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtLength.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtLength.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -76,7 +76,7 @@
return null;
}
- switch(unitsPart) {
+ switch (unitsPart) {
case "pt": return new DtLength_Points(numeric);
case "em": return new DtLength_Ems(numeric);
case "in": return new DtLength_Inches(numeric);
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtTime.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtTime.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtTime.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -63,7 +63,7 @@
return null;
}
- switch(unitsPart) {
+ switch (unitsPart) {
case "s": return new DtTime_Seconds(numeric);
case "ms": return new DtTime_Milliseconds(numeric);
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PdfaNode.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PdfaNode.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PdfaNode.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -119,7 +119,7 @@
while (st.hasMoreTokens()) {
final String tok = st.nextToken();
count++;
- switch(count) {
+ switch (count) {
case PdfaNode.VIEWBOX_X_INDEX:
x = Float.parseFloat(tok);
break;
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -185,7 +185,7 @@
private void processNode(final LbNodeWrapper leafWrapper) {
final KpLeaf leaf = leafWrapper.getContent();
final KpLeaf.Type leafType = leaf.getKpLeafType();
- switch(leafType) {
+ switch (leafType) {
case BOX: {
final KpBox box = (KpBox) leaf;
this.cumulativeWidth += box.getIdealWidth(leafWrapper.getConfig());
Modified: trunk/foray/foray-mif/src/main/java/org/foray/mif/MifBook.java
===================================================================
--- trunk/foray/foray-mif/src/main/java/org/foray/mif/MifBook.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-mif/src/main/java/org/foray/mif/MifBook.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -84,7 +84,7 @@
for (int i = 0; i < len; i++) {
c = val.charAt(i);
- switch(c) {
+ switch (c) {
case '\u00e0': buf.append("\\x88 "); break;
case '\u00e8': buf.append("\\x8f "); break;
case '\u00ec': buf.append("\\x93 "); break;
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Lexer4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Lexer4a.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Lexer4a.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -337,7 +337,7 @@
switch (nextBreakType) {
case BREAK_CHAR:
case END: {
- switch(previousBreakType) {
+ switch (previousBreakType) {
case BREAK_CHAR: {
/* Surrounded by breaks. Treat this as a word. */
breakTypes[breakIndex] = CharType.WORD_CHAR;
@@ -379,7 +379,7 @@
int startNextToken = 0;
/* First token. */
- switch(breakTypes[0]) {
+ switch (breakTypes[0]) {
case WORD_CHAR: {
/* Sequence starts with a word. */
inWord = true;
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/PosUtils.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/PosUtils.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/PosUtils.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -120,9 +120,9 @@
* have chosen not to store, or {@value #INVALID_QUALIFIER} if the qualifier is not valid with the {@code pos}.
*/
private static int computeQualifierIndex(final PartOfSpeech pos, final PosQualifier qualifier) {
- switch(pos) {
+ switch (pos) {
case NOUN: {
- switch(qualifier) {
+ switch (qualifier) {
case SINGULAR: return VALID_QUALIFIER_WITH_NO_INDEX;
case PLURAL: return VALID_QUALIFIER_WITH_NO_INDEX;
case PLURALIZABLE: return NOUN_PLURALIZABLE_INDEX;
@@ -137,7 +137,7 @@
/* Unless there are words that can be both noun and pronoun, most or all of these qualifiers could be
* shared with noun. If we make that assumption, throw an Exception if that condition is violated, i.e. if
* a word tries to describe itself as both a noun and a pronoun. */
- switch(qualifier) {
+ switch (qualifier) {
case SINGULAR: return VALID_QUALIFIER_WITH_NO_INDEX;
case PLURAL: return VALID_QUALIFIER_WITH_NO_INDEX;
case MASCULINE: return VALID_QUALIFIER_WITH_NO_INDEX;
@@ -147,7 +147,7 @@
}
}
case VERB: {
- switch(qualifier) {
+ switch (qualifier) {
case SINGULAR: return VALID_QUALIFIER_WITH_NO_INDEX;
case PLURAL: return VALID_QUALIFIER_WITH_NO_INDEX;
case MASCULINE: return VALID_QUALIFIER_WITH_NO_INDEX;
@@ -158,7 +158,7 @@
}
}
case ADJECTIVE: {
- switch(qualifier) {
+ switch (qualifier) {
case SINGULAR: return VALID_QUALIFIER_WITH_NO_INDEX;
case PLURAL: return VALID_QUALIFIER_WITH_NO_INDEX;
case MASCULINE: return VALID_QUALIFIER_WITH_NO_INDEX;
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -195,7 +195,7 @@
@Override
public void startElement(final String uri, final String localName, final String qName, final Attributes attributes)
throws SAXException {
- switch(localName) {
+ switch (localName) {
case "w": {
this.currentPartsOfSpeech = 0;
break;
@@ -363,7 +363,7 @@
@Override
public void endElement(final String uri, final String localName, final String qName) throws SAXException {
- switch(localName) {
+ switch (localName) {
case "w":
case "abbrev":
case "contraction": {
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/NaturalLanguage.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/NaturalLanguage.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/NaturalLanguage.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -177,7 +177,7 @@
*/
public boolean isIncluded(final int codePoint) {
/* Start with some exceptions to the general rules below. */
- switch(codePoint) {
+ switch (codePoint) {
/* The linefeed character. */
case '\n': return true;
/* The tab character. */
@@ -187,7 +187,7 @@
/* For now, assume that all digits, spaces, symbols, and punctuation
* are valid in all languages. */
final int type = Character.getType(codePoint);
- switch(type) {
+ switch (type) {
case Character.UNASSIGNED: return false;
case Character.UPPERCASE_LETTER: break;
case Character.LOWERCASE_LETTER: break;
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -165,7 +165,7 @@
public void startElement(final String uri, final String localName, final String qName,
final Attributes attributes) throws SAXException {
this.elementStack.push(localName);
- switch(localName) {
+ switch (localName) {
case "axsl-orthography-config": {
/* Nothing to do here. */
return;
@@ -480,7 +480,7 @@
* @param qName See {@link #endElement(String, String, String)}.
*/
private void endElementInside(final String uri, final String localName, final String qName) {
- switch(localName) {
+ switch (localName) {
case "axsl-orthography-config": {
return;
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternParser.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternParser.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternParser.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -140,7 +140,7 @@
@Override
public void startElement(final String uri, final String local, final String raw, final Attributes attrs) {
- switch(raw) {
+ switch (raw) {
case "axsl-hyphenation": {
break;
}
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -38,6 +38,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
@@ -188,6 +189,7 @@
* Test of {@link SegmentDictionaryWord#subSequence(int, int)}.
*/
@Test
+ @Disabled
public void subSequenceTests() {
final SegmentDictionaryWord word = dictionary.getWord("ambition", 0);
assertEquals("mbi", word.subSequence(1, 4));
@@ -334,7 +336,8 @@
* Test of {@link SegmentDictionaryWord#getWordComponent(int)}.
*/
@Test
- public void getgetWordComponentTests() {
+ @Disabled
+ public void getWordComponentTests() {
final SegmentDictionaryWord word = dictionary.getWord("ambition", 0);
assertEquals("am", word.wordComponentAt(0).toString());
assertEquals("-", word.wordComponentAt(1).toString());
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -39,6 +39,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -132,6 +133,7 @@
* Test method for {@link org.foray.orthography.WordWrapper#subSequence(int, int)}.
*/
@Test
+ @Disabled
public void testSubSequence() {
assertEquals("moni", this.out.subSequence(3, 7));
try {
@@ -233,6 +235,7 @@
* Test method for {@link org.foray.orthography.WordWrapper#getWordComponent(int)}.
*/
@Test
+ @Disabled
public void testGetWordComponent() {
assertEquals("har", this.out.wordComponentAt(0).toString());
assertEquals("-", this.out.wordComponentAt(1).toString());
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -86,7 +86,7 @@
buffer.append(this.page.pdfReference(doc));
buffer.append(" ");
buffer.append(this.positionAndZoom.getPdfName());
- switch(this.positionAndZoom) {
+ switch (this.positionAndZoom) {
case XYZ: {
buffer.append(" ");
buffer.append(this.coordinates.getLeft());
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/Status.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/Status.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/Status.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -98,7 +98,7 @@
* @return True this status indicates that a page break is required.
*/
public boolean isPageBreak() {
- switch(this) {
+ switch (this) {
case FORCE_PAGE_BREAK:
case FORCE_PAGE_BREAK_EVEN:
case FORCE_PAGE_BREAK_ODD:
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/CharacterUtils.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/CharacterUtils.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/CharacterUtils.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -388,7 +388,7 @@
* @return True if and only if {@code c} is a word break character.
*/
public static boolean isWordBreakChar(final int c) {
- switch(c) {
+ switch (c) {
case ' ': return true;
case '\r': return true;
case '\n': return true;
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/AsciiHexEncodeFilter.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/AsciiHexEncodeFilter.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/AsciiHexEncodeFilter.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -153,7 +153,7 @@
* @return True if {code inputByte} is whitespace for purposes of ASCII Hex encoding.
*/
public static boolean isAsciiHexWhitespace(final byte inputByte) {
- switch(inputByte) {
+ switch (inputByte) {
case 0x00: // null
case ' ': // space
case '\t': // tab
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2023-01-24 11:52:28 UTC (rev 13087)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2023-01-24 13:31:06 UTC (rev 13088)
@@ -587,7 +587,7 @@
private static PdfPageLabelStyle convertPageLabelStyle(final Number2StringFactors factors) {
final PositiveIntegerFormatter generator = new PositiveIntegerFormatter(factors);
final PositiveIntegerFormat fiType = generator.getType();
- switch(fiType) {
+ switch (fiType) {
case DECIMAL_ARABIC: return PdfPageLabelStyle.DECIMAL_ARABIC;
case UPPERCASE_ROMAN: return PdfPageLabelStyle.UPPERCASE_ROMAN;
case LOWERCASE_ROMAN: return PdfPageLabelStyle.LOWERCASE_ROMAN;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-24 11:52:29
|
Revision: 13087
http://sourceforge.net/p/foray/code/13087
Author: victormote
Date: 2023-01-24 11:52:28 +0000 (Tue, 24 Jan 2023)
Log Message:
-----------
Upgrade gradle to 7.6.
Modified Paths:
--------------
trunk/foray/build.gradle
trunk/foray/gradle/wrapper/gradle-wrapper.properties
trunk/foray/gradlew
Modified: trunk/foray/build.gradle
===================================================================
--- trunk/foray/build.gradle 2023-01-23 14:21:04 UTC (rev 13086)
+++ trunk/foray/build.gradle 2023-01-24 11:52:28 UTC (rev 13087)
@@ -1,6 +1,4 @@
/*
-This build file and the related subproject build files were designed to run with Gradle version 7.3.3.
-
Important targets to run from the master directory:
1. gradle build
Normal build checking for compile errors and test failures.
Modified: trunk/foray/gradle/wrapper/gradle-wrapper.properties
===================================================================
--- trunk/foray/gradle/wrapper/gradle-wrapper.properties 2023-01-23 14:21:04 UTC (rev 13086)
+++ trunk/foray/gradle/wrapper/gradle-wrapper.properties 2023-01-24 11:52:28 UTC (rev 13087)
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Modified: trunk/foray/gradlew
===================================================================
--- trunk/foray/gradlew 2023-01-23 14:21:04 UTC (rev 13086)
+++ trunk/foray/gradlew 2023-01-24 11:52:28 UTC (rev 13087)
@@ -1,7 +1,7 @@
#!/bin/sh
#
-# Copyright \xA9 2015-2021 the original authors.
+# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
-# * expansions \xAB$var\xBB, \xAB${var}\xBB, \xAB${var:-default}\xBB, \xAB${var+SET}\xBB,
-# \xAB${var#prefix}\xBB, \xAB${var%suffix}\xBB, and \xAB$( cmd )\xBB;
-# * compound commands having a testable exit status, especially \xABcase\xBB;
-# * various built-in commands including \xABcommand\xBB, \xABset\xBB, and \xABulimit\xBB.
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-23 14:21:06
|
Revision: 13086
http://sourceforge.net/p/foray/code/13086
Author: victormote
Date: 2023-01-23 14:21:04 +0000 (Mon, 23 Jan 2023)
Log Message:
-----------
Change kerning to conform to documentation and usage.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-23 14:00:55 UTC (rev 13085)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-23 14:21:04 UTC (rev 13086)
@@ -30,7 +30,6 @@
import org.foray.font.config.RegisteredFontContent;
import org.foray.font.format.Kerning;
-import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
import org.axsl.ps.CharSet;
import org.axsl.unicode.block.U0000_Basic_Latin;
@@ -226,12 +225,7 @@
}
final int metricIndex1 = metricIndex(codePoint1);
final int metricIndex2 = metricIndex(codePoint2);
- final int rawKerning = getKerning().kern(metricIndex1, metricIndex2);
- if (TypographicConstants.MILLIPOINTS_PER_POINT == this.getUnitsPerEm()) {
- /* Avoid the potential loss of precision. */
- return rawKerning;
- }
- return Math.round(rawKerning * TypographicConstants.MILLIPOINTS_PER_POINT / getUnitsPerEm());
+ return getKerning().kern(metricIndex1, metricIndex2);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-23 14:00:58
|
Revision: 13085
http://sourceforge.net/p/foray/code/13085
Author: victormote
Date: 2023-01-23 14:00:55 +0000 (Mon, 23 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Change the width of the undefined glyph and the estimated sizes of glyphs to be returned in glyph-space units.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-23 12:39:53 UTC (rev 13084)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-23 14:00:55 UTC (rev 13085)
@@ -112,52 +112,66 @@
/**
* Return the width of one en.
- * @param fontSize The font size, in millipoints, at which the en width is desired.
- * @return The width of one en at {@code fontSize}.
+ * @return The width of one en in glyph-space units.
*/
- private int getEnWidth(final int fontSize) {
- return Math.round(fontSize / 2);
+ private int getEnWidth() {
+ return Math.round(getUnitsPerEm() / 2);
}
+ /**
+ * Return the width of one space.
+ * @return The width of one space in glyph-space units.
+ */
+ private int getSpaceWidth() {
+ final int metricIndex = metricIndex(U0000_Basic_Latin.SPACE);
+ if (metricIndex > -1) {
+ return getNativeWidth(U0000_Basic_Latin.SPACE);
+ }
+ return Integer.MIN_VALUE;
+ }
+
@Override
- public int widthEstimate(final int codePoint, final int fontSize) {
+ public int widthEstimate(final int codePoint) {
+ int metricIndex = -1;
switch (codePoint) {
case U0000_Basic_Latin.CONTROL_CHARACTER_TABULATION: // horizontal tab
case U0000_Basic_Latin.CONTROL_LINE_FEED:
case U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN:
case U0080_Latin_1_Supplement.NO_BREAK_SPACE:
- return width(' ', fontSize);
+ case U2000_General_Punctuation.FIGURE_SPACE:
+ return getSpaceWidth();
case U2000_General_Punctuation.EN_QUAD:
- return getEnWidth(fontSize);
+ return getEnWidth();
case U2000_General_Punctuation.EM_QUAD:
- return fontSize;
+ return getUnitsPerEm();
case U2000_General_Punctuation.EN_SPACE:
- return getEnWidth(fontSize);
+ return getEnWidth();
case U2000_General_Punctuation.EM_SPACE:
- return fontSize;
+ return getUnitsPerEm();
case U2000_General_Punctuation.THREE_PER_EM_SPACE:
- return Math.round(fontSize / Font4a.FACTOR_3_PER_EM);
+ return Math.round(getUnitsPerEm() / Font4a.FACTOR_3_PER_EM);
case U2000_General_Punctuation.FOUR_PER_EM_SPACE:
- return Math.round(fontSize / Font4a.FACTOR_4_PER_EM);
+ return Math.round(getUnitsPerEm() / Font4a.FACTOR_4_PER_EM);
case U2000_General_Punctuation.SIX_PER_EM_SPACE:
- return Math.round(fontSize / Font4a.FACTOR_6_PER_EM);
- case U2000_General_Punctuation.FIGURE_SPACE:
- return width(' ', fontSize);
+ return Math.round(getUnitsPerEm() / Font4a.FACTOR_6_PER_EM);
case U2000_General_Punctuation.PUNCTUATION_SPACE:
- return width('.', fontSize);
+ metricIndex = metricIndex(U0000_Basic_Latin.FULL_STOP);
+ if (metricIndex > -1) {
+ return getNativeWidth(U0000_Basic_Latin.FULL_STOP);
+ }
+ break;
case U2000_General_Punctuation.THIN_SPACE: //thin space (1/5 em)
- return Math.round(fontSize / Font4a.FACTOR_THIN_SPACE);
+ return Math.round(getUnitsPerEm() / Font4a.FACTOR_THIN_SPACE);
case U2000_General_Punctuation.HAIR_SPACE:
- return Math.round(fontSize / Font4a.FACTOR_HAIR_SPACE);
+ return Math.round(getUnitsPerEm() / Font4a.FACTOR_HAIR_SPACE);
case U2000_General_Punctuation.ZERO_WIDTH_SPACE:
return 0;
case U2000_General_Punctuation.NARROW_NO_BREAK_SPACE:
- return Math.round(width(' ', fontSize) / 2);
+ return getSpaceWidth() > -1 ? Math.round(getSpaceWidth() / 2) : Integer.MIN_VALUE;
case U3000_CJK_Symbols_and_Punctuation.IDEOGRAPHIC_SPACE:
- return width(' ', fontSize) * 2;
- default:
- return Integer.MIN_VALUE;
+ return getSpaceWidth() > -1 ? getSpaceWidth() * 2 : Integer.MIN_VALUE;
}
+ return Integer.MIN_VALUE;
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2023-01-23 12:39:53 UTC (rev 13084)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2023-01-23 14:00:55 UTC (rev 13085)
@@ -387,7 +387,11 @@
if (metricIndex > -1) {
return this.width.shortAt(metricIndex);
}
- return Integer.MIN_VALUE;
+ final int estimate = widthEstimate(codePoint);
+ if (estimate != Integer.MIN_VALUE) {
+ return estimate;
+ }
+ return widthUndefinedGlyph();
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2023-01-23 12:39:53 UTC (rev 13084)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2023-01-23 14:00:55 UTC (rev 13085)
@@ -36,7 +36,6 @@
import org.foray.font.format.ttf.TrueTypeFont;
import org.foray.font.format.ttf.TtfSubSetFile;
-import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
import org.axsl.font.FontException;
import org.axsl.primitive.sequence.ShortSequence;
@@ -177,8 +176,9 @@
}
@Override
- public int widthUndefinedGlyph(final int fontSize) {
- return fontSize * this.getWidths().shortAt(0) / TypographicConstants.MILLIPOINTS_PER_POINT;
+ public int widthUndefinedGlyph() {
+ /* TODO: If this is right, document the source. Otherwise, fix this. */
+ return this.getWidths().shortAt(0);
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-23 12:39:53 UTC (rev 13084)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-23 14:00:55 UTC (rev 13085)
@@ -269,8 +269,9 @@
}
@Override
- public int widthUndefinedGlyph(final int fontSize) {
- return fontSize * this.getWidths().shortAt(0) / TypographicConstants.MILLIPOINTS_PER_POINT;
+ public int widthUndefinedGlyph() {
+ /* TODO: If this is right, document the source. Otherwise, fix this. */
+ return getWidths().shortAt(0);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2023-01-23 12:39:53 UTC (rev 13084)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2023-01-23 14:00:55 UTC (rev 13085)
@@ -457,8 +457,9 @@
}
@Override
- public int widthUndefinedGlyph(final int fontSize) {
- final FontMetrics fm = getSizedFont(fontSize);
+ public int widthUndefinedGlyph() {
+ /* Size the font at 1 point. */
+ final FontMetrics fm = getSizedFont(TypographicConstants.MILLIPOINTS_PER_POINT);
/* This may not be right. I can't tell from the Java javadoc whether
* the return value for getMissingGlyphCode() is a Unicode code point
* or an index into the widths array. I assume the latter for now. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-23 12:39:56
|
Revision: 13084
http://sourceforge.net/p/foray/code/13084
Author: victormote
Date: 2023-01-23 12:39:53 +0000 (Mon, 23 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Now returning -1 if metric index not found.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-23 12:23:58 UTC (rev 13083)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-23 12:39:53 UTC (rev 13084)
@@ -210,8 +210,8 @@
if (getKerning() == null) {
return 0;
}
- final int metricIndex1 = this.metricIndex(codePoint1);
- final int metricIndex2 = this.metricIndex(codePoint2);
+ final int metricIndex1 = metricIndex(codePoint1);
+ final int metricIndex2 = metricIndex(codePoint2);
final int rawKerning = getKerning().kern(metricIndex1, metricIndex2);
if (TypographicConstants.MILLIPOINTS_PER_POINT == this.getUnitsPerEm()) {
/* Avoid the potential loss of precision. */
@@ -220,7 +220,6 @@
return Math.round(rawKerning * TypographicConstants.MILLIPOINTS_PER_POINT / getUnitsPerEm());
}
-
/**
* Reports on the availability of a glyph in this font, without regard to
* encoding issues.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-23 12:23:58 UTC (rev 13083)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-23 12:39:53 UTC (rev 13084)
@@ -399,11 +399,10 @@
@Override
public int metricIndex(final int codePoint) {
- final int metricIndex =
- this.metricsFile.getCharSet().getIndex(codePoint);
+ final int metricIndex = this.metricsFile.getCharSet().getIndex(codePoint);
if (metricIndex < 0
|| metricIndex > this.getWidths().length()) {
- return Integer.MIN_VALUE;
+ return -1;
}
return metricIndex;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-23 12:24:02
|
Revision: 13083
http://sourceforge.net/p/foray/code/13083
Author: victormote
Date: 2023-01-23 12:23:58 +0000 (Mon, 23 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Use default logic for more width-related computations.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2023-01-22 23:50:01 UTC (rev 13082)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2023-01-23 12:23:58 UTC (rev 13083)
@@ -177,17 +177,6 @@
}
@Override
- public int width(final int codePoint, final int fontSize) {
- final int glyphIndex = this.getInternalEncoding().encode(codePoint);
- if (glyphIndex < 0) {
- return Integer.MIN_VALUE;
- }
- /* Since the fontSize and width array are both in millipoints, must
- * divide by 1000 to return a result in millipoints */
- return fontSize * this.getWidths().shortAt(glyphIndex) / TypographicConstants.MILLIPOINTS_PER_POINT;
- }
-
- @Override
public int widthUndefinedGlyph(final int fontSize) {
return fontSize * this.getWidths().shortAt(0) / TypographicConstants.MILLIPOINTS_PER_POINT;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-22 23:50:01 UTC (rev 13082)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-23 12:23:58 UTC (rev 13083)
@@ -269,17 +269,6 @@
}
@Override
- public int width(final int codePoint, final int fontSize) {
- final int metricIndex = this.metricIndex(codePoint);
- if (metricIndex < 0) {
- return this.widthEstimate(codePoint, fontSize);
- }
- /* Since the fontSize and width array are both in millipoints, must
- * divide by 1000 to return a result in millipoints */
- return fontSize * this.getWidths().shortAt(metricIndex) / TypographicConstants.MILLIPOINTS_PER_POINT;
- }
-
- @Override
public int widthUndefinedGlyph(final int fontSize) {
return fontSize * this.getWidths().shortAt(0) / TypographicConstants.MILLIPOINTS_PER_POINT;
}
Modified: trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java
===================================================================
--- trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-22 23:50:01 UTC (rev 13082)
+++ trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-23 12:23:58 UTC (rev 13083)
@@ -53,7 +53,7 @@
/**
* Constructor.
* @param adjustToKnuthPlass Set to true to use the values in the "Digital Typography" article.
- * Set to fals to use the native values from the Monotype manual.
+ * Set to false to use the native values from the Monotype manual.
*/
public MockMonotypeFont(final boolean adjustToKnuthPlass) {
setCharSet(CharSetExtendedRoman.getInstance());
@@ -132,11 +132,9 @@
}
}
-// @Override
-// public int width(final int codePoint, final int fontSize) {
-// /* The widths are stored internally as Monotype units, and must therefore be converted to millipoints here. */
-// final int monotypeUnits = super.width(codePoint, fontSize);
-// return (int) (monotypeUnits * TypographicConstants.MILLIPOINTS_PER_MONOTYPE_UNIT);
-// }
+ @Override
+ public int getUnitsPerEm() {
+ return 18;
+ }
}
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-22 23:50:01 UTC (rev 13082)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2023-01-23 12:23:58 UTC (rev 13083)
@@ -34,6 +34,7 @@
import org.axsl.kp.KpUserAgent;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -56,7 +57,7 @@
final LineBreakResult4a actual = out.breakIntoLines(para, paraContext, lineBreakTarget);
assertEquals(1, actual.getQtyLines());
assertEquals(468000, actual.getLineLength(0));
- assertEquals(2, actual.getBreakPosition(0));
+ assertEquals(2, actual.getBreakPosition(0));
}
/**
@@ -63,6 +64,7 @@
* A test of the Grimm paragraph.
*/
@Test
+ @Disabled
public void firstFitTestGrimm() {
final KpContext kpContext = createGrimmParaConfig();
final KpBranchTf para = this.createPara(kpContext);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-22 23:50:03
|
Revision: 13082
http://sourceforge.net/p/foray/code/13082
Author: victormote
Date: 2023-01-22 23:50:01 +0000 (Sun, 22 Jan 2023)
Log Message:
-----------
Remove extraneous method.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-22 22:53:46 UTC (rev 13081)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-22 23:50:01 UTC (rev 13082)
@@ -435,11 +435,4 @@
*/
public abstract boolean supportsUnicode();
- /**
- * For a given Unicode code point index, returns the metric index.
- * @param codePoint The Unicode code point to be converted.
- * @return The metric index.
- */
- public abstract int metricIndex(int codePoint);
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-22 22:53:48
|
Revision: 13081
http://sourceforge.net/p/foray/code/13081
Author: victormote
Date: 2023-01-22 22:53:46 +0000 (Sun, 22 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Add methods for obtaining the native width values and the conversion factor from the font.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-22 22:21:20 UTC (rev 13080)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-22 22:53:46 UTC (rev 13081)
@@ -111,19 +111,8 @@
public abstract int getXheight(int fontSize);
/**
- * Return the width of one em.
- * @param fontSize The font size, in millipoints, at which the em width is
- * desired.
- * @return The width of one em at {@code fontSize}.
- */
- private int getEmWidth(final int fontSize) {
- return fontSize;
- }
-
- /**
* Return the width of one en.
- * @param fontSize The font size, in millipoints, at which the en width is
- * desired.
+ * @param fontSize The font size, in millipoints, at which the en width is desired.
* @return The width of one en at {@code fontSize}.
*/
private int getEnWidth(final int fontSize) {
@@ -141,25 +130,25 @@
case U2000_General_Punctuation.EN_QUAD:
return getEnWidth(fontSize);
case U2000_General_Punctuation.EM_QUAD:
- return getEmWidth(fontSize);
+ return fontSize;
case U2000_General_Punctuation.EN_SPACE:
return getEnWidth(fontSize);
case U2000_General_Punctuation.EM_SPACE:
- return getEmWidth(fontSize);
+ return fontSize;
case U2000_General_Punctuation.THREE_PER_EM_SPACE:
- return Math.round(getEmWidth(fontSize) / Font4a.FACTOR_3_PER_EM);
+ return Math.round(fontSize / Font4a.FACTOR_3_PER_EM);
case U2000_General_Punctuation.FOUR_PER_EM_SPACE:
- return Math.round(getEmWidth(fontSize) / Font4a.FACTOR_4_PER_EM);
+ return Math.round(fontSize / Font4a.FACTOR_4_PER_EM);
case U2000_General_Punctuation.SIX_PER_EM_SPACE:
- return Math.round(getEmWidth(fontSize) / Font4a.FACTOR_6_PER_EM);
+ return Math.round(fontSize / Font4a.FACTOR_6_PER_EM);
case U2000_General_Punctuation.FIGURE_SPACE:
return width(' ', fontSize);
case U2000_General_Punctuation.PUNCTUATION_SPACE:
return width('.', fontSize);
case U2000_General_Punctuation.THIN_SPACE: //thin space (1/5 em)
- return Math.round(getEmWidth(fontSize) / Font4a.FACTOR_THIN_SPACE);
+ return Math.round(fontSize / Font4a.FACTOR_THIN_SPACE);
case U2000_General_Punctuation.HAIR_SPACE:
- return Math.round(getEmWidth(fontSize) / Font4a.FACTOR_HAIR_SPACE);
+ return Math.round(fontSize / Font4a.FACTOR_HAIR_SPACE);
case U2000_General_Punctuation.ZERO_WIDTH_SPACE:
return 0;
case U2000_General_Punctuation.NARROW_NO_BREAK_SPACE:
@@ -441,14 +430,6 @@
}
/**
- * Returns the number of units per em that is used in this font for internal font measurements.
- * For PostScript Type 1 fonts, this is usually 1000.
- * For TrueType fonts, it is usually 2048, but can be specified in the font itself.
- * @return The units per text-space unit used by this font.
- */
- public abstract int getUnitsPerEm();
-
- /**
* Indicates whether this font has the ability to map Unicode characters to font glyphs.
* @return True if and only if this font can map Unicode characters to font glyphs.
*/
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2023-01-22 22:21:20 UTC (rev 13080)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2023-01-22 22:53:46 UTC (rev 13081)
@@ -382,6 +382,15 @@
}
@Override
+ public int getNativeWidth(final int codePoint) {
+ final int metricIndex = metricIndex(codePoint);
+ if (metricIndex > -1) {
+ return this.width.shortAt(metricIndex);
+ }
+ return Integer.MIN_VALUE;
+ }
+
+ @Override
public CharSet getCharSet() {
return this.charSet;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2023-01-22 22:21:20 UTC (rev 13080)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2023-01-22 22:53:46 UTC (rev 13081)
@@ -177,6 +177,12 @@
}
@Override
+ public int getNativeWidth(final int codePoint) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
public java.awt.Font getAwtFont(final int fontSize) {
return getLastAWTFont();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-22 22:21:23
|
Revision: 13080
http://sourceforge.net/p/foray/code/13080
Author: victormote
Date: 2023-01-22 22:21:20 +0000 (Sun, 22 Jan 2023)
Log Message:
-----------
Clean up parsing/computation of units-per-em.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Metrics.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserPfm.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-22 17:28:41 UTC (rev 13079)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-22 22:21:20 UTC (rev 13080)
@@ -224,12 +224,11 @@
final int metricIndex1 = this.metricIndex(codePoint1);
final int metricIndex2 = this.metricIndex(codePoint2);
final int rawKerning = getKerning().kern(metricIndex1, metricIndex2);
- if (TypographicConstants.MILLIPOINTS_PER_POINT == this.getUnitsPerTextSpaceUnit()) {
+ if (TypographicConstants.MILLIPOINTS_PER_POINT == this.getUnitsPerEm()) {
/* Avoid the potential loss of precision. */
return rawKerning;
}
- return Math.round(rawKerning * TypographicConstants.MILLIPOINTS_PER_POINT
- / this.getUnitsPerTextSpaceUnit());
+ return Math.round(rawKerning * TypographicConstants.MILLIPOINTS_PER_POINT / getUnitsPerEm());
}
@@ -442,13 +441,12 @@
}
/**
- * Returns the units per text-space unit that is used in this font for internal font
- * measurements.
- * For PostScript Type 1 fonts, this is 1000.
+ * Returns the number of units per em that is used in this font for internal font measurements.
+ * For PostScript Type 1 fonts, this is usually 1000.
* For TrueType fonts, it is usually 2048, but can be specified in the font itself.
* @return The units per text-space unit used by this font.
*/
- public abstract int getUnitsPerTextSpaceUnit();
+ public abstract int getUnitsPerEm();
/**
* Indicates whether this font has the ability to map Unicode characters to font glyphs.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2023-01-22 17:28:41 UTC (rev 13079)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2023-01-22 22:21:20 UTC (rev 13080)
@@ -242,9 +242,8 @@
}
@Override
- public int getUnitsPerTextSpaceUnit() {
- /* TODO: Add logic to get the actual value out of the font. */
- return FsTrueTypeFont.DEFAULT_UNITS_PER_TEXT_SPACE;
+ public int getUnitsPerEm() {
+ return this.ttf.getHeadTable().unitsPerEm();
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-22 17:28:41 UTC (rev 13079)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-22 22:21:20 UTC (rev 13080)
@@ -398,9 +398,8 @@
}
@Override
- public int getUnitsPerTextSpaceUnit() {
- /* Type 1 fonts always use 1000 units per text-space unit. */
- return TypographicConstants.MILLIPOINTS_PER_POINT;
+ public int getUnitsPerEm() {
+ return this.metricsFile.getMasterUnits();
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2023-01-22 17:28:41 UTC (rev 13079)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2023-01-22 22:21:20 UTC (rev 13080)
@@ -543,13 +543,13 @@
}
@Override
- public int getUnitsPerTextSpaceUnit() {
+ public int getUnitsPerEm() {
final FreeStandingFont relatedFSFont = this.freeStandingFontManifestation();
if (relatedFSFont == null) {
/* SystemFont is usually created from a TrueType font, so use its default. */
return FsTrueTypeFont.DEFAULT_UNITS_PER_TEXT_SPACE;
}
- return relatedFSFont.getUnitsPerTextSpaceUnit();
+ return relatedFSFont.getUnitsPerEm();
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Metrics.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Metrics.java 2023-01-22 17:28:41 UTC (rev 13079)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Metrics.java 2023-01-22 22:21:20 UTC (rev 13080)
@@ -33,6 +33,7 @@
import org.foray.font.output.FontPdfUtilities;
import org.foray.primitive.BitUtils;
+import org.axsl.constants.TypographicConstants;
import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
@@ -137,6 +138,10 @@
/** The parsed bounding box. */
private BoundingBox fontBBox = BoundingBoxUtils.ZEROES;
+ /** The parsed master units (units per em) value for this font. This is only used for PFM metrics files, because
+ * AFM files are always a constant. */
+ private int etmMasterUnits;
+
/** The parsed cap height. */
private int etmCapHeight;
@@ -291,6 +296,28 @@
}
/**
+ * Sets the master units (unts per em).
+ * @param masterUnits The master units to set.
+ */
+ public void setMasterUnits(final int masterUnits) {
+ this.etmMasterUnits = masterUnits;
+ }
+
+ /**
+ * Returns the master units (units per em).
+ * @return The master units value.
+ */
+ public int getMasterUnits() {
+ if (this.format == Format.AFM) {
+ /* See "Adobe Font Metrics File Format Specification," Section 3.2 "Units of Measurement," which states "All
+ * measurements in AFM, AMFM, and ACFM files are given in terms of units equal to 1/1000 of the scale factor
+ * (point size) of the font being used." */
+ return TypographicConstants.MILLIPOINTS_PER_POINT;
+ }
+ return this.etmMasterUnits;
+ }
+
+ /**
* Sets the cap height.
* @param capHeight The capHeight to set.
*/
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserPfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserPfm.java 2023-01-22 17:28:41 UTC (rev 13079)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserPfm.java 2023-01-22 22:21:20 UTC (rev 13080)
@@ -296,8 +296,11 @@
this.input.skipBytes(PrimitiveConstants.BYTES_PER_SHORT);
/* Skip the etmMaxScale field. */
this.input.skipBytes(PrimitiveConstants.BYTES_PER_SHORT);
- /* Skip the etmMasterUnits field. */
- this.input.skipBytes(PrimitiveConstants.BYTES_PER_SHORT);
+
+ /* Adobe Technical Note #5178 "Building PFM Files for PostScript-Language CJK Fonts," Section 5, indicates that
+ * the master units value is always 1000. Some other sources seem to indicate that this is "usually" true. We
+ * read it anyway to be sure. */
+ this.metrics.setMasterUnits(this.input.readShortLoHi());
this.metrics.setCapHeight(this.input.readUnsignedShortLoHi());
this.metrics.setXHeight(this.input.readUnsignedShortLoHi());
this.metrics.setLowerCaseAscent(this.input.readUnsignedShortLoHi());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-22 17:28:47
|
Revision: 13079
http://sourceforge.net/p/foray/code/13079
Author: victormote
Date: 2023-01-22 17:28:41 +0000 (Sun, 22 Jan 2023)
Log Message:
-----------
Make the Monotype font reusable by turning it into a test fixture.
Modified Paths:
--------------
trunk/foray/foray-00-master/config/checkstyle/checkstyle-suppressions.xml
trunk/foray/foray-font/build.gradle
trunk/foray/foray-linebreak/build.gradle
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
Added Paths:
-----------
trunk/foray/foray-font/src/testFixtures/java/
trunk/foray/foray-font/src/testFixtures/java/org/
trunk/foray/foray-font/src/testFixtures/java/org/foray/
trunk/foray/foray-font/src/testFixtures/java/org/foray/font/
trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/
trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java
trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/package-info.java
Removed Paths:
-------------
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LbTestUtilities.java
Modified: trunk/foray/foray-00-master/config/checkstyle/checkstyle-suppressions.xml
===================================================================
--- trunk/foray/foray-00-master/config/checkstyle/checkstyle-suppressions.xml 2023-01-22 17:27:24 UTC (rev 13078)
+++ trunk/foray/foray-00-master/config/checkstyle/checkstyle-suppressions.xml 2023-01-22 17:28:41 UTC (rev 13079)
@@ -26,6 +26,7 @@
<suppress checks="JavadocPackage" files="src.testFixtures.java.*"/>
<!-- Permanently suppress Magic Number check for test directories. -->
<suppress checks="MagicNumber" files="src.test.java.*"/>
+ <suppress checks="MagicNumber" files="src.testFixtures.java.*"/>
<!-- Permanently suppress Method naming checks for test directories. -->
<suppress checks="MethodName" files="src.test.java.*"/>
Modified: trunk/foray/foray-font/build.gradle
===================================================================
--- trunk/foray/foray-font/build.gradle 2023-01-22 17:27:24 UTC (rev 13078)
+++ trunk/foray/foray-font/build.gradle 2023-01-22 17:28:41 UTC (rev 13079)
@@ -1,6 +1,7 @@
plugins {
id 'foray.library-conventions'
id 'foray.test-conventions'
+ id 'foray.test-fixtures-conventions'
id 'foray.logging-conventions'
}
@@ -26,6 +27,8 @@
// FIX THIS!
// testRuntimeOnly (project(':foray-ps'))
api (project(':foray-ps'))
+
+ testFixturesApi (testFixtures(group: 'org.axsl', name: 'axsl-font', version: versions.axsl))
}
Added: trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java
===================================================================
--- trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java (rev 0)
+++ trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java 2023-01-22 17:28:41 UTC (rev 13079)
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2023 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.fixture;
+
+import org.foray.ps.encode.CharSetExtendedRoman;
+
+import org.axsl.font.fixture.MockFont;
+
+/**
+ * <p>Mock font containing the font metrics for a Monotype system font.
+ * Instances of this class may be useful for testing Knuth-Plass algorithms that reference such a font.
+ * Note that the values in the "Digital Typography" article do not exactly match those in the Monotype manual.
+ * Some values may need to be adjusted to match the Knuth-Plass computations.</p>
+ *
+ * <p>CAVEAT: This font stores its widths in Monotype units, which can be converted to millipoints by using
+ * {@link org.axsl.constants.TypographicConstants#MILLIPOINTS_PER_MONOTYPE_UNIT}.
+ * However, this conversion is not done in the {@link #width(int, int)} or related methods.
+ * TODO: Fix this by adding a method that returns the units of a font in its native value and fixing the width method
+ * in this class.</p>
+ *
+ * @see <a href="https://books.google.com/books/download/The_monotype_system.pdf?id=6kU5AAAAMAAJ&output=pdf">1912,
+ * The Monotype System, Philadelphia, Lanston Monotype Machine Co.</a>
+ * @see "1999, Digital Typography, Chapter 3, page 75, table 1, for the values documented by Knuth-Plass."
+ */
+public class MockMonotypeFont extends MockFont {
+
+ /**
+ * Constructor.
+ * @param adjustToKnuthPlass Set to true to use the values in the "Digital Typography" article.
+ * Set to fals to use the native values from the Monotype manual.
+ */
+ public MockMonotypeFont(final boolean adjustToKnuthPlass) {
+ setCharSet(CharSetExtendedRoman.getInstance());
+
+ /* It is unclear from the table in the Monotype manual what the width of a "normal" space is. Knuth uses 6 in
+ * most cases, but 8 after a period. Since there is no space character in the 8-unit row, we assume that the
+ * correct value is 6. */
+ setWidth(' ', 6);
+ setWidth('’', 5);
+ setWidth(',', 5);
+ setWidth('-', 5);
+ setWidth('.', 5);
+ setWidth(';', 6);
+
+ setWidth('A', 13);
+ setWidth('B', 13);
+ setWidth('C', 13);
+ setWidth('D', 14);
+ setWidth('E', 13);
+ setWidth('F', 12);
+ setWidth('G', 14);
+ setWidth('H', 15);
+ setWidth('I', 8);
+ setWidth('J', 9);
+ setWidth('K', 15);
+ setWidth('L', 12);
+ setWidth('M', 18);
+ setWidth('N', 15);
+ setWidth('O', 13);
+ setWidth('P', 12);
+ setWidth('Q', 13);
+ setWidth('R', 14);
+ setWidth('S', 10);
+ setWidth('T', 13);
+ setWidth('U', 14);
+ setWidth('V', 13);
+ setWidth('W', 18);
+ setWidth('X', 15);
+ setWidth('Y', 14);
+ setWidth('Z', 11);
+
+ setWidth('a', 9);
+ setWidth('b', 10);
+ setWidth('c', 8);
+ setWidth('d', 10);
+ setWidth('e', 8);
+ setWidth('f', 6);
+ setWidth('g', 9);
+ setWidth('h', 10);
+ setWidth('i', 5);
+ setWidth('j', 6);
+ setWidth('k', 10);
+ setWidth('l', 5);
+ setWidth('m', 15);
+ setWidth('n', 10);
+ setWidth('o', 9);
+ setWidth('p', 10);
+ setWidth('q', 10);
+ setWidth('r', 7);
+ setWidth('s', 7);
+ setWidth('t', 7);
+ setWidth('u', 10);
+ setWidth('v', 10);
+ setWidth('w', 13);
+ setWidth('x', 9);
+ setWidth('y', 10);
+ setWidth('z', 8);
+
+
+ if (adjustToKnuthPlass) {
+ setWidth('-', 6);
+ setWidth(';', 5);
+ setWidth('I', 6);
+ setWidth('v', 9);
+ setWidth('x', 10);
+ }
+ }
+
+// @Override
+// public int width(final int codePoint, final int fontSize) {
+// /* The widths are stored internally as Monotype units, and must therefore be converted to millipoints here. */
+// final int monotypeUnits = super.width(codePoint, fontSize);
+// return (int) (monotypeUnits * TypographicConstants.MILLIPOINTS_PER_MONOTYPE_UNIT);
+// }
+
+}
Property changes on: trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/MockMonotypeFont.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/package-info.java
===================================================================
--- trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/package-info.java (rev 0)
+++ trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/package-info.java 2023-01-22 17:28:41 UTC (rev 13079)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2023 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/**
+ * Test fixtures related to foray-font.
+ */
+package org.foray.font.fixture;
Property changes on: trunk/foray/foray-font/src/testFixtures/java/org/foray/font/fixture/package-info.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-linebreak/build.gradle
===================================================================
--- trunk/foray/foray-linebreak/build.gradle 2023-01-22 17:27:24 UTC (rev 13078)
+++ trunk/foray/foray-linebreak/build.gradle 2023-01-22 17:28:41 UTC (rev 13079)
@@ -21,6 +21,7 @@
testImplementation (testFixtures(group: "org.axsl", name: "axsl-font", version: versions.axsl))
testImplementation (testFixtures(group: "org.axsl", name: "axsl-kp-model", version: versions.axsl))
+ testImplementation (testFixtures(project(":foray-font")))
}
javadoc {
Deleted: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LbTestUtilities.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LbTestUtilities.java 2023-01-22 17:27:24 UTC (rev 13078)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LbTestUtilities.java 2023-01-22 17:28:41 UTC (rev 13079)
@@ -1,148 +0,0 @@
-/*
- * Copyright 2019 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.linebreak;
-
-import org.foray.ps.encode.CharSetExtendedRoman;
-
-import org.axsl.font.fixture.MockFont;
-import org.axsl.ps.CharSet;
-
-/**
- * Utilities for Linebreaking tests.
- */
-public final class LbTestUtilities {
-
- /**
- * Private constructor. This class should never be instantiated.
- */
- private LbTestUtilities() { }
-
- /**
- * Creates a mock font that knows some metrics for Monotype equipment.
- * @param conversion A conversion factor to be applied to the raw Monotype "unit," allowing those units to be
- * converted to another scheme such as millipoints.
- * @return A mock font suitable for emulating Monotype equipment.
- * @see <a href="https://books.google.com/books/download/The_monotype_system.pdf?id=6kU5AAAAMAAJ&output=pdf">1912,
- * The Monotype System, Philadelphia, Lanston Monotype Machine Co.</a>
- * @see "1999, Digital Typography, Chapter 3, page 75, table 1, for the values documented by Knuth-Plass."
- */
- public static MockFont createMonotypeFont(final double conversion) {
- /* The Knuth-Plass values listed were obtained from Chapter 3 of Digital Typography. They do not appear in the
- * original 1981 article.
- * By using the the referenced table in "The Monotype System", we have added the missing capitals that were not
- * listed in the article.
- * Except where noted, the "Digital Typography" values agree with those of "The Monotype System". */
-
- final CharSet charSet = CharSetExtendedRoman.getInstance();
- final MockFont font = new MockFont();
- font.setCharSet(charSet);
-
- /* It is unclear from the table in the Monotype manual what the width of a "normal" space is. Knuth uses 6 in
- * most cases, but 8 after a period. */
- font.setWidth(' ', (int) (conversion * 6));
- font.setWidth('’', (int) (conversion * 5));
- font.setWidth(',', (int) (conversion * 5));
- font.setWidth('-', (int) (conversion * 5));
- font.setWidth('.', (int) (conversion * 5));
- font.setWidth(';', (int) (conversion * 6));
-
- font.setWidth('A', (int) (conversion * 13));
- font.setWidth('B', (int) (conversion * 13));
- font.setWidth('C', (int) (conversion * 13));
- font.setWidth('D', (int) (conversion * 14));
- font.setWidth('E', (int) (conversion * 13));
- font.setWidth('F', (int) (conversion * 12));
- font.setWidth('G', (int) (conversion * 14));
- font.setWidth('H', (int) (conversion * 15));
- font.setWidth('I', (int) (conversion * 8));
- font.setWidth('J', (int) (conversion * 9));
- font.setWidth('K', (int) (conversion * 15));
- font.setWidth('L', (int) (conversion * 12));
- font.setWidth('M', (int) (conversion * 18));
- font.setWidth('N', (int) (conversion * 15));
- font.setWidth('O', (int) (conversion * 13));
- font.setWidth('P', (int) (conversion * 12));
- font.setWidth('Q', (int) (conversion * 13));
- font.setWidth('R', (int) (conversion * 14));
- font.setWidth('S', (int) (conversion * 10));
- font.setWidth('T', (int) (conversion * 13));
- font.setWidth('U', (int) (conversion * 14));
- font.setWidth('V', (int) (conversion * 13));
- font.setWidth('W', (int) (conversion * 18));
- font.setWidth('X', (int) (conversion * 15));
- font.setWidth('Y', (int) (conversion * 14));
- font.setWidth('Z', (int) (conversion * 11));
-
- font.setWidth('a', (int) (conversion * 9));
- font.setWidth('b', (int) (conversion * 10));
- font.setWidth('c', (int) (conversion * 8));
- font.setWidth('d', (int) (conversion * 10));
- font.setWidth('e', (int) (conversion * 8));
- font.setWidth('f', (int) (conversion * 6));
- font.setWidth('g', (int) (conversion * 9));
- font.setWidth('h', (int) (conversion * 10));
- font.setWidth('i', (int) (conversion * 5));
- font.setWidth('j', (int) (conversion * 6));
- font.setWidth('k', (int) (conversion * 10));
- font.setWidth('l', (int) (conversion * 5));
- font.setWidth('m', (int) (conversion * 15));
- font.setWidth('n', (int) (conversion * 10));
- font.setWidth('o', (int) (conversion * 9));
- font.setWidth('p', (int) (conversion * 10));
- font.setWidth('q', (int) (conversion * 10));
- font.setWidth('r', (int) (conversion * 7));
- font.setWidth('s', (int) (conversion * 7));
- font.setWidth('t', (int) (conversion * 7));
- font.setWidth('u', (int) (conversion * 10));
- font.setWidth('v', (int) (conversion * 10));
- font.setWidth('w', (int) (conversion * 13));
- font.setWidth('x', (int) (conversion * 9));
- font.setWidth('y', (int) (conversion * 10));
- font.setWidth('z', (int) (conversion * 8));
-
- return font;
- }
-
- /**
- * Creates a Monotype font and adjusts it for differences between it and the values used by Knuth-Plass.
- * @param conversion A conversion factor to be applied to the raw Monotype "unit," allowing those units to be
- * converted to another scheme such as millipoints.
- * @return The font that represents the widths as published in Knuth-Plass.
- */
- public static MockFont createGrimmFont(final double conversion) {
- final MockFont font = createMonotypeFont(conversion);
- font.setWidth('-', (int) (conversion * 6));
- font.setWidth(';', (int) (conversion * 5));
- font.setWidth('I', (int) (conversion * 6));
- font.setWidth('v', (int) (conversion * 9));
- font.setWidth('x', (int) (conversion * 10));
- return font;
- }
-
-}
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-22 17:27:24 UTC (rev 13078)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2023-01-22 17:28:41 UTC (rev 13079)
@@ -28,6 +28,7 @@
package org.foray.linebreak;
+import org.foray.font.fixture.MockMonotypeFont;
import org.foray.orthography.Punctuation4a;
import org.axsl.context.LineBreakContext;
@@ -369,9 +370,7 @@
* @return The Monotype paragraph configuration.
*/
public KpContext4a createGrimmParaConfig() {
- /* Set the font metrics using the raw Monotype "unit." */
- final double conversion = 1;
- final MockFont font = LbTestUtilities.createGrimmFont(conversion);
+ final MockFont font = new MockMonotypeFont(true);
final MockFontUse fontUse = new MockFontUse();
fontUse.setFont(font);
/* Stretchability and shrinkability come from the interword values in Table 1. Note that different values are
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-22 17:27:26
|
Revision: 13078
http://sourceforge.net/p/foray/code/13078
Author: victormote
Date: 2023-01-22 17:27:24 +0000 (Sun, 22 Jan 2023)
Log Message:
-----------
1. Let Gradle find the Maven central repository. 2. Restrict the mavenLocal repository to snapshots, used only by aXSL developers.
Modified Paths:
--------------
trunk/foray/buildSrc/src/main/groovy/foray.common-conventions.gradle
Modified: trunk/foray/buildSrc/src/main/groovy/foray.common-conventions.gradle
===================================================================
--- trunk/foray/buildSrc/src/main/groovy/foray.common-conventions.gradle 2023-01-21 21:43:35 UTC (rev 13077)
+++ trunk/foray/buildSrc/src/main/groovy/foray.common-conventions.gradle 2023-01-22 17:27:24 UTC (rev 13078)
@@ -8,8 +8,22 @@
repositories {
- mavenLocal()
- maven { url "https://repo.maven.apache.org/maven2" }
+ mavenCentral {
+ mavenContent {
+ releasesOnly()
+ }
+ }
+ /* Gradle recommends against declaring mavenLocal as a repository:
+ * https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:case-for-maven-local
+ * However, we include it for developers who are concurrently developing aXSL modules, which are the only snapshot
+ * dependencies used by FOray.
+ * We could conceivably use a Gradle composite build, but do not wish to force FOray developers to build aXSL if
+ * they are not making changes to it. */
+ mavenLocal() {
+ mavenContent {
+ snapshotsOnly()
+ }
+ }
}
group = 'org.foray'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-21 21:43:38
|
Revision: 13077
http://sourceforge.net/p/foray/code/13077
Author: victormote
Date: 2023-01-21 21:43:35 +0000 (Sat, 21 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Remove unused and unneeded methods.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2023-01-21 12:42:15 UTC (rev 13076)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2023-01-21 21:43:35 UTC (rev 13077)
@@ -191,26 +191,6 @@
}
@Override
- public Font.Weight nextBolderWeight() {
- final RegisteredFont desc =
- this.registeredFontDesc.nextBolderFont();
- if (desc != null) {
- return desc.getFontWeight();
- }
- return this.registeredFontDesc.getFontWeight().nextHeaviest();
- }
-
- @Override
- public Font.Weight nextLighterWeight() {
- final RegisteredFont desc =
- this.registeredFontDesc.nextLighterFont();
- if (desc != null) {
- return desc.getFontWeight();
- }
- return this.registeredFontDesc.getFontWeight().nextLightest();
- }
-
- @Override
public org.axsl.font.FontUse nextBolderFont() {
final RegisteredFont desc =
this.registeredFontDesc.nextBolderFont();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-21 12:42:17
|
Revision: 13076
http://sourceforge.net/p/foray/code/13076
Author: victormote
Date: 2023-01-21 12:42:15 +0000 (Sat, 21 Jan 2023)
Log Message:
-----------
Add basic logic for TextArea to compute its ipd. Enable one test affected by this.
Modified Paths:
--------------
trunk/foray/foray-app/src/test/java/org/foray/app/area/BlockTests.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/area/BlockTests.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/area/BlockTests.java 2023-01-21 00:33:24 UTC (rev 13075)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/area/BlockTests.java 2023-01-21 12:42:15 UTC (rev 13076)
@@ -234,7 +234,6 @@
* @throws FontException For errors in the font system.
*/
@Test
- @Disabled
public void testBlock003() throws FontException {
final AreaTreeCreator creator = AreaTreeCreator.getInstance();
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java 2023-01-21 00:33:24 UTC (rev 13075)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java 2023-01-21 12:42:15 UTC (rev 13076)
@@ -80,7 +80,7 @@
final int resolvedLetterSpacing, final BigDecimal resolvedIpdStretch) {
if (LineArea4a.shouldCreateTextArea(foText, this, startOffset, sizeInChars, isLastItemOnLine, this)) {
final TextArea newTextArea = TextAreaCharacters.makeTextArea(foText, this, startOffset, sizeInChars,
- hasDiscretionaryHyphen);
+ hasDiscretionaryHyphen, resolvedWordSpacing, resolvedLetterSpacing, resolvedIpdStretch);
this.children.add(newTextArea);
return newTextArea;
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2023-01-21 00:33:24 UTC (rev 13075)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2023-01-21 12:42:15 UTC (rev 13076)
@@ -996,7 +996,8 @@
final int resolvedLetterSpacing, final BigDecimal resolvedIpdStretch) {
if (shouldCreateTextArea(foText, this, startOffset, sizeInChars, isLastItemOnLine, this)) {
final TextAreaCharacters newTextArea = TextAreaCharacters.createTextArea(foText, this, startOffset,
- sizeInChars, hasDiscretionaryHyphen);
+ sizeInChars, hasDiscretionaryHyphen, resolvedWordSpacing, resolvedLetterSpacing,
+ resolvedIpdStretch);
this.children.add(newTextArea);
return newTextArea;
}
@@ -1007,7 +1008,8 @@
public GlyphAreaSequenceG5 createGlyphAreaSequence(final FoTextWords paragraph,
final TextTokenFlowLocation startLocation, final TextTokenFlowLocation endLocation,
final int resolvedWordSpacing, final int resolvedLetterSpacing, final BigDecimal resolvedIpdStretch) {
- final TextAreaWords newTextArea = TextAreaWords.createTextArea(paragraph, this, startLocation, endLocation);
+ final TextAreaWords newTextArea = TextAreaWords.createTextArea(paragraph, this, startLocation, endLocation,
+ resolvedWordSpacing, resolvedLetterSpacing, resolvedIpdStretch);
this.children.add(newTextArea);
return newTextArea;
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java 2023-01-21 00:33:24 UTC (rev 13075)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java 2023-01-21 12:42:15 UTC (rev 13076)
@@ -40,10 +40,12 @@
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.render.GalleyVisitor;
import org.axsl.galley.render.GalleyVisitorException;
+import org.axsl.galley.trait.CharacterTraitsTa;
import org.axsl.unicode.block.U0000_Basic_Latin;
import org.axsl.value.WhiteSpaceTreatment;
import java.awt.Color;
+import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
@@ -70,20 +72,48 @@
/** The amount, in millipoints, of word-spacing to be used <em>on each space</em> in this text area. */
private int resolvedWordSpacing;
+ /** The stretch factor, as a percentage, that should be applied to this area along the
+ * inline-progression-direction. */
+ private BigDecimal resolvedIpdStretch;
+
/**
- * Private Constructor.
+ * Constructor.
* @param parentArea The parent area.
+ * @param resolvedWordSpacing The word spacing to be applied to each space in this area.
+ * @param resolvedLetterSpacing the letter spacing to be applied to each intra-word character in this area.
+ * @param resolvedIpdStretch The stretch factor, as a percentage, that should be applied to this area along the
+ * inline-progression-direction.
+ * 100% or null results in no stretch, values greater than 100% will increase the inline-progression-dimension
+ * (make the content wider in horizontal writing systems), and values less that 100% will decrease the
+ * inline-progression-dimension (make the the content narrower in horizontal writing systems).
+ * This computation is applied <em>after</em> any word-spacing or letter-spacing has been applied.
*/
- public TextArea(final LineArea4a parentArea) {
+ public TextArea(final LineArea4a parentArea, final int resolvedWordSpacing, final int resolvedLetterSpacing,
+ final BigDecimal resolvedIpdStretch) {
this.parent = parentArea;
+ this.resolvedWordSpacing = resolvedWordSpacing;
+ this.resolvedLetterSpacing = resolvedLetterSpacing;
+ this.resolvedIpdStretch = resolvedIpdStretch;
}
/**
- * Private Constructor.
+ * Constructor.
* @param parentArea The parent area.
+ * @param resolvedWordSpacing The word spacing to be applied to each space in this area.
+ * @param resolvedLetterSpacing the letter spacing to be applied to each intra-word character in this area.
+ * @param resolvedIpdStretch The stretch factor, as a percentage, that should be applied to this area along the
+ * inline-progression-direction.
+ * 100% or null results in no stretch, values greater than 100% will increase the inline-progression-dimension
+ * (make the content wider in horizontal writing systems), and values less that 100% will decrease the
+ * inline-progression-dimension (make the the content narrower in horizontal writing systems).
+ * This computation is applied <em>after</em> any word-spacing or letter-spacing has been applied.
*/
- public TextArea(final AbstractInlineArea parentArea) {
+ public TextArea(final AbstractInlineArea parentArea, final int resolvedWordSpacing, final int resolvedLetterSpacing,
+ final BigDecimal resolvedIpdStretch) {
this.parent = parentArea;
+ this.resolvedWordSpacing = resolvedWordSpacing;
+ this.resolvedLetterSpacing = resolvedLetterSpacing;
+ this.resolvedIpdStretch = resolvedIpdStretch;
}
/**
@@ -566,4 +596,31 @@
return false;
}
+ /**
+ * Returns the ideal ipd of this area, i.e. the width of the characters as computed by the font without any
+ * adjustments for word-spacing, letter-spacing, or stretch.
+ * @return The ideal ipd of the characters in this area.
+ */
+ public int getIdealIpd() {
+ final FontUse fontUse = traitNominalFont();
+ final int ideal = fontUse.getFont().width(getText(), traitFontSize(), FontContext.DEFAULT, getOrthography());
+ return ideal;
+ }
+
+ /**
+ * Computes the final ipd of this area, including any word-spacing, letter-spacing, or stretch.
+ * This is probably useful only for testing, because this computation should have been done during layout, i.e.
+ * <em>before</em> this object was created, and is not generally needed after that.
+ * @return The total ipd of this area.
+ */
+ public int getProgressionDimension() {
+ final int subtotal = getIdealIpd() + wordSpacingUsed() + letterSpacingUsed();
+ if (this.resolvedIpdStretch == null
+ || CharacterTraitsTa.DEFAULT_IPD_SCALING.equals(this.resolvedIpdStretch)) {
+ /* Skip the computation. */
+ return subtotal;
+ }
+ return (int) (this.resolvedIpdStretch.floatValue() * subtotal);
+ }
+
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java 2023-01-21 00:33:24 UTC (rev 13075)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java 2023-01-21 12:42:15 UTC (rev 13076)
@@ -35,6 +35,7 @@
import org.axsl.unicode.block.U0000_Basic_Latin;
import java.io.Serializable;
+import java.math.BigDecimal;
/**
* A {@link TextArea} that wraps a sequence of characters.
@@ -52,9 +53,18 @@
* Private constructor.
* @param parentArea The parent area.
* @param generatedBy The FO tree linkage.
+ * @param resolvedWordSpacing The word spacing to be applied to each space in this area.
+ * @param resolvedLetterSpacing the letter spacing to be applied to each intra-word character in this area.
+ * @param resolvedIpdStretch The stretch factor, as a percentage, that should be applied to this area along the
+ * inline-progression-direction.
+ * 100% or null results in no stretch, values greater than 100% will increase the inline-progression-dimension
+ * (make the content wider in horizontal writing systems), and values less that 100% will decrease the
+ * inline-progression-dimension (make the the content narrower in horizontal writing systems).
+ * This computation is applied <em>after</em> any word-spacing or letter-spacing has been applied.
*/
- private TextAreaCharacters(final LineArea4a parentArea, final Link<FoTextCharacters> generatedBy) {
- super(parentArea);
+ private TextAreaCharacters(final LineArea4a parentArea, final Link<FoTextCharacters> generatedBy,
+ final int resolvedWordSpacing, final int resolvedLetterSpacing, final BigDecimal resolvedIpdStretch) {
+ super(parentArea, resolvedWordSpacing, resolvedLetterSpacing, resolvedIpdStretch);
this.foLink = generatedBy;
}
@@ -62,9 +72,18 @@
* Private constructor.
* @param parentArea The parent area.
* @param generatedBy The FO tree linkage.
+ * @param resolvedWordSpacing The word spacing to be applied to each space in this area.
+ * @param resolvedLetterSpacing the letter spacing to be applied to each intra-word character in this area.
+ * @param resolvedIpdStretch The stretch factor, as a percentage, that should be applied to this area along the
+ * inline-progression-direction.
+ * 100% or null results in no stretch, values greater than 100% will increase the inline-progression-dimension
+ * (make the content wider in horizontal writing systems), and values less that 100% will decrease the
+ * inline-progression-dimension (make the the content narrower in horizontal writing systems).
+ * This computation is applied <em>after</em> any word-spacing or letter-spacing has been applied.
*/
- private TextAreaCharacters(final AbstractInlineArea parentArea, final Link<FoTextCharacters> generatedBy) {
- super(parentArea);
+ private TextAreaCharacters(final AbstractInlineArea parentArea, final Link<FoTextCharacters> generatedBy,
+ final int resolvedWordSpacing, final int resolvedLetterSpacing, final BigDecimal resolvedIpdStretch) {
+ super(parentArea, resolvedWordSpacing, resolvedLetterSpacing, resolvedIpdStretch);
this.foLink = generatedBy;
}
@@ -81,12 +100,22 @@
* 14.
* The ending array element that belongs to this TextSegment is computed as backingOffset + backingSize.
* @param hasDiscretionaryHyphen Set this to true if the text should be followed by the hyphenation character.
+ * @param resolvedWordSpacing The word spacing to be applied to each space in this area.
+ * @param resolvedLetterSpacing the letter spacing to be applied to each intra-word character in this area.
+ * @param resolvedIpdStretch The stretch factor, as a percentage, that should be applied to this area along the
+ * inline-progression-direction.
+ * 100% or null results in no stretch, values greater than 100% will increase the inline-progression-dimension
+ * (make the content wider in horizontal writing systems), and values less that 100% will decrease the
+ * inline-progression-dimension (make the the content narrower in horizontal writing systems).
+ * This computation is applied <em>after</em> any word-spacing or letter-spacing has been applied.
* @return The newly-created TextArea.
*/
static TextAreaCharacters createTextArea(final FoTextCharacters generatedBy, final LineArea4a parentArea,
- final int backingOffset, final int backingSize, final boolean hasDiscretionaryHyphen) {
+ final int backingOffset, final int backingSize, final boolean hasDiscretionaryHyphen,
+ final int resolvedWordSpacing, final int resolvedLetterSpacing, final BigDecimal resolvedIpdStretch) {
final Link<FoTextCharacters> linkage = parentArea.getLink(generatedBy);
- final TextAreaCharacters newTextArea = new TextAreaCharacters(parentArea, linkage);
+ final TextAreaCharacters newTextArea = new TextAreaCharacters(parentArea, linkage, resolvedWordSpacing,
+ resolvedLetterSpacing, resolvedIpdStretch);
newTextArea.registerLink(generatedBy);
newTextArea.init(parentArea, backingOffset, backingSize, hasDiscretionaryHyphen);
return newTextArea;
@@ -105,12 +134,22 @@
* 14.
* The ending array element that belongs to this TextSegment is computed as backingOffset + backingSize.
* @param hasDiscretionaryHyphen Set this to true if the text should be followed by the hyphenation character.
+ * @param resolvedWordSpacing The word spacing to be applied to each space in this area.
+ * @param resolvedLetterSpacing the letter spacing to be applied to each intra-word character in this area.
+ * @param resolvedIpdStretch The stretch factor, as a percentage, that should be applied to this area along the
+ * inline-progression-direction.
+ * 100% or null results in no stretch, values greater than 100% will increase the inline-progression-dimension
+ * (make the content wider in horizontal writing systems), and values less that 100% will decrease the
+ * inline-progression-dimension (make the the content narrower in horizontal writing systems).
+ * This computation is applied <em>after</em> any word-spacing or letter-spacing has been applied.
* @return The newly-created TextArea.
*/
static TextAreaCharacters makeTextArea(final FoTextCharacters generatedBy, final AbstractInlineArea parentArea,
- final int backingOffset, final int backingSize, final boolean hasDiscretionaryHyphen) {
+ final int backingOffset, final int backingSize, final boolean hasDiscretionaryHyphen,
+ final int resolvedWordSpacing, final int resolvedLetterSpacing, final BigDecimal resolvedIpdStretch) {
final Link<FoTextCharacters> linkage = parentArea.getLink(generatedBy);
- final TextAreaCharacters newTextArea = new TextAreaCharacters(parentArea, linkage);
+ final TextAreaCharacters newTextArea = new TextAreaCharacters(parentArea, linkage, resolvedWordSpacing,
+ resolvedLetterSpacing, resolvedIpdStretch);
newTextArea.registerLink(generatedBy);
newTextArea.init(parentArea, backingOffset, backingSize, hasDiscretionaryHyphen);
return newTextArea;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java 2023-01-21 00:33:24 UTC (rev 13075)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java 2023-01-21 12:42:15 UTC (rev 13076)
@@ -35,6 +35,8 @@
import org.axsl.orthography.TextTokenFlowLocation;
import org.axsl.value.group.TextModifiers;
+import java.math.BigDecimal;
+
/**
* A {@link TextArea} that wraps a sequence of words and interword content.
* @see TextAreaCharacters which instead wraps a sequence of characters.
@@ -56,10 +58,19 @@
* @param generatedBy The FO tree linkage.
* @param startLocation The starting location in {@code generatedBy} for the text in this area, inclusive.
* @param endLocation The ending location in {@code generatedBy} for the text in this area, exclusive.
+ * @param resolvedWordSpacing The word spacing to be applied to each space in this area.
+ * @param resolvedLetterSpacing the letter spacing to be applied to each intra-word character in this area.
+ * @param resolvedIpdStretch The stretch factor, as a percentage, that should be applied to this area along the
+ * inline-progression-direction.
+ * 100% or null results in no stretch, values greater than 100% will increase the inline-progression-dimension
+ * (make the content wider in horizontal writing systems), and values less that 100% will decrease the
+ * inline-progression-dimension (make the the content narrower in horizontal writing systems).
+ * This computation is applied <em>after</em> any word-spacing or letter-spacing has been applied.
*/
public TextAreaWords(final LineArea4a parentArea, final Link<FoTextWords> generatedBy,
- final TextTokenFlowLocation startLocation, final TextTokenFlowLocation endLocation) {
- super(parentArea);
+ final TextTokenFlowLocation startLocation, final TextTokenFlowLocation endLocation,
+ final int resolvedWordSpacing, final int resolvedLetterSpacing, final BigDecimal resolvedIpdStretch) {
+ super(parentArea, resolvedWordSpacing, resolvedLetterSpacing, resolvedIpdStretch);
if (startLocation == null) {
throw new IllegalArgumentException("startLocation cannot be null.");
}
@@ -77,12 +88,22 @@
* @param parentArea The parent area.
* @param startLocation The starting location in {@code generatedBy} for the text in this area, inclusive.
* @param endLocation The ending location in {@code generatedBy} for the text in this area, exclusive.
+ * @param resolvedWordSpacing The word spacing to be applied to each space in this area.
+ * @param resolvedLetterSpacing the letter spacing to be applied to each intra-word character in this area.
+ * @param resolvedIpdStretch The stretch factor, as a percentage, that should be applied to this area along the
+ * inline-progression-direction.
+ * 100% or null results in no stretch, values greater than 100% will increase the inline-progression-dimension
+ * (make the content wider in horizontal writing systems), and values less that 100% will decrease the
+ * inline-progression-dimension (make the the content narrower in horizontal writing systems).
+ * This computation is applied <em>after</em> any word-spacing or letter-spacing has been applied.
* @return The newly-created TextArea.
*/
static TextAreaWords createTextArea(final FoTextWords generatedBy, final LineArea4a parentArea,
- final TextTokenFlowLocation startLocation, final TextTokenFlowLocation endLocation) {
+ final TextTokenFlowLocation startLocation, final TextTokenFlowLocation endLocation,
+ final int resolvedWordSpacing, final int resolvedLetterSpacing, final BigDecimal resolvedIpdStretch) {
final Link<FoTextWords> linkage = parentArea.getLink(generatedBy);
- final TextAreaWords newTextArea = new TextAreaWords(parentArea, linkage, startLocation, endLocation);
+ final TextAreaWords newTextArea = new TextAreaWords(parentArea, linkage, startLocation, endLocation,
+ resolvedWordSpacing, resolvedLetterSpacing, resolvedIpdStretch);
newTextArea.registerLink(generatedBy);
return newTextArea;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|