diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-16 12:17:59 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-16 12:17:59 (GMT) |
commit | 7a5d64437977cc14b7b79e336b3b2a20785348e5 (patch) | |
tree | 7a98c5e25eb278af7eb4c7fa58ab73d819c2c739 /generic/tkFont.c | |
parent | 41d3c8f67e62fe307c46c91e5a42b71e39c59334 (diff) | |
download | tk-7a5d64437977cc14b7b79e336b3b2a20785348e5.zip tk-7a5d64437977cc14b7b79e336b3b2a20785348e5.tar.gz tk-7a5d64437977cc14b7b79e336b3b2a20785348e5.tar.bz2 |
Rename TkUtfToUniChar32 to TkUtfToUniChar2, and various simplifications needing less #ifdef's
Diffstat (limited to 'generic/tkFont.c')
-rw-r--r-- | generic/tkFont.c | 47 |
1 files changed, 6 insertions, 41 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c index 3088959..4a45691 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -497,11 +497,7 @@ Tk_FontObjCmd( const char *s; Tk_Font tkfont; Tcl_Obj *optPtr, *charPtr, *resultPtr; -#if TCL_UTF_MAX == 4 int uniChar = 0; -#else - Tcl_UniChar uniChar = 0; -#endif const TkFontAttributes *faPtr; TkFontAttributes fa; @@ -566,32 +562,19 @@ Tk_FontObjCmd( */ if (charPtr != NULL) { -#if TCL_UTF_MAX == 4 - Tcl_UniChar *ucPtr; -#endif + const char *string = Tcl_GetString(charPtr); + int len = TkUtfToUniChar2(string, &uniChar); - if (Tcl_GetCharLength(charPtr) != 1) { + if (len != charPtr->length) { resultPtr = Tcl_NewStringObj( "expected a single character but got \"", -1); - Tcl_AppendLimitedToObj(resultPtr, Tcl_GetString(charPtr), + Tcl_AppendLimitedToObj(resultPtr, string, -1, 40, "..."); Tcl_AppendToObj(resultPtr, "\"", -1); Tcl_SetObjResult(interp, resultPtr); Tcl_SetErrorCode(interp, "TK", "VALUE", "FONT_SAMPLE", NULL); return TCL_ERROR; } -#if TCL_UTF_MAX == 4 - ucPtr = Tcl_GetUnicodeFromObj(charPtr, NULL); - uniChar = *ucPtr; - if (((uniChar & 0xFC00) == 0xD800) && (ucPtr[1] != 0x000)) { - if ((ucPtr[1] & 0xFC00) == 0xDC00) { - uniChar = ((uniChar & 0x3FF) << 10) + (ucPtr[1] & 0x3FF); - uniChar += 0x10000; - } - } -#else - uniChar = Tcl_GetUniChar(charPtr, 0); -#endif } /* @@ -1713,11 +1696,7 @@ Tk_PostscriptFontName( } else if (strcasecmp(family, "ZapfDingbats") == 0) { family = "ZapfDingbats"; } else { -#if TCL_UTF_MAX == 4 int ch; -#else - Tcl_UniChar ch; -#endif /* * Inline, capitalize the first letter of each word, lowercase the @@ -1735,11 +1714,7 @@ Tk_PostscriptFontName( src++; upper = 1; } -#if TCL_UTF_MAX == 4 - src += TkUtfToUniChar32(src, &ch); -#else - src += Tcl_UtfToUniChar(src, &ch); -#endif + src += TkUtfToUniChar2(src, &ch); if (upper) { ch = (Tcl_UniChar) Tcl_UniCharToUpper(ch); upper = 0; @@ -3276,11 +3251,7 @@ Tk_TextLayoutToPostscript( int i, j, len; const char *p, *glyphname; char uindex[5], c, *ps; -#if TCL_UTF_MAX == 4 int ch; -#else - Tcl_UniChar ch; -#endif Tcl_AppendToObj(psObj, "[(", -1); for (i = 0; i < layoutPtr->numChunks; i++, chunkPtr++) { @@ -3303,11 +3274,7 @@ Tk_TextLayoutToPostscript( * international postscript fonts. */ -#if TCL_UTF_MAX == 4 - p += TkUtfToUniChar32(p, &ch); -#else - p += Tcl_UtfToUniChar(p, &ch); -#endif + p += TkUtfToUniChar2(p, &ch); if ((ch == '(') || (ch == ')') || (ch == '\\') || (ch < 0x20)) { /* * Tricky point: the "03" is necessary in the sprintf below, @@ -3333,11 +3300,9 @@ Tk_TextLayoutToPostscript( * use the full glyph name. */ -#if TCL_UTF_MAX > 3 if (ch > 0xffff) { goto noMapping; } -#endif sprintf(uindex, "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { |