Skip to content

Commit

Permalink
fixed disappearing space characters is some circumstances
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalpospiech committed Jan 23, 2019
1 parent 1f0a79a commit 32b6c51
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 6 additions & 1 deletion examples/simpleInline.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!--<div style="display:block;border:1px solid #FF8000;line-height:2;">test</div>-->
<div style="font-family:'PT Sans';font-size:12px;line-height:1.2;">

<div style="font-family:'DejaVu Sans';font-size:12px;line-height:1.2;">
<div style="display:inline;border:1px solid #000000;">
<div style="display:inline;border:1px solid #FF8000;vertical-align:top;">inline1</div>
<div style="display:inline-block;padding:10px;border:1px solid #0000ff;line-height:2">inline-block1</div>
Expand All @@ -13,6 +14,10 @@
<div style="display:inline-block;padding:10px;border:1px solid #0000ff;line-height:2">inline-block3</div>
</div>
</div>

<div style="font-family:'DejaVu Sans';font-size:16px;">
<span>1</span> <span>2 3 </span><span>4</span>
</div>
<!--
<div style="display:inline;">inline</div>
<div style="display:inline;">inline2</div>
Expand Down
Binary file modified examples/simpleInline.pdf
Binary file not shown.
14 changes: 9 additions & 5 deletions lib/Layout/InlineBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,18 @@ public function appendText($childDomElement, $element = null, $style = null, $pa
}
if ($text !== '') {
if ($whiteSpace === 'normal') {
$words = preg_split('/ /u', $text, 0, PREG_SPLIT_NO_EMPTY);
$words = preg_split('/ /u', $text, 0);
$count = count($words);
if ($count) {
foreach ($words as $index => $word) {
$this->createText($word);
$parent = $this->getParent();
$anonymous = ($parent instanceof self && $parent->isAnonymous()) || $parent instanceof LineBox;
if ($index + 1 !== $count || $anonymous) {
if ($word !== '') {
$this->createText($word);
$parent = $this->getParent();
$anonymous = ($parent instanceof self && $parent->isAnonymous()) || $parent instanceof LineBox;
if ($index + 1 !== $count || $anonymous) {
$this->createText(' ', true);
}
} else {
$this->createText(' ', true);
}
}
Expand Down

0 comments on commit 32b6c51

Please sign in to comment.