1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 00:21:15 +03:00
This commit is contained in:
Simon Sapin 2011-10-11 12:09:37 +02:00
parent fe6182b4a3
commit 67bb96ea06
4 changed files with 13 additions and 3 deletions

View File

@ -706,6 +706,8 @@ def expand_font(name, values):
# Then line-height is optional, but font-family is not so the list
# must not be empty yet
if not values:
raise InvalidValues
value = values.pop()
if line_height([value]) is not None:

View File

@ -79,6 +79,8 @@ def skip_first_whitespace(box, skip_stack):
return index, None
if isinstance(box, (boxes.LineBox, boxes.InlineBox)):
if index == 0 and not box.children:
return None
result = skip_first_whitespace(box.children[index], next_skip_stack)
if result == 'continue':
index += 1

View File

@ -722,7 +722,9 @@ def test_page_and_linebox_breaking():
@page { size: 100px; margin:2px; border:1px solid }
body { margin: 0 }
</style>
<div>%(content)s</div>'''
<div><span/>%(content)s</div>'''
# The empty <span/> above tests a corner case
# in skip_first_whitespace()
page = page % {'fonts': FONTS, 'content': content}
return parse(page)

View File

@ -43,8 +43,12 @@ class TextFragment(object):
attributes = dict(
# TODO: somehow handle color.alpha
color='#%02x%02x%02x' % (color.red, color.green, color.blue),
face=', '.join(style.font_family),
variant=style.font_variant,
# Other than 'face', values are numbers or known keyword and dont
# need escaping.
face=', '.join(style.font_family)
.replace('&', '&amp;').replace('"', '&quot;'),
# CSS: small-caps, Pango: smallcaps
variant=style.font_variant.replace('-', ''),
style=style.font_style,
size=Pango.units_from_double(style.font_size),
weight=int(style.font_weight),