-
Notifications
You must be signed in to change notification settings - Fork 185
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
Some CJK characters don't follow the FontChoice option #1271
Conversation
src/termout.c
Outdated
uchar cf = scriptfont(wc); | ||
if (cf && cf <= 10 && !(asav & FONTFAM_MASK)) | ||
term.curs.attr.attr = asav | ((cattrflags)cf << ATTR_FONTFAM_SHIFT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(If not sure if this is the best place to set FONTFAM, though.)
BTW, should this commented line Line 5224 in 78c7d20
be as follows (to make it consistent with line 5225)? // && wcschr(W("〈〉《》「」『』【】〔〕〖〗〘〙〚〛"), wc) The characters "〒" and "〓" are not a pair. |
Thanks for the analysis. Before I try to understand it, let's set up a common test case: I could not reproduce this with a Windows preinstalled CJK font - which of them are actually Japanese? |
It can be also reproduced with "MS Gothic".
Yes, it is the same in my side. Because the left half of the "「" glyph is blank. The blank part is expanded and shown as a double-width blank.
Yes, it is the expected behavior. |
scriptfont is called again in write_ucschar so it appears to be a bit redundant (although it does not impose measurable slowdown). |
The characters listed here (e.g. "「" (U 300C)) don't follow the FontChoice option: https://github.com/mintty/mintty/blob/78c7d205d586ed87c946b00dc62034ea54c96e7b/src/termout.c#L5224-L5225 Consider the following settings: ``` Font=Anonymous Pro # ASCII font FontChoice=CJK:1 Font1=IPAGothic # Japanese font ``` U 300C is a double width character so `win_char_width()` should return 2 here: https://github.com/mintty/mintty/blob/78c7d205d586ed87c946b00dc62034ea54c96e7b/src/termout.c#L5222-L5231 However, FONTFAM is not set to `term.curs.attr.attr` at this point, then `win_char_width()` returns 1 and the `TATTR_EXPAND` flag is unintentionally set. As the result, U 300C is not shown correctly. (The left half of the glyph of U 300C is expanded.) FONTFAM should be set before calling `win_char_width()`.
as attached: Feel free to convert your PR accordingly. |
Import the suggested changes. Co-authored-by: Thomas Wolff <[email protected]>
cc3e3f8
to
4129d4e
Compare
Thank you. I've confirmed that your patch works fine. |
code fixed in previous two commits
Released 3.7.2. |
The characters listed here (e.g. "「" (U 300C)) don't follow the FontChoice option:
mintty/src/termout.c
Lines 5224 to 5225 in 78c7d20
Consider the following settings:
U 300C is a double width CJK character so
win_char_width()
should return 2 here:mintty/src/termout.c
Lines 5222 to 5231 in 78c7d20
However, FONTFAM is not set to
term.curs.attr.attr
at this point, thenwin_char_width()
returns 1 and theTATTR_EXPAND
flag is unintentionally set. As the result, U 300C is not shown correctly. (The left half of the glyph of U 300C is expanded.)FONTFAM should be set before calling
win_char_width()
.