-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
TexText
Bug: Some Chinese characters get hollowed
#2146
Comments
English
So I tried changing the order of different closed path in the SVG file (in the attribute TestScene.mp4中文
所以我调换了一下 SVG 里的绘制顺序( 视频见上文 |
TexText
Bug: Some Chinese characters get hollowed
EnglishSeems that the problem is caused by SVG Here's an example: <!--a.svg-->
<?xml version='1.0' encoding='UTF-8'?>
<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='16pt' height='16pt' viewBox='-4 -4 12 12'>
<defs>
<path id='test' d='M 0 0 L 0 7 L 7 7 L 7 0 L 0 0 Z M 1 1 L 6 1 L 6 6 L 1 6 L 1 1 Z M 2 2 L 5 2 L 5 5 L 2 5 L 2 2 Z M 3 3 L 3 4 L 4 4 L 4 3 L 3 3 Z'/>
</defs>
<g>
<use x='0' y='0' xlink:href='#test'/>
</g>
</svg> # scene.py
from manimlib import *
class TestScene(Scene):
def construct(self):
self.play(ShowCreation(SVGMobject("a.svg", color="white"), run_time=10)) I created 4 squares in This is what P.S. Interestingly, 中文这个问题应该是 SVG 的 例: <!--a.svg-->
<?xml version='1.0' encoding='UTF-8'?>
<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='16pt' height='16pt' viewBox='-4 -4 12 12'>
<defs>
<path id='test' d='M 0 0 L 0 7 L 7 7 L 7 0 L 0 0 Z M 1 1 L 6 1 L 6 6 L 1 6 L 1 1 Z M 2 2 L 5 2 L 5 5 L 2 5 L 2 2 Z M 3 3 L 3 4 L 4 4 L 4 3 L 3 3 Z'/>
</defs>
<g>
<use x='0' y='0' xlink:href='#test'/>
</g>
</svg> # scene.py
from manimlib import *
class TestScene(Scene):
def construct(self):
self.play(ShowCreation(SVGMobject("a.svg", color="white"), run_time=10))
Chrome 中显示效果是这样的: 注:只改变绕行方向也会影响 |
Thanks for the detailed explanation and example. This will be tricky to fix fully on the rendering side without compromising some other features, but I can look into it. In the meantime, one potential strategy would be to edit how SVGMobject reads in SVGs such that it re-orients internal curves whenever there's this discrepancy. |
I think the most recent commit should address this. At the very least, the example you gave including the holes within holes renders properly now. Let me know if the Chinese text you mentioned renders better. It's not perfect, I could find edge cases where mixed winding signs and partial opacity behave strangely together, but hopefully, that's a pathological enough case that it won't be as painful a bug. |
Switching to the latest version has improved the overall situation significantly compared to before, but it is still not perfect. The specifics are as follows: The test code is as follows: from manimlib import *
class TestScene(Scene):
def construct(self):
preamble = r"""
\usepackage{xeCJK}
\renewcommand{\songti}{\CJKfontspec{LXGW WenKai Mono}}
\renewcommand{\heiti}{\CJKfontspec{Microsoft YaHei}}
\newcommand{\shs}{\CJKfontspec{Source Han Sans SC}}
"""
## 微软雅黑: 粗,当,衫,显
## 霞鹜文楷: 侧,厕,测,答,钉,动,费,公,谷,浩,浑,简,洁,禁,坑,礼,虑,骡,票,洽,签,潜,衫,抬,踢,修,沿,言,冶,浴,钥,治,武
## 思源黑体: 蹲,给,论,诱,帐,紫
txt = r"""
Microsoft YaHei: \heiti 粗当衫显
LXGW WenKai Mono: \songti 侧厕测答钉动费公谷浩浑简洁禁坑礼虑骡票洽签潜衫抬踢修沿言冶浴钥治武
Source Han Sans SC: \shs 蹲给论诱帐紫
"""
self.add(TexText(txt, template="ctex", additional_preamble=preamble, font_size=36).to_edge(UP))
self.wait() TestScene.mp4 |
Ah, I see. It seems like this negative winding number situation now interferes poorly with the border width. If you call text.set_fill(border_width=0), you'll notice the issue goes away. I'll think of a better way to have this addressed by default. |
English
Describe the bug
Some of the Chinese characters in
TexText
get hollowed, even when usingSVGMoject
with compiled SVG files (nothing wrong with SVG files). I thought it was a rendering bug of ManimGL.Code:
Wrong display or Error traceback:
Additional context
Someone else (@起床王王王 in Manim Kindergarten's QQ group) found the same problem in Feb this year. He solved by changing typeface, but other characters can also get a display error in other typefaces on my computer. This seemed to have different effects on different computers. E.g. “边” and “代” got hollowed on @起床王王王's computer, but it worked well for me. And I got hollowed “始” and “终” in Song typeface, deformed “奇” in Kai typeface.
The picture shows @起床王王王's result.
中文
描述
TexText
中有些汉字显示为空心,哪怕把相应的 SVG 放到SVGMobject
里去也是同样效果,但编译出的 SVG 没有任何异常,我觉得应该是 ManimGL 渲染的问题。图片和源码见上文
附加信息
今年 2 月的时候 mk 群里面也有人(群昵称 @起床王王王)发现了同样问题,他当时是用更换字体的方式解决的,但我这里更换了字体就会有其他汉字显示异常。这个问题貌似在不同电脑上表现不同,在 @起床王王王 的电脑上“边”“代”有问题,但在我的电脑上显示正常,在我的电脑上用宋体会导致“始”“终”空心,用楷体会导致“奇”字形扭曲。
图(见上文)为 @起床王王王 的显示效果。
The text was updated successfully, but these errors were encountered: