Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
49.51k stars 1.73k forks source link

[BUG] SVG font rendering too narrow for Asian language #2742

Open shiba2046 opened 1 year ago

shiba2046 commented 1 year ago

First of all I'm a great fan of your work, I love it.

I've encountered the following problem. When rendering a table with Chinese characters, it displays nicely in terminal. However when exporting it to svg, the characters are all stacked together make them unreadable. This is also present in the svg example on the project

Upon inspecting the svg code, I think it's that the textLength property is maybe too small.

Is there a way to overide this and make it wider?

Screenshot 2023-01-11 184913 Screenshot 2023-01-11 184953

github-actions[bot] commented 1 year ago

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

I-love-study commented 1 year ago

Same issue for it and there's minimal reproducibility example

from rich.console import Console

console = Console(record=True)
console.print("中文测试")
console.save_svg("output.svg")

Output: output

In Mono font for example, width of the CJK characters are usually twice as wide as English characters, but in export_svg method, every character are in the same width.

https://github.com/Textualize/rich/blob/44cf059b14a0e6ac7ad91638e892b32d62c6b0fb/rich/console.py#L2342