Improve rendering of wavy underline at small font sizes

See #853
This commit is contained in:
Kovid Goyal 2018-09-03 10:15:53 +05:30
parent f8395e36a1
commit b0a2dea747
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 3 deletions

View File

@ -14,6 +14,8 @@ Changelog
- Draw underlines under the text instead of over it - Draw underlines under the text instead of over it
- Improve rendering of wavy underline at small font sizes (:iss:`853`)
0.12.0 [2018-09-01] 0.12.0 [2018-09-01]
------------------------------ ------------------------------

View File

@ -116,7 +116,9 @@ def add_dline(buf, cell_width, position, thickness, cell_height):
def add_curl(buf, cell_width, position, thickness, cell_height): def add_curl(buf, cell_width, position, thickness, cell_height):
xfactor = 2.0 * pi / cell_width xfactor = 2.0 * pi / cell_width
yfactor = thickness yfactor = max(thickness, 2)
if position + yfactor >= cell_height:
position = cell_height - yfactor - 1
def clamp_y(y): def clamp_y(y):
return max(0, min(int(y), cell_height - 1)) return max(0, min(int(y), cell_height - 1))
@ -125,8 +127,9 @@ def add_curl(buf, cell_width, position, thickness, cell_height):
return max(0, min(int(x), cell_width - 1)) return max(0, min(int(x), cell_width - 1))
def add_intensity(x, y, distance): def add_intensity(x, y, distance):
buf[cell_width * y + x] = min( idx = cell_width * y + x
255, buf[cell_width * y + x] + int(255 * (1 - distance)) buf[idx] = min(
255, buf[idx] + int(255 * (1 - distance))
) )
for x_exact in range(cell_width): for x_exact in range(cell_width):