mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-05 16:37:47 +03:00
Obey code conventions
This commit is contained in:
parent
c243ceb8c2
commit
c70233dceb
@ -507,10 +507,13 @@ def split_first_line(text, style, hinting, max_width, line_width):
|
|||||||
|
|
||||||
# manual hyphenation, check for missing hyphen
|
# manual hyphenation, check for missing hyphen
|
||||||
if hyphens == 'manual':
|
if hyphens == 'manual':
|
||||||
|
if (len(first_part)
|
||||||
if len(first_part) and first_part[len(first_part)-1] == u'\u00AD':
|
and first_part[len(first_part)-1] == u'\u00AD'):
|
||||||
new_first_line = (first_part[:len(first_part)-1] + style.hyphenate_character)
|
new_first_line = (
|
||||||
temp_layout = create_layout(new_first_line, style, hinting, None)
|
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_lines = temp_layout.iter_lines()
|
||||||
temp_first_line = next(temp_lines, None)
|
temp_first_line = next(temp_lines, None)
|
||||||
temp_second_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
|
# the hyphen does not fit, break earlier
|
||||||
else:
|
else:
|
||||||
prev_hyphen = first_part.rfind(u'\u00AD', 0, len(first_part)-2)
|
prev_hyphen = first_part.rfind(u'\u00AD',
|
||||||
prev_blank = first_part.rfind(' ', 0, len(first_part)-2)
|
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 > -1) or (prev_blank > -1):
|
||||||
|
|
||||||
if prev_hyphen > prev_blank:
|
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:
|
else:
|
||||||
new_first_line = (first_part[:prev_blank])
|
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_lines = temp_layout.iter_lines()
|
||||||
temp_first_line = next(temp_lines, None)
|
temp_first_line = next(temp_lines, None)
|
||||||
temp_second_line = next(temp_lines, None)
|
temp_second_line = next(temp_lines, None)
|
||||||
|
|
||||||
first_line = temp_first_line
|
first_line = temp_first_line
|
||||||
second_line = temp_second_line
|
second_line = temp_second_line
|
||||||
layout = temp_layout
|
layout = temp_layout
|
||||||
resume_at = len(new_first_line)
|
resume_at = len(new_first_line)
|
||||||
|
|
||||||
|
|
||||||
elif hyphens =='auto' and lang:
|
elif hyphens =='auto' and lang:
|
||||||
dictionary_key = (lang, left, right, total)
|
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:
|
if temp_first_line_width <= max_width:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
# Step 5: Try to break word if it's too long for the line
|
# Step 5: Try to break word if it's too long for the line
|
||||||
overflow_wrap = style.overflow_wrap
|
overflow_wrap = style.overflow_wrap
|
||||||
first_line_width, _height = get_size(first_line)
|
first_line_width, _height = get_size(first_line)
|
||||||
|
Loading…
Reference in New Issue
Block a user