Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
Add bold text support (pull request #35 by andyone)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbedos committed Jul 6, 2018
1 parent 2a13811 commit f623de9
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 58 deletions.
3 changes: 1 addition & 2 deletions examples/awesome.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions examples/casts/awesome.cast
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"version": 2, "width": 82, "height": 19, "theme": {"fg": "#839496", "bg": "#002b36", "palette": "#073642:#dc322f:#859900:#b58900:#268bd2:#d33682:#2aa198:#eee8d5:#002b36:#cb4b16:#586e75:#657b83:#839496:#6c71c4:#93a1a1:#fdf6e3"}}
[0.0, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[0.0, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[0.390644, "o", "t"]
[0.534149, "o", "e"]
[0.60612, "o", "r"]
Expand All @@ -11,7 +11,7 @@
[1.845896, "o", "g"]
[2.045981, "o", "\r\n"]
[2.31268, "o", "Recording started, enter \"exit\" command or Control-D to end\r\n"]
[2.335253, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[2.335253, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[2.919678, "o", "f"]
[3.057802, "o", "o"]
[3.156814, "o", "r"]
Expand Down Expand Up @@ -84,12 +84,12 @@
[19.312437, "o", "\u001b[39m\u001b[38;5;44mo\u001b[39m"]
[19.314078, "o", "\u001b[38;5;44mm\u001b[39m\u001b[38;5;44me\u001b[39m\u001b[38;5;44m!\u001b[39m\u001b[38;5;44m\u001b[39m\r\n\u001b[38;5;33mt\u001b[39m\u001b[38;5;33me\u001b[39m\u001b[38;5;39mr\u001b[39m\u001b[38;5;39mm\u001b[39m\u001b[38;5;39mt\u001b[39m\u001b[38;5;39mo\u001b[39m\u001b[38;5;39ms\u001b[39m\u001b[38;5;39mv\u001b[39m\u001b[38;5;39mg\u001b[39m\u001b[38;5;39m \u001b[39m\u001b[38;5;39mi\u001b[39m\u001b[38;5;38ms\u001b[39m\u001b[38;5;38m \u001b[39m\u001b[38;5;44ma\u001b[39m\u001b[38;5;44mw\u001b[39m\u001b[38;5;44me\u001b[39m\u001b[38;5;44ms\u001b[39m\u001b[38;5;44mo\u001b[39m\u001b[38;5;44mm\u001b[39m\u001b[38;5;44me\u001b[39m\u001b[38;5;44m!\u001b[39m\u001b[38;5;44m\u001b[39m\r\n\u001b[38;5;39mt\u001b[39m\u001b[38;5;39me\u001b[39m\u001b[38;5;39mr\u001b[39m\u001b[38;5;39mm\u001b[39m\u001b[38;5;39mt\u001b[39m\u001b[38;5;39mo\u001b[39m\u001b[38;5;39ms\u001b[39m\u001b[38;5;39mv\u001b[39m\u001b[38;5;38mg\u001b[39m\u001b[38;5;38m \u001b[39m\u001b[38;5;44mi\u001b[39m\u001b[38;5;44ms\u001b[39m\u001b[38;5;44m \u001b[39m\u001b[38;5;44ma\u001b[39m\u001b[38;5;44mw\u001b[39m\u001b[38;5;44me\u001b[39m\u001b[38;5;44ms\u001b[39m\u001b[38;5;44mo\u001b[39m\u001b[38;5;44mm\u001b[39m\u001b[38;5;44me\u001b[39m\u001b[38;5;43m!\u001b[39m\u001b[38;5;49m\u001b[39m\r\n\u001b[38;5;39mt\u001b[39m\u001b[38;5;39me\u001b[39m\u001b[38;5;39mr\u001b[39m\u001b[38;5;39mm\u001b[39m\u001b[38;5;39mt\u001b[39m\u001b[38;5;38mo\u001b[39m\u001b[38;5;38ms\u001b[39m\u001b[38;5;44mv\u001b[39m\u001b[38;5;44mg\u001b[39m\u001b[38;5;44m \u001b[39m\u001b[38;5;44mi\u001b[39m\u001b[38;5;44ms\u001b[39m\u001b[38;5;44m \u001b[39m\u001b[38;5;44ma\u001b[39m\u001b[38;5;44mw\u001b[39m\u001b[38;5;44me\u001b["]
[19.31967, "o", "39m\u001b[38;5;44ms\u001b[39m\u001b[38;5;43mo\u001b[39m\u001b[38;5;49mm\u001b[39m\u001b[38;5;49me\u001b[39m\u001b[38;5;49m!\u001b[39m\u001b[38;5;49m\u001b[39m\r\n\u001b[38;5;39mt\u001b[39m\u001b[38;5;39me\u001b[39m\u001b[38;5;38mr\u001b[39m\u001b[38;5;38mm\u001b[39m\u001b[38;5;44mt\u001b[39m\u001b[38;5;44mo\u001b[39m\u001b[38;5;44ms\u001b[39m\u001b[38;5;44mv\u001b[39m\u001b[38;5;44mg\u001b[39m\u001b[38;5;44m \u001b[39m\u001b[38;5;44mi\u001b[39m\u001b[38;5;44ms\u001b[39m\u001b[38;5;44m \u001b[39m\u001b[38;5;44ma\u001b[39m\u001b[38;5;43mw\u001b[39m\u001b[38;5;49me\u001b[39m\u001b[38;5;49ms\u001b[39m\u001b[38;5;49mo\u001b[39m\u001b[38;5;49mm\u001b[39m\u001b[38;5;49me\u001b[39m\u001b[38;5;49m!\u001b[39m\u001b[38;5;49m\u001b[39m\r\n\u001b[38;5;38mt\u001b[39m\u001b[38;5;44me\u001b[39m\u001b[38;5;44mr\u001b[39m\u001b[38;5;44mm\u001b[39m\u001b[38;5;44mt\u001b[39m\u001b[38;5;44mo\u001b[39m\u001b[38;5;44ms\u001b[39m\u001b[38;5;44mv\u001b[39m\u001b[38;5;44mg\u001b[39m\u001b[38;5;44m \u001b[39m\u001b[38;5;44mi\u001b[39m\u001b[38;5;43ms\u001b[39m\u001b[38;5;49m \u001b[39m\u001b[38;5;49ma\u001b[39m\u001b[38;5;49mw\u001b[39m\u001b[38;5;49me\u001b[39m\u001b[38;5;49ms\u001b[39m\u001b[38;5;49mo\u001b[39m\u001b[38;5;49mm\u001b[39m\u001b[38;5;49me\u001b[39m\u001b[38;5;49m!\u001b[39m\u001b[38;5;49m\u001b[39m\r\n\u001b[38;5;44mt\u001b[39m\u001b[38;5;44me\u001b[39m\u001b[38;5;44mr\u001b[39m\u001b[38;5;44mm\u001b[39m\u001b[38;5;44mt\u001b[39m\u001b[38;5;44mo\u001b[39m\u001b[38;5;44ms\u001b[39m\u001b[38;5;44mv\u001b[39m\u001b[38;5;43mg\u001b[39m\u001b[38;5;49m \u001b[39m\u001b[38;5;49mi\u001b[39m\u001b[38;5;49ms\u001b[39m\u001b[38;5;49m \u001b[39m\u001b[38;5;49m"]
[19.323298, "o", "a\u001b[39m\u001b[38;5;49mw\u001b[39m\u001b[38;5;49me\u001b[39m\u001b[38;5;49ms\u001b[39m\u001b[38;5;49mo\u001b[39m\u001b[38;5;49mm\u001b[39m\u001b[38;5;48me\u001b[39m\u001b[38;5;48m!\u001b[39m\u001b[38;5;48m\u001b[39m\r\n\u001b[38;5;44mt\u001b[39m\u001b[38;5;44me\u001b[39m\u001b[38;5;44mr\u001b[39m\u001b[38;5;44mm\u001b[39m\u001b[38;5;44mt\u001b[39m\u001b[38;5;43mo\u001b[39m\u001b[38;5;49ms\u001b[39m\u001b[38;5;49mv\u001b[39m\u001b[38;5;49mg\u001b[39m\u001b[38;5;49m \u001b[39m\u001b[38;5;49mi\u001b[39m\u001b[38;5;49ms\u001b[39m\u001b[38;5;49m \u001b[39m\u001b[38;5;49ma\u001b[39m\u001b[38;5;49mw\u001b[39m\u001b[38;5;49me\u001b[39m\u001b[38;5;48ms\u001b[39m\u001b[38;5;48mo\u001b[39m\u001b[38;5;48mm\u001b[39m\u001b[38;5;48me\u001b[39m\u001b[38;5;48m!\u001b[39m\u001b[38;5;48m\u001b[39m\r\n\u001b[m\u001b[?25h\u001b[?1;5;2004l\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[19.323298, "o", "a\u001b[39m\u001b[38;5;49mw\u001b[39m\u001b[38;5;49me\u001b[39m\u001b[38;5;49ms\u001b[39m\u001b[38;5;49mo\u001b[39m\u001b[38;5;49mm\u001b[39m\u001b[38;5;48me\u001b[39m\u001b[38;5;48m!\u001b[39m\u001b[38;5;48m\u001b[39m\r\n\u001b[38;5;44mt\u001b[39m\u001b[38;5;44me\u001b[39m\u001b[38;5;44mr\u001b[39m\u001b[38;5;44mm\u001b[39m\u001b[38;5;44mt\u001b[39m\u001b[38;5;43mo\u001b[39m\u001b[38;5;49ms\u001b[39m\u001b[38;5;49mv\u001b[39m\u001b[38;5;49mg\u001b[39m\u001b[38;5;49m \u001b[39m\u001b[38;5;49mi\u001b[39m\u001b[38;5;49ms\u001b[39m\u001b[38;5;49m \u001b[39m\u001b[38;5;49ma\u001b[39m\u001b[38;5;49mw\u001b[39m\u001b[38;5;49me\u001b[39m\u001b[38;5;48ms\u001b[39m\u001b[38;5;48mo\u001b[39m\u001b[38;5;48mm\u001b[39m\u001b[38;5;48me\u001b[39m\u001b[38;5;48m!\u001b[39m\u001b[38;5;48m\u001b[39m\r\n\u001b[m\u001b[?25h\u001b[?1;5;2004l\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[22.490234, "o", "e"]
[22.737309, "o", "x"]
[22.889771, "o", "i"]
[23.009438, "o", "t"]
[23.761836, "o", "\r\nexit\r\n"]
[23.836601, "o", "Recording ended, SVG animation is /tmp/termtosvg__20rwx67.svg\r\n"]
[23.836602, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[23.836602, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[26.349826, "o", ""]
8 changes: 4 additions & 4 deletions examples/casts/colors.cast
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"version": 2, "width": 82, "height": 19, "theme": {"fg": "#839496", "bg": "#002b36", "palette": "#073642:#dc322f:#859900:#b58900:#268bd2:#d33682:#2aa198:#eee8d5:#002b36:#cb4b16:#586e75:#657b83:#839496:#6c71c4:#93a1a1:#fdf6e3"}}
[0.0, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[0.0, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[1.226717, "o", "~"]
[1.642848, "o", "/"]
[1.786827, "o", "s"]
Expand Down Expand Up @@ -108,7 +108,7 @@
[5.709857, "o", "\u001b[48;5;240m \u001b[0m\u001b[48;5;241m \u001b[0m\u001b[48;5;242m \u001b[0m\u001b[48;5;243m \u001b[0m\u001b[48;5;244m \u001b[0m\u001b[48;5;245m \u001b[0m\u001b[48;5;246m \u001b[0m\u001b[48;5;247m \u001b[0m\u001b[48;5;248m \u001b[0m\u001b[48;5;249m \u001b[0m\u001b[48;5;250m \u001b[0m"]
[5.709923, "o", "\u001b[48;5;251m \u001b[0m\u001b[48;5;252m \u001b[0m\u001b[48;5;253m \u001b[0m\u001b[48;5;254m \u001b[0m\u001b[48;5;255m \u001b[0m"]
[5.709965, "o", "\r\n\r\n"]
[5.710217, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[5.710217, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[7.618975, "o", "~"]
[7.938859, "o", "/"]
[8.066321, "o", "s"]
Expand Down Expand Up @@ -143,7 +143,7 @@
[13.592818, "o", "\u001b[48;2;20;40;234m\u001b[38;2;234;214;20m \u001b[0m\u001b[48;2;16;33;238m\u001b[38;2;238;221;16m \u001b[0m\u001b[48;2;13;26;241m\u001b[38;2;241;228;13m \u001b[0m"]
[13.592858, "o", "\u001b[48;2;10;20;244m\u001b[38;2;244;234;10m \u001b[0m\u001b[48;2;6;13;248m\u001b[38;2;248;241;6m \u001b[0m\u001b[48;2;3;6;251m\u001b[38;2;251;248;3m \u001b[0m\u001b[48;2;0;0;255m\u001b[38;2;255;255;0m \u001b[0m"]
[13.592898, "o", "\r\n"]
[13.593518, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[13.593518, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[15.354717, "o", "t"]
[15.482695, "o", "e"]
[15.546875, "o", "r"]
Expand Down Expand Up @@ -565,7 +565,7 @@
[22.190496, "o", "\u001b[38;5;184ml\u001b[39m\u001b[38;5;184mp\u001b[39m"]
[22.190557, "o", "\u001b[38;5;178m'\u001b[39m\u001b[38;5;214m\u001b[39m\r\n"]
[22.191482, "o", "\u001b[m\u001b[?25h\u001b[?1;5;2004l"]
[22.196526, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[22.196526, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[24.786606, "o", "e"]
[24.986799, "o", "x"]
[25.090796, "o", "i"]
Expand Down
4 changes: 2 additions & 2 deletions examples/casts/htop.cast
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"version": 2, "width": 82, "height": 19, "theme": {"fg": "#839496", "bg": "#002b36", "palette": "#073642:#dc322f:#859900:#b58900:#268bd2:#d33682:#2aa198:#eee8d5:#002b36:#cb4b16:#586e75:#657b83:#839496:#6c71c4:#93a1a1:#fdf6e3"}}
[0.0, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[0.0, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[1.560565, "o", "h"]
[1.640251, "o", "t"]
[1.720707, "o", "o"]
Expand Down Expand Up @@ -60,7 +60,7 @@
[13.464868, "o", "\u001b[4;57H\u001b[0;1m\u000f\u001b[36m1\r\u001b[14d\u001b[39m\u001b[m\u000f27173 nico 20 0 \u001b[36m16\u001b[39m\u001b[m\u000f244 \u001b[36m 4\u001b[39m\u001b[m\u000f080 \u001b[36m 3\u001b[39m\u001b[m\u000f364 S 0.0 0.1 0:00.08 \u001b[36m│ │ └─ \u001b[39m\u001b[m\u000fbash \u001b[15;1H\u001b[30m\u001b[46m29180 nico 20 0 104M 26720 8640 S 0.0 0.3 0:00.28 │ │ └─ pyth\u001b[1;1H\u001b[39;49m\u001b[m\u000f"]
[14.980874, "o", "\u001b[2;10H \u001b[2;34H5.0\u001b[2;53H\u001b[0;1m\u000f\u001b[32m2\u001b[3;8H\u001b[0m\u000f\u001b[31m|\u001b[39m\u001b[m\u000f \u001b[3;34H5.4\u001b[4;8H\u001b[32m||\u001b[31m|\u001b[4;33H\u001b[39m\u001b[m\u000f10.8\u001b[4;57H\u001b[0;1m\u000f\u001b[36m2\u001b[5;8H\u001b[0m\u000f\u001b[32m|\u001b[5;36H\u001b[39m\u001b[m\u000f0\u001b[17;48H8\u001b[17;62H4\u001b[H"]
[15.648421, "o", "\u001b[19d\u001b[J\u001b[34h\u001b[?25h\u001b[?1000l\u001b[19;1H\u001b[?1049l\r\u001b[?1l\u001b>"]
[15.648984, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[15.648984, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[16.664419, "o", "e"]
[16.960091, "o", "x"]
[17.112119, "o", "i"]
Expand Down
4 changes: 2 additions & 2 deletions examples/casts/ipython.cast
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"version": 2, "width": 82, "height": 19, "theme": {"fg": "#839496", "bg": "#002b36", "palette": "#073642:#dc322f:#859900:#b58900:#268bd2:#d33682:#2aa198:#eee8d5:#002b36:#cb4b16:#586e75:#657b83:#839496:#6c71c4:#93a1a1:#fdf6e3"}}
[0.0, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[0.0, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[0.921472, "o", "i"]
[1.073422, "o", "p"]
[1.31298, "o", "y"]
Expand Down Expand Up @@ -158,7 +158,7 @@
[34.020075, "o", "\u001b[?25l\u001b[?7l\u001b[0mt\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"]
[34.196083, "o", "\u001b[?25l\u001b[?7l\u001b[12D\u001b[0m\u001b[J\u001b[0;38;5;28mIn [\u001b[0;38;5;10;1m3\u001b[0;38;5;28m]: \u001b[0mexit\u001b[12D\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"]
[34.196286, "o", "\u001b[?2004l"]
[34.282302, "o", "\u001b[1;31mnico \u001b[0;34m~\u001b[1;31m $ \u001b[0m"]
[34.282302, "o", "\u001b[0;31mnico \u001b[0;34m~\u001b[0;31m $ \u001b[0m"]
[34.673114, "o", "e"]
[34.753043, "o", "x"]
[34.960957, "o", "i"]
Expand Down
4 changes: 2 additions & 2 deletions examples/casts/unittest.cast
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"version": 2, "width": 82, "height": 19, "theme": {"fg": "#839496", "bg": "#002b36", "palette": "#073642:#dc322f:#859900:#b58900:#268bd2:#d33682:#2aa198:#eee8d5:#002b36:#cb4b16:#586e75:#657b83:#839496:#6c71c4:#93a1a1:#fdf6e3"}}
[0.0, "o", "\u001b[1;31mnico \u001b[0;34m~/termtosvg\u001b[1;31m $ \u001b[0m"]
[0.0, "o", "\u001b[0;31mnico \u001b[0;34m~/termtosvg\u001b[0;31m $ \u001b[0m"]
[0.891279, "o", "m"]
[1.003135, "o", "a"]
[1.115415, "o", "k"]
Expand Down Expand Up @@ -105,7 +105,7 @@
[11.542392, "o", "ok\r\n"]
[11.542649, "o", "\r\n----------------------------------------------------------------------\r\nRan 18 tests in 5.164s\r\n\r\nOK\r\n"]
[11.767437, "o", "Name Stmts Miss Branch BrPart Cover\r\n----------------------------------------------------------\r\ntermtosvg/__init__.py 0 0 0 0 100%\r\ntermtosvg/__main__.py 106 4 38 4 94%\r\ntermtosvg/anim.py 146 3 60 3 97%\r\ntermtosvg/asciicast.py 93 6 38 3 93%\r\ntermtosvg/term.py 192 13 66 8 91%\r\n----------------------------------------------------------\r\nTOTAL 537 26 202 18 94%\r\n"]
[11.981343, "o", "\u001b[1;31mnico \u001b[0;34m~/termtosvg\u001b[1;31m $ \u001b[0m"]
[11.981343, "o", "\u001b[0;31mnico \u001b[0;34m~/termtosvg\u001b[0;31m $ \u001b[0m"]
[15.49189, "o", "e"]
[15.68319, "o", "x"]
[15.842958, "o", "i"]
Expand Down
3 changes: 1 addition & 2 deletions examples/colors.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions examples/htop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions examples/ipython.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions examples/unittest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions termtosvg/anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

_CharacterCell = namedtuple('_CharacterCell', ['text', 'color', 'background_color'])
_CharacterCell = namedtuple('_CharacterCell', ['text', 'color', 'background_color', 'bold'])
_CharacterCell.__doc__ = 'Representation of a character cell'
_CharacterCell.text.__doc__ = 'Text content of the cell'
_CharacterCell.bold.__doc__ = 'Bold modificator flag'
_CharacterCell.color.__doc__ = 'Color of the text'
_CharacterCell.background_color.__doc__ = 'Background color of the cell'

Expand Down Expand Up @@ -80,7 +81,7 @@ def from_pyte(cls, char, palette):
if char.reverse:
text_color, background_color = background_color, text_color

return CharacterCell(char.data, text_color, background_color)
return CharacterCell(char.data, text_color, background_color, char.bold)


CharacterCellConfig = namedtuple('CharacterCellConfig', ['width', 'height', 'text_color',
Expand Down Expand Up @@ -139,6 +140,8 @@ def make_text(group: List[int]) -> svgwrite.text.Text:
'lengthAdjust': 'spacingAndGlyphs',
'fill': screen_line[group[0]].color
}
if screen_line[group[0]].bold:
attributes['font-weight'] = 'bold'
return svgwrite.text.Text(**attributes)

group = []
Expand Down Expand Up @@ -176,9 +179,6 @@ def render_animation(records, filename, font, font_size=14, cell_width=8, cell_h
'text': {
'dominant-baseline': 'text-before-edge',
},
'.bold': {
'font-weight': 'bold',
},
'.background': {
'fill': header.background_color,
},
Expand Down
58 changes: 29 additions & 29 deletions tests/test_anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def test_from_pyte(self):
]

char_cells = [
anim.CharacterCell('A', 'color1', 'color4'),
anim.CharacterCell('B', 'color4', 'color1'),
anim.CharacterCell('C', 'color9', 'color4'),
anim.CharacterCell('D', 'color4', 'color9'),
anim.CharacterCell('E', 'color12', 'color4'),
anim.CharacterCell('F', 'foreground', 'background'),
anim.CharacterCell('G', '#008700', '#ABCDEF'),
anim.CharacterCell('H', 'color10', '#ABCDEF'),
anim.CharacterCell('I', 'color3', '#ABCDEF'),
anim.CharacterCell('A', 'color1', 'color4', False),
anim.CharacterCell('B', 'color4', 'color1', False),
anim.CharacterCell('C', 'color9', 'color4', True),
anim.CharacterCell('D', 'color4', 'color9', True),
anim.CharacterCell('E', 'color12', 'color4', True),
anim.CharacterCell('F', 'foreground', 'background', False),
anim.CharacterCell('G', '#008700', '#ABCDEF', False),
anim.CharacterCell('H', 'color10', '#ABCDEF', True),
anim.CharacterCell('I', 'color3', '#ABCDEF', True),
]

palette = {
Expand All @@ -60,16 +60,16 @@ def test_from_pyte(self):
def test__render_line_bg_colors(self):
cell_width = 8
screen_line = {
0: anim.CharacterCell('A', 'black', 'red'),
1: anim.CharacterCell('A', 'black', 'red'),
3: anim.CharacterCell('A', 'black', 'red'),
4: anim.CharacterCell('A', 'black', 'blue'),
6: anim.CharacterCell('A', 'black', 'blue'),
7: anim.CharacterCell('A', 'black', 'blue'),
8: anim.CharacterCell('A', 'black', 'green'),
9: anim.CharacterCell('A', 'black', 'red'),
10: anim.CharacterCell('A', 'black', 'red'),
99: anim.CharacterCell('A', 'black', 'black'),
0: anim.CharacterCell('A', 'black', 'red', False),
1: anim.CharacterCell('A', 'black', 'red', False),
3: anim.CharacterCell('A', 'black', 'red', False),
4: anim.CharacterCell('A', 'black', 'blue', False),
6: anim.CharacterCell('A', 'black', 'blue', False),
7: anim.CharacterCell('A', 'black', 'blue', False),
8: anim.CharacterCell('A', 'black', 'green', False),
9: anim.CharacterCell('A', 'black', 'red', False),
10: anim.CharacterCell('A', 'black', 'red', False),
99: anim.CharacterCell('A', 'black', 'black', False),
}

rectangles = anim._render_line_bg_colors(screen_line=screen_line,
Expand All @@ -95,15 +95,15 @@ def test__render_line_bg_colors(self):

def test__render_characters(self):
screen_line = {
0: anim.CharacterCell('A', 'red', 'white'),
1: anim.CharacterCell('B', 'blue', 'white'),
2: anim.CharacterCell('C', 'blue', 'white'),
7: anim.CharacterCell('D', 'green', 'white'),
8: anim.CharacterCell('E', 'green', 'white'),
9: anim.CharacterCell('F', 'green', 'white'),
10: anim.CharacterCell('G', 'green', 'white'),
11: anim.CharacterCell('H', 'red', 'white'),
20: anim.CharacterCell(' ', 'black', 'black')
0: anim.CharacterCell('A', 'red', 'white', False),
1: anim.CharacterCell('B', 'blue', 'white', False),
2: anim.CharacterCell('C', 'blue', 'white', False),
7: anim.CharacterCell('D', 'green', 'white', False),
8: anim.CharacterCell('E', 'green', 'white', False),
9: anim.CharacterCell('F', 'green', 'white', False),
10: anim.CharacterCell('G', 'green', 'white', False),
11: anim.CharacterCell('H', 'red', 'white', False),
20: anim.CharacterCell(' ', 'black', 'black', False)
}

with self.subTest(case='Content'):
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_serialize_css_dict(self):

def test_render_animation(self):
def line(i):
chars = [anim.CharacterCell(c, '#123456', '#789012') for c in 'line{}'.format(i)]
chars = [anim.CharacterCell(c, '#123456', '#789012', False) for c in 'line{}'.format(i)]
return dict(enumerate(chars))

records = [
Expand Down

0 comments on commit f623de9

Please sign in to comment.