New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REQUEST] Add support for more characters for SVG formatting #2526
Comments
1. Export directlyfrom rich.console import Console
from rich.table import Table
table = Table(title="测试")
table.add_column("Title 测试")
table.add_column("Title 2 测试")
table.add_row("测试","test")
table.add_row("test","测试")
console = Console(record=True)
console.print(table)
console.save_svg('output.svg') 2. Export with specifying font in CONSOLE_SVG_FORMATHere I use Sarasa Mono SC which supports the Chinese characters ...
console.save_svg('output.svg',code_format=CONSOLE_SVG_FORMAT)
... 3. Export with specifying font in CONSOLE_SVG_FORMAT and change the char_width from 0.61 to 0.5 |
Yes, we would like to support CJK at all times. Will look in to that. |
Did I solve your problem? Why not buy the devs a coffee to say thanks? |
Hey @onlyacat, I've added a |
help me a lot, thanks! |
Current status
For now, Rich uses the the Fora Code as the font for exporting and saving the SVG.
Currently, this font does not support some kind of characters like Chinese or Japanese, which causes tofu blocks after exporting. The issue can be referred to here: tonsky/FiraCode#620
A workaround is to specify the font that supports the Chinese in the CONSOLE_SVG_FORMAT.
However, another problem comes. Every character's width in FiraCode is 0.6, thus the tables or other formatting in the SVGs are in a mess. Because most of the fonts have width of 0.5.
Therefore, a solution is changing the hardcode width from 0.61 to 0.5.
rich/rich/console.py
Lines 2309 to 2311 in eaba862
How would you improve Rich?
we could change the font in the parameter but it would be hard to change the variable inside the lib. Will it be possible to help export the variable, or find other methods to solve it? Thanks in advance.
The text was updated successfully, but these errors were encountered: