Skip to content

Commit

Permalink
fix: Avoid newlines between 2 tspan elements (#114)
Browse files Browse the repository at this point in the history
This whitespace messes up word alignment when placed in between 2 tspan
elements. This causes misalignment when rendering more than 2 lines of
tap text.
  • Loading branch information
wouterj authored Oct 8, 2024
1 parent 3995b00 commit 9190216
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions keymap_drawer/draw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def _draw_textblock(self, p: Point, words: Sequence[str], classes: Sequence[str]
scaling = self._get_scaling(max(len(w) for w in words))
self.out.write(f'<tspan x="{round(p.x)}" dy="-{dy_0}em"{scaling}>{escape(words[0])}</tspan>')
for word in words[1:]:
self.out.write(f'<tspan x="{round(p.x)}" dy="{self.cfg.line_spacing}em"{scaling}>{escape(word)}</tspan>\n')
self.out.write("</text>\n")
self.out.write(f'<tspan x="{round(p.x)}" dy="{self.cfg.line_spacing}em"{scaling}>{escape(word)}</tspan>')
self.out.write("\n</text>\n")

def _draw_glyph(self, p: Point, name: str, legend_type: LegendType, classes: Sequence[str]) -> None:
width, height, d_y = self.get_glyph_dimensions(name, legend_type)
Expand Down

0 comments on commit 9190216

Please sign in to comment.