mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-05 16:37:47 +03:00
Merge upstream master release 0.30 into letter-spacing-workaround patch branch
This commit is contained in:
commit
9620c71c13
@ -11,6 +11,7 @@ addons:
|
||||
packages:
|
||||
- ttf-dejavu
|
||||
install:
|
||||
- pip install --upgrade setuptools
|
||||
- pip install pytest flake8 -e .
|
||||
- mkdir -p ~/.fonts
|
||||
- wget "https://github.com/Kozea/Ahem/blob/master/Ahem.ttf?raw=true" -O ~/.fonts/Ahem.ttf
|
||||
|
16
CHANGES
16
CHANGES
@ -2,6 +2,22 @@ WeasyPrint changelog
|
||||
====================
|
||||
|
||||
|
||||
Version 0.30
|
||||
------------
|
||||
|
||||
Released on 2016-07-18.
|
||||
|
||||
WeasyPrint now depends on html5lib-0.999999999.
|
||||
|
||||
Bux fixes:
|
||||
|
||||
* Fix Acid2
|
||||
* `#325: <https://github.com/Kozea/WeasyPrint/issues/325>`_:
|
||||
Cutting lines is broken in page margin boxes.
|
||||
* `#334: <https://github.com/Kozea/WeasyPrint/issues/334>`_:
|
||||
Newest html5lib 0.999999999 breaks rendering.
|
||||
|
||||
|
||||
Version 0.29
|
||||
------------
|
||||
|
||||
|
92
docs/_static/custom.css
vendored
92
docs/_static/custom.css
vendored
@ -1,87 +1,11 @@
|
||||
@import 'default.css';
|
||||
|
||||
.footnote-reference { vertical-align: super; font-size: 75% }
|
||||
.wy-nav-content {
|
||||
height: auto;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
@bottom-center {
|
||||
content: counter(page);
|
||||
font-size: 75%;
|
||||
}
|
||||
.wy-grid-for-nav {
|
||||
height: auto;
|
||||
position: static;
|
||||
}
|
||||
|
||||
@page:first {
|
||||
@bottom-center {
|
||||
content: '';
|
||||
}
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
background: transparent !important;
|
||||
border-bottom: none !important;
|
||||
font-family: "Fontin" !important;
|
||||
}
|
||||
|
||||
.headerlink {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.documentwrapper {
|
||||
float: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 26pt !important;
|
||||
margin: 5em 1em !important;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 20pt !important;
|
||||
page-break-before: always;
|
||||
}
|
||||
|
||||
body, div.document {
|
||||
background: transparent;
|
||||
font-family: "Fontin Sans" !important;
|
||||
}
|
||||
|
||||
div.highlight {
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
pre, span.pre {
|
||||
border: 0 !important;
|
||||
font-family: "DejaVu Sans Mono";
|
||||
}
|
||||
|
||||
pre {
|
||||
background: #f8f8f8;
|
||||
font-size: 10pt;
|
||||
page-break-before: avoid;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
pre + pre {
|
||||
page-break-before: auto;
|
||||
}
|
||||
|
||||
span.pre, tt.docutils.literal {
|
||||
background: transparent !important;
|
||||
font-size: 10.5pt;
|
||||
}
|
||||
|
||||
.footnote-reference {
|
||||
margin-left: 0.3em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
dl.method, dl.function {
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
}
|
||||
}
|
@ -109,6 +109,10 @@ html_theme = 'sphinx_rtd_theme'
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
html_theme_path = ['_themes']
|
||||
|
||||
html_context = {
|
||||
'extra_css_files': ['_static/custom.css']
|
||||
}
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
@ -130,8 +134,6 @@ html_favicon = 'icon.ico'
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
#html_style = 'custom.css'
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit eeff5645dc4eeb7a5c4910d39c17131961045dce
|
||||
Subproject commit e9481bfea50584951fe1703fae997a9387ed4dac
|
2
setup.py
2
setup.py
@ -27,7 +27,7 @@ LONG_DESCRIPTION = open(path.join(path.dirname(__file__), 'README.rst')).read()
|
||||
REQUIREMENTS = [
|
||||
# XXX: Keep this in sync with docs/install.rst
|
||||
'lxml>=3.0',
|
||||
'html5lib>=0.999',
|
||||
'html5lib>=0.999999999',
|
||||
'tinycss==0.3',
|
||||
'cssselect>=0.6',
|
||||
'cffi>=0.6',
|
||||
|
@ -19,7 +19,7 @@ import contextlib # noqa
|
||||
import html5lib # noqa
|
||||
|
||||
|
||||
VERSION = '0.29'
|
||||
VERSION = '0.30'
|
||||
__version__ = VERSION
|
||||
|
||||
# Used for 'User-Agent' in HTTP and 'Creator' in PDF
|
||||
@ -83,13 +83,15 @@ class HTML(object):
|
||||
if source_type == 'tree':
|
||||
result = source
|
||||
else:
|
||||
if not encoding:
|
||||
encoding = protocol_encoding
|
||||
if isinstance(source, unicode):
|
||||
encoding = None
|
||||
result = html5lib.parse(
|
||||
source, treebuilder='lxml', encoding=encoding,
|
||||
namespaceHTMLElements=False)
|
||||
result = html5lib.parse(
|
||||
source, treebuilder='lxml',
|
||||
namespaceHTMLElements=False)
|
||||
else:
|
||||
result = html5lib.parse(
|
||||
source, treebuilder='lxml', override_encoding=encoding,
|
||||
transport_encoding=protocol_encoding,
|
||||
namespaceHTMLElements=False)
|
||||
assert result
|
||||
base_url = find_base_url(result, base_url)
|
||||
if hasattr(result, 'getroot'):
|
||||
|
@ -34,13 +34,14 @@ def float_layout(context, box, containing_block, device_size, absolute_boxes,
|
||||
from .inlines import inline_replaced_box_width_height
|
||||
|
||||
cb_width, cb_height = (containing_block.width, containing_block.height)
|
||||
resolve_percentages(box, (cb_width, cb_height))
|
||||
|
||||
# TODO: This is only handled later in blocks.block_container_layout
|
||||
# http://www.w3.org/TR/CSS21/visudet.html#normal-block
|
||||
if cb_height == 'auto':
|
||||
cb_height = (
|
||||
containing_block.position_y - containing_block.content_box_y())
|
||||
|
||||
resolve_percentages(box, (cb_width, cb_height))
|
||||
resolve_position_percentages(box, (cb_width, cb_height))
|
||||
|
||||
if box.margin_left == 'auto':
|
||||
|
@ -4954,7 +4954,10 @@ def test_floats():
|
||||
div, anon_block = body.children
|
||||
line, = anon_block.children
|
||||
img_2, = line.children
|
||||
assert outer_area(img_2) == (0, 0, 50, 50)
|
||||
|
||||
# Regression test
|
||||
# https://github.com/Kozea/WeasyPrint/issues/263
|
||||
page, = parse('''<div style="top:100%; float:left">''')
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
@ -5737,3 +5740,50 @@ def test_radial_gradient():
|
||||
init=(450, 100, 0, 450 * sqrt2), scale_y=200/450)
|
||||
layout('radial-gradient(farthest-corner at 40px 210px, blue, lime)',
|
||||
init=(40, 210, 0, 360 * sqrt2), scale_y=210/360)
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_shrink_to_fit_floating_point_error():
|
||||
"""Test that no floating point error occurs during shrink to fit.
|
||||
|
||||
See bugs #325 and #288, see commit fac5ee9.
|
||||
|
||||
"""
|
||||
for margin_left in range(1, 10):
|
||||
for font_size in range(1, 10):
|
||||
page, = parse('''
|
||||
<style>
|
||||
@page { size: 100000px 100px }
|
||||
p { float: left; margin-left: 0.%iin; font-size: 0.%iem;
|
||||
font-family: "ahem" }
|
||||
</style>
|
||||
<p>this parrot is dead</p>
|
||||
''' % (margin_left, font_size))
|
||||
html, = page.children
|
||||
body, = html.children
|
||||
p, = body.children
|
||||
assert len(p.children) == 1
|
||||
|
||||
letters = 1
|
||||
for font_size in (1, 5, 10, 50, 100, 1000, 10000):
|
||||
while True:
|
||||
page, = parse('''
|
||||
<style>
|
||||
@page { size: %i0pt %i0px }
|
||||
p { font-size: %ipt; font-family: "ahem" }
|
||||
</style>
|
||||
<p>mmm <b>%s a</b></p>
|
||||
''' % (font_size, font_size, font_size, 'i' * letters))
|
||||
html, = page.children
|
||||
body, = html.children
|
||||
p, = body.children
|
||||
assert len(p.children) in (1, 2)
|
||||
assert len(p.children[0].children) == 2
|
||||
text = p.children[0].children[1].children[0].text
|
||||
print(font_size, text, letters)
|
||||
assert text
|
||||
if text.endswith('i'):
|
||||
letters = 1
|
||||
break
|
||||
else:
|
||||
letters += 1
|
||||
|
@ -431,6 +431,14 @@ def split_first_line(text, style, hinting, max_width, line_width):
|
||||
|
||||
if text_wrap:
|
||||
max_width = None
|
||||
elif max_width is not None:
|
||||
# In some cases (shrink-to-fit result being the preferred width)
|
||||
# this value is coming from Pango itself,
|
||||
# but floating point errors have accumulated:
|
||||
# width2 = (width + X) - X # in some cases, width2 < width
|
||||
# Increase the value a bit to compensate and not introduce
|
||||
# an unexpected line break. The 1e-9 value comes from PEP 485.
|
||||
max_width *= 1 + 1e-9
|
||||
|
||||
# Step #1: Get a draft layout with the first line
|
||||
layout = None
|
||||
|
Loading…
Reference in New Issue
Block a user