Skip to content

Commit

Permalink
描画時サロゲートペアの文字が含まれるとき描画が崩れることがあったので修正 #386
Browse files Browse the repository at this point in the history
- 発生条件
  - 描画幅に合わせてリサイズしたフォントを描画=on
  - 描画文字にUTF-16(wchar_t)にしたときサロゲートペアの文字が含まれるとき
- サロゲートペア範囲 U+010000...U+10FFFF
  • Loading branch information
zmatsuo committed Oct 30, 2024
1 parent aa7d0dc commit bd1a824
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/en/html/about/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ <h3 id="teraterm_5.4">YYYY.MM.DD (Ver 5.4 not released yet)</h3>
<li>Unnecessary overwrite confirmation dialog is no longer displayed when selecting a existing file as a log file at file selecting dialog box.</li>
<li>MACRO: Fixed TTL cannot be execute when it is UTF-8 without BOM.</li>
<li>Fixed to handle U+20000 to U+3FFFF of UTF-8.</li>
<li>Fixed display characters containing surrogate pair character when "<a href="../menu/setup-additional-font.html#ResizedFont">Drawing resized font to fit cell width</a>"
</ul>
</li>

Expand Down
1 change: 1 addition & 0 deletions doc/ja/html/about/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ <h3 id="teraterm_5.4">YYYY.MM.DD (Ver 5.4 not released yet)</h3>
<li>ログファイルとしてファイル選択ダイアログで既存のファイルを指定した時に上書き確認ダイアログを表示しないようにした。</li>
<li>MACRO: TTL ファイルが BOM なし UTF-8 の場合、実行できない問題を修正した。</li>
<li>UTF-8 の U+20000 から U+3FFFF を正しく扱うよう修正した。</li>
<li>"<a href="../menu/setup-additional-font.html#ResizedFont">Drawing resized font to fit cell width</a>" が on のとき、サロゲートペアの文字が存在したとき正しく表示するよう修正した。</li>
</ul>
</li>

Expand Down
10 changes: 8 additions & 2 deletions teraterm/teraterm/vtdisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2887,6 +2887,12 @@ static void DrawStrWSub(HDC DC, HDC BGDC, const wchar_t *StrW, const int *Dx,
* StrW U+307B U+309A
* cells 0 2
*
* len=4
* 吉(つちよし) 野 家
* 0 1 2
* StrW 0xd842 0xdfb7 0x91ce 0x5bb6
* cells 0 2 2 2
*
*/
void DrawStrW(HDC DC, HDC BGDC, const wchar_t *StrW, const char *cells, int len, int font_width, int font_height,
int Y, int *X)
Expand Down Expand Up @@ -2926,7 +2932,7 @@ void DrawStrW(HDC DC, HDC BGDC, const wchar_t *StrW, const char *cells, int len,
else {
SIZE size;
GetTextExtentPoint32W(DC, &StrW[i - zero_count], 1 + zero_count, &size);
if ((size.cx == Dx[i]) || (size.cx == Dx[i] + 1)) {
if (zero_count == 0 && ((size.cx == Dx[i]) || (size.cx == Dx[i] + 1))) {
wchar_count++;
cell_count += cells[i];
}
Expand All @@ -2938,10 +2944,10 @@ void DrawStrW(HDC DC, HDC BGDC, const wchar_t *StrW, const char *cells, int len,
}
DrawChar(DC, BGDC, *X, Y, &StrW[i - zero_count], 1 + zero_count, cells[i]);
*X += cells[i] * FontWidth;
start_idx += 1 + zero_count;
zero_count = 0;
cell_count = 0;
wchar_count = 0;
start_idx++;
}
}
}
Expand Down

0 comments on commit bd1a824

Please sign in to comment.