Skip to content
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

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Move the TATTR_EXPAND check down into write_ucschar
Import the suggested changes.

Co-authored-by: Thomas Wolff <[email protected]>
  • Loading branch information
k-takata and mintty committed Jun 21, 2024
commit 4129d4e3a6702780481a703a7ddf52e579f5c548
27 changes: 12 additions & 15 deletions src/termout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 1248,18 @@ write_ucschar(wchar hwc, wchar wc, int width)
if (cf && cf <= 10 && !(attr & FONTFAM_MASK))
term.curs.attr.attr = attr | ((cattrflags)cf << ATTR_FONTFAM_SHIFT);

// Auto-expanded glyphs
if (width == 2
// && wcschr(W("〈〉《》「」『』【】〔〕〖〗〘〙〚〛"), wc)
&& wc >= 0x3008 && wc <= 0x301B
&& (wc | 1) != 0x3013 // exclude 〒〓 from the range
&& win_char_width(wc, term.curs.attr.attr) < 2
// ensure symmetric handling of matching brackets
&& win_char_width(wc ^ 1, term.curs.attr.attr) < 2)
{
term.curs.attr.attr |= TATTR_EXPAND;
}

if (hwc) {
if (width == 1
&& (cfg.charwidth == 10 || cs_single_forced)
Expand Down Expand Up @@ -4987,10 4999,6 @@ term_do_write(const char *buf, uint len, bool fix_status)

cattrflags asav = term.curs.attr.attr;

uchar cf = scriptfont(wc);
if (cf && cf <= 10 && !(asav & FONTFAM_MASK))
term.curs.attr.attr = asav | ((cattrflags)cf << ATTR_FONTFAM_SHIFT);

switch (cset) {
when CSET_VT52DRW: // VT52 "graphics" mode
if (0x5E <= wc && wc <= 0x7E) {
Expand Down Expand Up @@ -5223,17 5231,6 @@ term_do_write(const char *buf, uint len, bool fix_status)
width = 1;
}

// Auto-expanded glyphs
if (width == 2
// && wcschr(W("〈〉《》「」『』【】〒〓〔〕〖〗〘〙〚〛"), wc)
&& wc >= 0x3008 && wc <= 0x301B && (wc | 1) != 0x3013
&& win_char_width(wc, term.curs.attr.attr) < 2
// ensure symmetric handling of matching brackets
&& win_char_width(wc ^ 1, term.curs.attr.attr) < 2)
{
term.curs.attr.attr |= TATTR_EXPAND;
}

// Control characters
if (wc < 0x20 || wc == 0x7F) {
if (!do_ctrl(wc) && c == wc) {
Expand Down