diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-19 10:14:52 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-19 10:14:52 (GMT) |
commit | bdb580aa2563588e6e1f5090bb9b89369e2f2d4f (patch) | |
tree | 011764b9a1c9b1b47f5d61b56f1627526961f832 /unix | |
parent | 7a5d64437977cc14b7b79e336b3b2a20785348e5 (diff) | |
download | tk-bdb580aa2563588e6e1f5090bb9b89369e2f2d4f.zip tk-bdb580aa2563588e6e1f5090bb9b89369e2f2d4f.tar.gz tk-bdb580aa2563588e6e1f5090bb9b89369e2f2d4f.tar.bz2 |
More simplifications
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tkUnixFont.c | 20 | ||||
-rw-r--r-- | unix/tkUnixRFont.c | 2 |
2 files changed, 15 insertions, 7 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 681d1d1..ce4eca9 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -405,7 +405,7 @@ ControlUtfProc( { const char *srcStart, *srcEnd; char *dstStart, *dstEnd; - Tcl_UniChar ch; + int ch; int result; static char hexChars[] = "0123456789abcdef"; static char mapChars[] = { @@ -426,9 +426,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) { @@ -436,13 +436,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; @@ -1027,7 +1035,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; @@ -1043,7 +1051,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 0ea1ec6..cf4127d 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -670,7 +670,7 @@ Tk_MeasureChars( while (numBytes > 0) { int unichar; - clen = TkUtfToUniChar2(source, &unichar); + clen = TkUtfToUniChar(source, &unichar); c = (FcChar32) unichar; if (clen <= 0) { |