1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 08:27:22 +03:00

Obey code conventions

This commit is contained in:
Johannes Duschl 2014-05-23 11:37:54 +02:00
parent c243ceb8c2
commit c70233dceb

View File

@ -507,10 +507,13 @@ def split_first_line(text, style, hinting, max_width, line_width):
# manual hyphenation, check for missing hyphen
if hyphens == 'manual':
if len(first_part) and first_part[len(first_part)-1] == u'\u00AD':
new_first_line = (first_part[:len(first_part)-1] + style.hyphenate_character)
temp_layout = create_layout(new_first_line, style, hinting, None)
if (len(first_part)
and first_part[len(first_part)-1] == u'\u00AD'):
new_first_line = (
first_part[:len(first_part)-1]
+ style.hyphenate_character)
temp_layout = create_layout(
new_first_line, style, hinting, None)
temp_lines = temp_layout.iter_lines()
temp_first_line = next(temp_lines, None)
temp_second_line = next(temp_lines, None)
@ -525,26 +528,30 @@ def split_first_line(text, style, hinting, max_width, line_width):
# the hyphen does not fit, break earlier
else:
prev_hyphen = first_part.rfind(u'\u00AD', 0, len(first_part)-2)
prev_blank = first_part.rfind(' ', 0, len(first_part)-2)
prev_hyphen = first_part.rfind(u'\u00AD',
0, len(first_part)-2)
prev_blank = first_part.rfind(' ',
0, len(first_part)-2)
if (prev_hyphen > -1) or (prev_blank > -1):
if prev_hyphen > prev_blank:
new_first_line = (first_part[:prev_hyphen] + style.hyphenate_character)
new_first_line = (
first_part[:prev_hyphen]
+ style.hyphenate_character)
else:
new_first_line = (first_part[:prev_blank])
temp_layout = create_layout(new_first_line, style, hinting, max_width)
temp_layout = create_layout(
new_first_line,
style, hinting, max_width)
temp_lines = temp_layout.iter_lines()
temp_first_line = next(temp_lines, None)
temp_second_line = next(temp_lines, None)
first_line = temp_first_line
second_line = temp_second_line
second_line = temp_second_line
layout = temp_layout
resume_at = len(new_first_line)
resume_at = len(new_first_line)
elif hyphens =='auto' and lang:
dictionary_key = (lang, left, right, total)
@ -572,7 +579,6 @@ def split_first_line(text, style, hinting, max_width, line_width):
if temp_first_line_width <= max_width:
break
# Step 5: Try to break word if it's too long for the line
overflow_wrap = style.overflow_wrap
first_line_width, _height = get_size(first_line)