Skip to content

Commit

Permalink
Merge pull request #1970 from gauravsamudra/handle-y-offset-of-glyphs
Browse files Browse the repository at this point in the history
Handle y offset of glyphs
  • Loading branch information
liZe authored Sep 25, 2023
2 parents a8ff8a6 + d51e211 commit 9596307
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ requires-python = '>=3.7'
readme = {file = 'README.rst', content-type = 'text/x-rst'}
license = {file = 'LICENSE'}
dependencies = [
'pydyf >=0.6.0',
'pydyf >=0.8.0',
'cffi >=0.6',
'html5lib >=1.1',
'tinycss2 >=1.0.0',
Expand Down
22 changes: 19 additions & 3 deletions weasyprint/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,9 +1179,25 @@ def draw_first_line(stream, textbox, text_overflow, block_ellipsis, matrix):
utf8_position = utf8_positions[i]

offset = glyph_info.geometry.x_offset / font_size
if offset:
string += f'>{-offset}<'
string += f'{glyph:02x}' if font.bitmap else f'{glyph:04x}'
rise = glyph_info.geometry.y_offset / 1000
if rise:
if string[-1] == '<':
string = string[:-1]
else:
string += '>'
stream.show_text(string)
stream.set_text_rise(-rise)
string = ''
if offset:
string = f'{-offset}'
string += f'<{glyph:02x}>' if font.bitmap else f'<{glyph:04x}>'
stream.show_text(string)
stream.set_text_rise(0)
string = '<'
else:
if offset:
string += f'>{-offset}<'
string += f'{glyph:02x}' if font.bitmap else f'{glyph:04x}'

# Ink bounding box and logical widths in font
if glyph not in font.widths:
Expand Down

0 comments on commit 9596307

Please sign in to comment.