diff --git a/rich/__main__.py b/rich/__main__.py index 7b3ffb4f2b..3c26a9c2c6 100644 --- a/rich/__main__.py +++ b/rich/__main__.py @@ -226,7 +226,9 @@ def iter_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]: console.print(test_card) taken = round((process_time() - start) * 1000.0, 1) - Console().print(test_card) + c = Console(record=True) + c.print(test_card) + print(c.export_svg("Rich can export to SVG!")) print(f"rendered in {pre_cache_taken}ms (cold cache)") print(f"rendered in {taken}ms (warm cache)") diff --git a/rich/console.py b/rich/console.py index fbfe542f32..c3474b5a40 100644 --- a/rich/console.py +++ b/rich/console.py @@ -119,6 +119,22 @@ class NoChange: {text}' + # If the style doesn't contain a color, we still # need to make sure we output the default foreground color # from the TerminalTheme. @@ -2364,7 +2391,7 @@ def export_svg( # Monospace fonts are generally around 0.5-0.55 width/height ratio, but I've # added extra width to ensure that the output SVG is big enough. - monospace_font_width_scale = 0.6 + monospace_font_width_scale = 0.57 # This works out as a good heuristic for the final size of the drawn terminal. terminal_height = required_code_height + code_start_y