Skip to content

Commit

Permalink
Merge pull request #2329 from kesara/refactor/layout-preferred
Browse files Browse the repository at this point in the history
Refactor text.line_break.get_log_attrs()
  • Loading branch information
liZe authored Dec 16, 2024
2 parents 45d3c93 + 246bc3e commit 2ada586
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions weasyprint/text/line_break.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,13 @@ def get_log_attrs(text, lang):
log_attrs = ffi.new('PangoLogAttr[]', length)
pango.pango_get_log_attrs(
text_p, len(bytestring), -1, language, log_attrs, length)
return bytestring, log_attrs
return log_attrs


def next_break_point(text, lang):
if not text or len(text) < 2:
return None
bytestring, log_attrs = get_log_attrs(text, lang)
log_attrs = get_log_attrs(text, lang)
length = len(text) + 1
for i, attr in enumerate(log_attrs[1:length - 1]):
if attr.is_line_break:
Expand All @@ -516,7 +516,7 @@ def can_break_text(text, lang):
def get_next_word_boundaries(text, lang):
if not text or len(text) < 2:
return None
bytestring, log_attrs = get_log_attrs(text, lang)
log_attrs = get_log_attrs(text, lang)
for i, attr in enumerate(log_attrs):
if attr.is_word_end:
word_end = i
Expand All @@ -531,7 +531,7 @@ def get_next_word_boundaries(text, lang):
def get_last_word_end(text, lang):
if not text or len(text) < 2:
return None
bytestring, log_attrs = get_log_attrs(text, lang)
log_attrs = get_log_attrs(text, lang)
for i, attr in enumerate(list(log_attrs)[::-1]):
if i and attr.is_word_end:
return len(text) - i

0 comments on commit 2ada586

Please sign in to comment.