diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-29 12:38:54 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-29 12:38:54 (GMT) |
commit | 88ee425e30d88dd5cafc3f2387e5b5f50098517e (patch) | |
tree | 27b23d9828d8e560c051b9ff8b3130101c014b23 /unix | |
parent | 508dc0d9c60f4a9e75ebf487ef12167290509f71 (diff) | |
parent | 3bca7a22ca1dff514ae34de1506efc170620e0f0 (diff) | |
download | tk-88ee425e30d88dd5cafc3f2387e5b5f50098517e.zip tk-88ee425e30d88dd5cafc3f2387e5b5f50098517e.tar.gz tk-88ee425e30d88dd5cafc3f2387e5b5f50098517e.tar.bz2 |
Fix [6c0d7aec67]: unicode text input Windows 8
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tkUnixFont.c | 24 | ||||
-rw-r--r-- | unix/tkUnixRFont.c | 4 |
2 files changed, 18 insertions, 10 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index a6826b5..1b0f175 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -35,9 +35,9 @@ static const char *const encodingList[] = { * family": the foundry, face name, and charset. */ -#define FONTMAP_SHIFT 10 +#define FONTMAP_SHIFT 12 -#define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT)) +#define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT)) #define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT) typedef struct FontFamily { @@ -406,7 +406,7 @@ ControlUtfProc( { const char *srcStart, *srcEnd; char *dstStart, *dstEnd; - Tcl_UniChar ch; + int ch; int result; static char hexChars[] = "0123456789abcdef"; static char mapChars[] = { @@ -427,9 +427,9 @@ ControlUtfProc( result = TCL_CONVERT_NOSPACE; break; } - src += Tcl_UtfToUniChar(src, &ch); + src += TkUtfToUniChar(src, &ch); dst[0] = '\\'; - if ((ch < sizeof(mapChars)) && (mapChars[ch] != 0)) { + if (((size_t) ch < sizeof(mapChars)) && (mapChars[ch] != 0)) { dst[1] = mapChars[ch]; dst += 2; } else if (ch < 256) { @@ -437,13 +437,21 @@ ControlUtfProc( dst[2] = hexChars[(ch >> 4) & 0xf]; dst[3] = hexChars[ch & 0xf]; dst += 4; - } else { + } else if (ch < 0x10000) { dst[1] = 'u'; dst[2] = hexChars[(ch >> 12) & 0xf]; dst[3] = hexChars[(ch >> 8) & 0xf]; dst[4] = hexChars[(ch >> 4) & 0xf]; dst[5] = hexChars[ch & 0xf]; dst += 6; + } else { + /* TODO we can do better here */ + dst[1] = 'u'; + dst[2] = 'f'; + dst[3] = 'f'; + dst[4] = 'f'; + dst[5] = 'd'; + dst += 6; } } *srcReadPtr = src - srcStart; @@ -1028,7 +1036,7 @@ Tk_MeasureChars( curByte = 0; } else if (maxLength < 0) { const char *p, *end, *next; - Tcl_UniChar ch; + int ch; SubFont *thisSubFontPtr; FontFamily *familyPtr; Tcl_DString runString; @@ -1044,7 +1052,7 @@ Tk_MeasureChars( curX = 0; end = source + numBytes; for (p = source; p < end; ) { - next = p + Tcl_UtfToUniChar(p, &ch); + next = p + TkUtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { familyPtr = lastSubFontPtr->familyPtr; diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 01bbb30..cf4127d 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -668,9 +668,9 @@ Tk_MeasureChars( curByte = 0; sawNonSpace = 0; while (numBytes > 0) { - Tcl_UniChar unichar; + int unichar; - clen = Tcl_UtfToUniChar(source, &unichar); + clen = TkUtfToUniChar(source, &unichar); c = (FcChar32) unichar; if (clen <= 0) { |