-
-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #891 from Kozea/text-overflow
Support text-overflow
- Loading branch information
Showing
7 changed files
with
145 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
""" | ||
weasyprint.tests.test_draw.test_text | ||
------------------------------------ | ||
Test how text is drawn. | ||
:copyright: Copyright 2011-2019 Simon Sapin and contributors, see AUTHORS. | ||
:license: BSD, see LICENSE for details. | ||
""" | ||
|
||
from . import assert_pixels | ||
|
||
|
||
def test_text_overflow_clip(): | ||
assert_pixels('text_overflow', 9, 7, ''' | ||
_________ | ||
_RRRRRRR_ | ||
_RRRRRRR_ | ||
_________ | ||
_RR__RRR_ | ||
_RR__RRR_ | ||
_________ | ||
''', ''' | ||
<style> | ||
@font-face {src: url(AHEM____.TTF); font-family: ahem} | ||
@page { | ||
size: 9px 7px; | ||
background: white; | ||
} | ||
body { | ||
color: red; | ||
font-family: ahem; | ||
font-size: 2px; | ||
} | ||
div { | ||
line-height: 1; | ||
margin: 1px; | ||
overflow: hidden; | ||
width: 3.5em; | ||
} | ||
</style> | ||
<div>abcde</div> | ||
<div style="white-space: nowrap">a bcde</div>''') | ||
|
||
|
||
def test_text_overflow_ellipsis(): | ||
assert_pixels('text_overflow', 9, 16, ''' | ||
_________ | ||
_RRRRRR__ | ||
_RRRRRR__ | ||
_________ | ||
_RR__RR__ | ||
_RR__RR__ | ||
_________ | ||
_RRRRRR__ | ||
_RRRRRR__ | ||
_________ | ||
_RRRRRRR_ | ||
_RRRRRRR_ | ||
_________ | ||
_RRRRRRR_ | ||
_RRRRRRR_ | ||
_________ | ||
''', ''' | ||
<style> | ||
@font-face {src: url(AHEM____.TTF); font-family: ahem} | ||
@page { | ||
background: white; | ||
size: 9px 16px; | ||
} | ||
body { | ||
color: red; | ||
font-family: ahem; | ||
font-size: 2px; | ||
} | ||
div { | ||
line-height: 1; | ||
margin: 1px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
width: 3.5em; | ||
} | ||
div div { | ||
margin: 0; | ||
} | ||
</style> | ||
<div>abcde</div> | ||
<div style="white-space: nowrap">a bcde</div> | ||
<div><span>a<span>b</span>cd</span>e</div> | ||
<div><div style="text-overflow: clip">abcde</div></div> | ||
<div><div style="overflow: visible">abcde</div></div> | ||
''') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters