mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-09 13:42:09 -05:00
GTK: don't try to use X fonts for characters outside BMP
X fonts are indexed by 16-bit quantities, so even Unicode-capable fonts can only have characters in the Basic Multilingual Plane (BMP). PuTTY, however, tried to look up all Unicode characters in X fonts, and did so by effectively ignoring all but the low-order 16 bits of the character code. This meant that trying to display a non-BMP character could get you the corresponding character from the BMP instead, if that character was in the font. Now, x11font_has_glyph() always returns false for glyphs outside the BMP, which should mean that x11font_draw_text() never gets asked to draw them.
This commit is contained in:
parent
fcadb5fed1
commit
a0a92da035
@ -554,10 +554,11 @@ static bool x11font_has_glyph(unifont *font, wchar_t glyph)
|
||||
if (xfont->sixteen_bit) {
|
||||
/*
|
||||
* This X font has 16-bit character indices, which means
|
||||
* we can directly use our Unicode input value.
|
||||
* we can directly use our Unicode input value as long as
|
||||
* it's in the BMP.
|
||||
*/
|
||||
return x11_font_has_glyph(xfont->fonts[0].xfs,
|
||||
glyph >> 8, glyph & 0xFF);
|
||||
return glyph < 0x10000 &&
|
||||
x11_font_has_glyph(xfont->fonts[0].xfs, glyph >> 8, glyph & 0xFF);
|
||||
} else {
|
||||
/*
|
||||
* This X font has 8-bit indices, so we must convert to the
|
||||
@ -790,6 +791,8 @@ static void x11font_draw_text(unifont_drawctx *ctx, unifont *font,
|
||||
xcslen = len;
|
||||
xcs = snewn(xcslen, XChar2b);
|
||||
for (i = 0; i < xcslen; i++) {
|
||||
/* We shouldn't see any character not in the font. */
|
||||
assert(string[i] < 0x10000);
|
||||
xcs[i].byte1 = string[i] >> 8;
|
||||
xcs[i].byte2 = string[i];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user