diff --git a/web/app.py b/web/app.py
index 4895889..f72b145 100644
--- a/web/app.py
+++ b/web/app.py
@@ -300,12 +300,12 @@ def _markup_unit_svg(unit: str, fd: _FontData, fill='#1a1a1a') -> str:
def _text_to_paths(text, x, y, font_size, fd: _FontData, anchor='start', fill='#1a1a1a', wrap_transform=None):
s = font_size / fd.upm
- if anchor == 'middle':
+ if anchor in ('middle', 'end'):
total_w = sum(
fd.hmtx.get(fd.cmap.get(ord(ch)), (0, 0))[0] * s
for ch in text if fd.cmap.get(ord(ch))
)
- x -= total_w / 2
+ x -= total_w / 2 if anchor == 'middle' else total_w
parts = []
cx = x
@@ -506,6 +506,34 @@ def generate_svg(unit, min_val, max_val, left_label, right_label, big_ticks, sma
)
parts.append(' ' + _markup_unit_svg(unit, fd))
+
+ left_lines = left_label.split('\n')[:2]
+ right_lines = right_label.split('\n')[:2]
+
+ for i, line in enumerate(left_lines):
+ if not line:
+ continue
+ y = LEFT_Y0 + i * CORNER_LINE_SPACING
+ if use_paths:
+ parts.append(' ' + _text_to_paths(line, LEFT_X, y, CORNER_FONT_SIZE, fd, anchor='start'))
+ else:
+ parts.append(
+ f' {escape(line)}'
+ )
+
+ for i, line in enumerate(right_lines):
+ if not line:
+ continue
+ y = RIGHT_Y0 + i * CORNER_LINE_SPACING
+ if use_paths:
+ parts.append(' ' + _text_to_paths(line, RIGHT_X, y, CORNER_FONT_SIZE, fd, anchor='end'))
+ else:
+ parts.append(
+ f' {escape(line)}'
+ )
+
parts += [' ', '']
return '\n'.join(parts)