You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There isn't really automatic language detection. For proper typesetting, you need to set both the language and a good font.
We're aware that the out-of-the-box experience is bad, but it's more due to missing features than any of the existing systems working incorrectly. Related: #5040
Note that raw blocks also set the language to English by default because code is often in English. To override this, you need to write
@laurmaedje Thanks for the reply, but I have to disagree on a few points you missed.
First, calling this an "out-of-box experience issue" doesn't really hold up. The font style behavior is clearly undefined and needs proper definition. Plus, we could label any bug or feature request as an "out-of-box experience issue" - if an explanation works for everything, it's probably not explaining anything.
You also missed a key point: cjk-latin-spacing shouldn't be getting into Raw blocks at all. Your own example with #show raw: set text(lang: "zh") shows that Raw blocks are supposed to ignore normal font/language settings. This just proves my point - the whole question of what styles affect Raw blocks is completely undefined and messy right now.
The spacing issue is critical because CJK characters are not only used in comments in the code.
while (true) // 典型的Textbook式死循环
In this situation, the spacing around Textbook is okey.
printf("这是%d段代码", 1)
In this case, if we add a space between %d and 段代码 in the compiled result, it will be confusing, because we can't judge whether it is a simple white space.
The font style behavior is clearly undefined and needs proper definition.
Well, yes, but only because no suitable font is defined, so it's triggering fallback all over the place, which is fundamentally a bit unpredictable. I'm not saying the fallback behaviour can't be improved, but the main issue is that language and font aren't set -- and that's something that should work better out of the box.
You also missed a key point: cjk-latin-spacing shouldn't be getting into Raw blocks at all.
Yeah, that's an actual bug. I didn't comment on that specifically, but I did notice it. I think that deserves its own issue though (I'd be happy for you to open it). A very broad issue like this one here is not super actionable.
The fallback stuff, in my opinion, falls into #5040. (I have reworded the title of the issue since it is not web-app specific).
That covers the first two points in your list of errors. The third point I'm not sure about since there isn't an automatic language detection algorithm in the first place.
Activity
laurmaedje commentedon Jan 24, 2025
There isn't really automatic language detection. For proper typesetting, you need to set both the language and a good font.
We're aware that the out-of-the-box experience is bad, but it's more due to missing features than any of the existing systems working incorrectly. Related: #5040
Note that raw blocks also set the language to English by default because code is often in English. To override this, you need to write
hongjr03 commentedon Jan 24, 2025
There is a solution in FAQ of typst-doc-cn's guide, have a check on it! 🎉
earmer commentedon Jan 24, 2025
Thank you. But, I'm still eager to know why it does the font style like this.
By the way, the search function of the official document is...not good.
earmer commentedon Jan 24, 2025
@laurmaedje Thanks for the reply, but I have to disagree on a few points you missed.
First, calling this an "out-of-box experience issue" doesn't really hold up. The font style behavior is clearly undefined and needs proper definition. Plus, we could label any bug or feature request as an "out-of-box experience issue" - if an explanation works for everything, it's probably not explaining anything.
You also missed a key point:
cjk-latin-spacingshouldn't be getting into Raw blocks at all. Your own example with#show raw: set text(lang: "zh")shows that Raw blocks are supposed to ignore normal font/language settings. This just proves my point - the whole question of what styles affect Raw blocks is completely undefined and messy right now.The spacing issue is critical because CJK characters are not only used in comments in the code.
In this situation, the spacing around
Textbookis okey.In this case, if we add a space between
%dand段代码in the compiled result, it will be confusing, because we can't judge whether it is a simple white space.laurmaedje commentedon Jan 25, 2025
Well, yes, but only because no suitable font is defined, so it's triggering fallback all over the place, which is fundamentally a bit unpredictable. I'm not saying the fallback behaviour can't be improved, but the main issue is that language and font aren't set -- and that's something that should work better out of the box.
Yeah, that's an actual bug. I didn't comment on that specifically, but I did notice it. I think that deserves its own issue though (I'd be happy for you to open it). A very broad issue like this one here is not super actionable.
The fallback stuff, in my opinion, falls into #5040. (I have reworded the title of the issue since it is not web-app specific).
That covers the first two points in your list of errors. The third point I'm not sure about since there isn't an automatic language detection algorithm in the first place.
earmer commentedon Jan 26, 2025
Yes, and I think I can close this issue and open a new one. Thank you again. @laurmaedje
earmer commentedon Jan 26, 2025
Well, and the most proper solution is like:
Use "Menlo" for mono font, and use "PingFang SC" for a fallback font for CJK.
@hongjr03
hongjr03 commentedon Jan 26, 2025
i agree 🎉