Skip to content

Commit

Permalink
Fixes #440 - Remove trailing whitespace when not left aligned.
Browse files Browse the repository at this point in the history
With test. Also had to recommit bidi tests because changed the result pixel wise.
  • Loading branch information
danfickle committed Feb 20, 2020
1 parent 179494b commit 2548d79
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ private static void startNewInlineLine(LayoutContext c, BlockBox box, int breakA
List<Layer> pendingInlineLayers, int lineOffset, InlineBox inlineBox, LineBreakContext lbContext) {

IdentValue align = inlineBox.getStyle().getIdent(CSSName.TEXT_ALIGN);
if (align == IdentValue.JUSTIFY ||
(align != IdentValue.LEFT && inlineBox.getStyle().getWordWrap() == IdentValue.BREAK_WORD)) {
if (align != IdentValue.LEFT) {
current.line.trimTrailingSpace(c);
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html>
<head>
<style>
@page {
size: 250px 600px;
}
body {
font-size: 16px;
text-align: right;
}
</style>
</head>
<body>
This is some text to show that text aligned right has the trailing spaces removed,
just like justified text. All the characters at the right should line up em
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,15 @@ public void testIssue446LangSelector() throws IOException {
assertTrue(vt.runTest("issue-446-lang-selector"));
}

/**
* Tests that aligned right text doesn't have trailing spaces
* that cause ragged text on the right.
*/
@Test
public void testIssue440TrailingWsAlignRight() throws IOException {
assertTrue(vt.runTest("issue-440-trailing-ws-align-right"));
}

/**
* Don't launch a ClassCastException if a td in a table is floated.
*
Expand Down

0 comments on commit 2548d79

Please sign in to comment.