log.debug("Could not find a set of breaking points " + threshold);
return 0;
}
+ // lastDeactivated was a "good" break, while lastTooShort and lastTooLong
+ // were "bad" breaks since the beginning;
+ // if it is not the node we just restarted from, lastDeactivated can
+ // replace either lastTooShort or lastTooLong
+ if (lastDeactivated != null && lastDeactivated != lastForced) {
+ if (lastDeactivated.adjustRatio > 0) {
+ lastTooShort = lastDeactivated;
+ } else {
+ lastTooLong = lastDeactivated;
+ }
+ }
if (lastTooShort == null || lastForced.position == lastTooShort.position) {
if (isPartOverflowRecoveryActivated()) {
if (this.lastRecovered == null) {
// the word fragment ends with a character that acts as a hyphen
// if a break occurs the width does not increase,
// otherwise there is one more letter space
- wordElements.addAll(createElementsForAHyphen(alignment, 0, letterSpaceWidth, false));
+ wordElements.addAll(createElementsForAHyphen(alignment, 0, letterSpaceWidth, true));
}
return wordElements;
}
// static final int SOFT_HYPHEN_PENALTY = KnuthPenalty.FLAGGED_PENALTY / 10;
static final int SOFT_HYPHEN_PENALTY = 1;
private LinkedList createElementsForAHyphen(int alignment,
- int widthIfBreakOccurs, MinOptMax widthIfNoBreakOccurs, boolean softHyphen) {
+ int widthIfBreakOccurs, MinOptMax widthIfNoBreakOccurs, boolean unflagged) {
if (widthIfNoBreakOccurs == null) {
widthIfNoBreakOccurs = ZERO_MINOPTMAX;
}
(new KnuthGlue(0, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
new LeafPosition(this, -1), false));
*/
+ hyphenElements.add
+ (new KnuthPenalty(0, KnuthElement.INFINITE, false,
+ new LeafPosition(this, -1), true));
hyphenElements.add
(new KnuthGlue(lineEndBAP, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
new LeafPosition(this, -1), true));
hyphenElements.add
(new KnuthPenalty(hyphIPD,
- softHyphen ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, true,
+ unflagged ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
new LeafPosition(this, -1), false));
hyphenElements.add
(new KnuthGlue(-(lineEndBAP + lineStartBAP),
new LeafPosition(this, -1), false));
*/
if (lineStartBAP != 0 || lineEndBAP != 0) {
+ hyphenElements.add
+ (new KnuthPenalty(0, KnuthElement.INFINITE, false,
+ new LeafPosition(this, -1), true));
hyphenElements.add
(new KnuthGlue(lineEndBAP, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
new LeafPosition(this, -1), false));
hyphenElements.add
(new KnuthPenalty(widthIfBreakOccurs,
- softHyphen ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, true,
+ unflagged ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
new LeafPosition(this, -1), false));
hyphenElements.add
(new KnuthGlue(widthIfNoBreakOccurs.opt - (lineStartBAP + lineEndBAP),
(new KnuthGlue(lineStartBAP, 0, 0,
new LeafPosition(this, -1), false));
} else {
+ hyphenElements.add
+ (new KnuthPenalty(0, KnuthElement.INFINITE, false,
+ new LeafPosition(this, -1), true));
hyphenElements.add
(new KnuthGlue(0, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
new LeafPosition(this, -1), false));
hyphenElements.add
(new KnuthPenalty(widthIfBreakOccurs,
- softHyphen ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, true,
+ unflagged ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
new LeafPosition(this, -1), false));
hyphenElements.add
(new KnuthGlue(widthIfNoBreakOccurs.opt,
new LeafPosition(this, -1), false));
*/
if (lineStartBAP != 0 || lineEndBAP != 0) {
+ hyphenElements.add
+ (new KnuthPenalty(0, KnuthElement.INFINITE, false,
+ new LeafPosition(this, -1), true));
+
hyphenElements.add
(new KnuthGlue(lineEndBAP, 0, 0,
new LeafPosition(this, -1), false));
hyphenElements.add
(new KnuthPenalty(widthIfBreakOccurs,
- softHyphen ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, true,
+ unflagged ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
new LeafPosition(this, -1), false));
// extra elements representing a letter space that is suppressed
// if a break occurs
} else {
hyphenElements.add
(new KnuthPenalty(widthIfBreakOccurs,
- softHyphen ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, true,
+ unflagged ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
new LeafPosition(this, -1), false));
// extra elements representing a letter space that is suppressed
// if a break occurs
}
+
<changes>
<release version="FOP Trunk">
+ <action context="Code" dev="LF" type="fix" fixes-bug="41019">
+ Fix incorrect behaviour of the BreakingAlgorithm when some inline content is wider than
+ the available ipd, causing a restart.
+ </action>
<action context="Code" dev="JM" type="fix">
Fix for PDF corruption when a TrueType font with spaces in its name is embedded and no
XML font metrics file for that font is used.
<!-- from the spec: If that dimension is not specified explicitly (i.e., it depends on
content's blockprogression-dimension), the value is interpreted as "auto". -->
<!-- The 10% are ignored in this case. -->
- <eval expected="28800" xpath="//flow/block[2]/@bpd"/> <!-- 2 lines -->
+ <eval expected="43200" xpath="//flow/block[2]/@bpd"/> <!-- 3 lines -->
<eval expected="100000" xpath="//flow/block[2]/@ipd"/>
- <eval expected="28800" xpath="//flow/block[2]/block[1]/block[1]/@bpd"/>
+ <eval expected="43200" xpath="//flow/block[2]/block[1]/block[1]/@bpd"/>
<eval expected="50000" xpath="//flow/block[2]/block[1]/block[1]/@ipd"/>
<!-- absolute -->
<!-- from the spec: If that dimension is not specified explicitly (i.e., it depends on
content's blockprogression-dimension), the value is interpreted as "auto". -->
<!-- The 10% are ignored in this case. -->
- <eval expected="43200" xpath="//flow/block[4]/@bpd"/> <!-- 3 lines -->
+ <eval expected="57600" xpath="//flow/block[4]/@bpd"/> <!-- 4 lines -->
<eval expected="100000" xpath="//flow/block[4]/@ipd"/>
- <eval expected="43200" xpath="//flow/block[4]/block[1]/block[1]/@bpd"/>
+ <eval expected="28800" xpath="//flow/block[4]/block[1]/block[1]/@bpd"/> <!-- the first 2 lines ... -->
<eval expected="50000" xpath="//flow/block[4]/block[1]/block[1]/@ipd"/>
+ <eval expected="28800" xpath="//flow/block[4]/block[1]/block[2]/@bpd"/> <!-- ... and the other 2 lines -->
+ <eval expected="50000" xpath="//flow/block[4]/block[1]/block[2]/@ipd"/>
</checks>
</testcase>
\r
<eval expected="188950" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipd"/>\r
<eval expected="color=#ffff00" xpath="//flow/block[5]/lineArea[1]/inlineparent/@background"/>\r
- <eval expected="313470" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>\r
+ <eval expected="335700" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>\r
<eval expected="color=#ffff00" xpath="//flow/block[5]/lineArea[2]/inlineparent/@background"/>\r
- <eval expected="145610" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>\r
+ <eval expected="126160" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>\r
<eval expected="color=#ffff00" xpath="//flow/block[5]/lineArea[3]/inlineparent/@background"/>\r
\r
<eval expected="188950" xpath="//flow/block[6]/lineArea[1]/inlineparent/@ipd"/>\r
<eval expected="color=#ffff00" xpath="//flow/block[6]/lineArea[1]/inlineparent/@background"/>\r
- <eval expected="313470" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>\r
+ <eval expected="335700" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>\r
<eval expected="color=#ffff00" xpath="//flow/block[6]/lineArea[2]/inlineparent/@background"/>\r
- <eval expected="109650" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>\r
+ <eval expected="90200" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>\r
<eval expected="color=#ffff00" xpath="//flow/block[6]/lineArea[3]/inlineparent/@background"/>\r
\r
<eval expected="199793" xpath="//flow/block[7]/lineArea[1]/inlineparent/@ipd"/>\r
<eval expected="color=#ffff00" xpath="//flow/block[7]/lineArea[1]/inlineparent/@background"/>\r
<eval expected="350000" xpath="//flow/block[7]/lineArea[2]/inlineparent/@ipd"/>\r
<eval expected="color=#ffff00" xpath="//flow/block[7]/lineArea[2]/inlineparent/@background"/>\r
- <eval expected="118530" xpath="//flow/block[7]/lineArea[3]/inlineparent/@ipd"/>\r
+ <eval expected="99080" xpath="//flow/block[7]/lineArea[3]/inlineparent/@ipd"/>\r
<eval expected="color=#ffff00" xpath="//flow/block[7]/lineArea[3]/inlineparent/@background"/>\r
\r
<eval expected="128370" xpath="//flow/block[8]/lineArea[1]/inlineparent/@ipd"/>\r
<eval expected="3000" xpath="//flow/block[4]/lineArea[3]/inlineparent/@padding-end"/>\r
<eval expected="5000" xpath="//flow/block[4]/lineArea[3]/inlineparent/@padding-start"/>\r
\r
- <eval expected="149500" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipd"/>\r
- <eval expected="159500" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipda"/>\r
+ <eval expected="172840" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipd"/>\r
+ <eval expected="182840" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipda"/>\r
<eval expected="0" xpath="//flow/block[5]/lineArea[1]/inlineparent/@offset"/>\r
<eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[1]/inlineparent/@border-after"/>\r
<eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[1]/inlineparent/@border-before"/>\r
<eval expected="1000" xpath="//flow/block[5]/lineArea[1]/inlineparent/@padding-before"/>\r
<eval expected="3000" xpath="//flow/block[5]/lineArea[1]/inlineparent/@padding-end"/>\r
<eval expected="5000" xpath="//flow/block[5]/lineArea[1]/inlineparent/@padding-start"/>\r
- <eval expected="237340" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>\r
- <eval expected="247340" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipda"/>\r
+ <eval expected="231230" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>\r
+ <eval expected="241230" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipda"/>\r
<eval expected="0" xpath="//flow/block[5]/lineArea[2]/inlineparent/@offset"/>\r
<eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[2]/inlineparent/@border-after"/>\r
<eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[2]/inlineparent/@border-before"/>\r
<eval expected="1000" xpath="//flow/block[5]/lineArea[2]/inlineparent/@padding-before"/>\r
<eval expected="3000" xpath="//flow/block[5]/lineArea[2]/inlineparent/@padding-end"/>\r
<eval expected="5000" xpath="//flow/block[5]/lineArea[2]/inlineparent/@padding-start"/>\r
- <eval expected="239550" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>\r
- <eval expected="249550" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipda"/>\r
+ <eval expected="222320" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>\r
+ <eval expected="232320" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipda"/>\r
<eval expected="0" xpath="//flow/block[5]/lineArea[3]/inlineparent/@offset"/>\r
<eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[3]/inlineparent/@border-after"/>\r
<eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[3]/inlineparent/@border-before"/>\r
<eval expected="1000" xpath="//flow/block[6]/lineArea[1]/inlineparent/@padding-after"/>\r
<eval expected="1000" xpath="//flow/block[6]/lineArea[1]/inlineparent/@padding-before"/>\r
<eval expected="5000" xpath="//flow/block[6]/lineArea[1]/inlineparent/@padding-start"/>\r
- <eval expected="237340" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>\r
- <eval expected="237340" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipda"/>\r
+ <eval expected="254570" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>\r
+ <eval expected="254570" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipda"/>\r
<eval expected="0" xpath="//flow/block[6]/lineArea[2]/inlineparent/@offset"/>\r
<eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[2]/inlineparent/@border-after"/>\r
<eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[2]/inlineparent/@border-before"/>\r
<eval expected="1000" xpath="//flow/block[6]/lineArea[2]/inlineparent/@padding-after"/>\r
<eval expected="1000" xpath="//flow/block[6]/lineArea[2]/inlineparent/@padding-before"/>\r
- <eval expected="239550" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>\r
- <eval expected="243550" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipda"/>\r
+ <eval expected="222320" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>\r
+ <eval expected="226320" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipda"/>\r
<eval expected="0" xpath="//flow/block[6]/lineArea[3]/inlineparent/@offset"/>\r
<eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[3]/inlineparent/@border-after"/>\r
<eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[3]/inlineparent/@border-before"/>\r