[FOray-commit] SF.net SVN: foray:[13100] trunk/foray/foray-linebreak/src
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
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.
|