summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-06-19 14:08:44 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-06-19 14:08:44 (GMT)
commit5f5dec875b76abf0a55e531de9d358ba5b34485f (patch)
tree60a74042807f27c3a0efa85c2e7b7c4cfabc4498 /unix
parent59237b6ac5e62f44c6451465d76f19bb3c97469b (diff)
downloadtk-5f5dec875b76abf0a55e531de9d358ba5b34485f.zip
tk-5f5dec875b76abf0a55e531de9d358ba5b34485f.tar.gz
tk-5f5dec875b76abf0a55e531de9d358ba5b34485f.tar.bz2
Use available "ucs2-be" encoding on X11 and "utf-16" encoding on Win32, if provided by Tcl (TIP #547). If Tcl doesn't provide those encodings, proceed as usual.
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixFont.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index 96635b4..d00ff82 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -186,14 +186,7 @@ static EncodingAlias encodingAliases[] = {
{"tis620", "tis620*"},
{"ksc5601", "ksc5601*"},
{"dingbats", "*dingbats"},
-#ifdef WORDS_BIGENDIAN
- {"unicode", "iso10646-1"},
-#else
- /*
- * ucs-2be is needed if native order isn't BE.
- */
{"ucs-2be", "iso10646-1"},
-#endif
{NULL, NULL}
};
@@ -246,7 +239,6 @@ static unsigned RankAttributes(FontAttributes *wantPtr,
static void ReleaseFont(UnixFont *fontPtr);
static void ReleaseSubFont(Display *display, SubFont *subFontPtr);
static int SeenName(const char *name, Tcl_DString *dsPtr);
-#ifndef WORDS_BIGENDIAN
static int Ucs2beToUtfProc(ClientData clientData, const char*src,
int srcLen, int flags, Tcl_EncodingState*statePtr,
char *dst, int dstLen, int *srcReadPtr,
@@ -255,7 +247,6 @@ static int UtfToUcs2beProc(ClientData clientData, const char*src,
int srcLen, int flags, Tcl_EncodingState*statePtr,
char *dst, int dstLen, int *srcReadPtr,
int *dstWrotePtr, int *dstCharsPtr);
-#endif
/*
*-------------------------------------------------------------------------
@@ -320,9 +311,9 @@ TkpFontPkgInit(
{
ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- Tcl_EncodingType type;
SubFont dummy;
int i;
+ Tcl_Encoding ucs2;
if (tsdPtr->controlFamily.encoding == NULL) {
type.encodingName = "X11ControlChars";
@@ -343,20 +334,18 @@ TkpFontPkgInit(
FontMapInsert(&dummy, i + 0x80);
}
-#ifndef WORDS_BIGENDIAN
/*
* UCS-2BE is unicode (UCS-2) in big-endian format. Define this if
- * native order isn't BE. It is used in iso10646 fonts.
+ * if it doesn't exist yet. It is used in iso10646 fonts.
*/
- type.encodingName = "ucs-2be";
- type.toUtfProc = Ucs2beToUtfProc;
- type.fromUtfProc = UtfToUcs2beProc;
- type.freeProc = NULL;
- type.clientData = NULL;
- type.nullSize = 2;
- Tcl_CreateEncoding(&type);
-#endif
+ ucs2 = Tcl_GetEncoding(NULL, "ucs-2be");
+ if (ucs2 == NULL) {
+ Tcl_EncodingType type = {"ucs-2be", Ucs2beToUtfProc, UtfToUcs2beProc, NULL, NULL, 2};
+ Tcl_CreateEncoding(&type);
+ } else {
+ Tcl_FreeEncoding(ucs2);
+ }
Tcl_CreateThreadExitHandler(FontPkgCleanup, NULL);
}
}
@@ -459,7 +448,6 @@ ControlUtfProc(
return result;
}
-#ifndef WORDS_BIGENDIAN
/*
*-------------------------------------------------------------------------
*
@@ -632,7 +620,6 @@ UtfToUcs2beProc(
*dstCharsPtr = numChars;
return result;
}
-#endif /* WORDS_BIGENDIAN */
/*
*---------------------------------------------------------------------------