summaryrefslogtreecommitdiffstats
path: root/generic/tkFont.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-09-29 12:03:43 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-09-29 12:03:43 (GMT)
commit3bca7a22ca1dff514ae34de1506efc170620e0f0 (patch)
treea7130678e7d225c7e0c128f344c6f24f961b670d /generic/tkFont.c
parenta17940858b04468beb718a5114bcdf8056b4b8f0 (diff)
parent22a93049efcb472b432f33af5567c150eef0855c (diff)
downloadtk-3bca7a22ca1dff514ae34de1506efc170620e0f0.zip
tk-3bca7a22ca1dff514ae34de1506efc170620e0f0.tar.gz
tk-3bca7a22ca1dff514ae34de1506efc170620e0f0.tar.bz2
Fix [6c0d7aec6713ab6a7c3e12dff7f26bff4679bc9d|6c0d7aec67]: unicode text input Windows 8. Added some test-cases using the "font actual" command.
Diffstat (limited to 'generic/tkFont.c')
-rw-r--r--generic/tkFont.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 102fc6e..51b2fce 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -13,6 +13,7 @@
#include "tkInt.h"
#include "tkFont.h"
+#include <windows.h>
/*
* The following structure is used to keep track of all the fonts that exist
@@ -497,7 +498,7 @@ Tk_FontObjCmd(
const char *s;
Tk_Font tkfont;
Tcl_Obj *optPtr, *charPtr, *resultPtr;
- Tcl_UniChar uniChar = 0;
+ int uniChar = 0;
const TkFontAttributes *faPtr;
TkFontAttributes fa;
@@ -562,17 +563,19 @@ Tk_FontObjCmd(
*/
if (charPtr != NULL) {
- if (Tcl_GetCharLength(charPtr) != 1) {
+ const char *string = Tcl_GetString(charPtr);
+ int len = TkUtfToUniChar(string, &uniChar);
+
+ 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;
}
- uniChar = Tcl_GetUniChar(charPtr, 0);
}
/*
@@ -1694,7 +1697,7 @@ Tk_PostscriptFontName(
} else if (strcasecmp(family, "ZapfDingbats") == 0) {
family = "ZapfDingbats";
} else {
- Tcl_UniChar ch;
+ int ch;
/*
* Inline, capitalize the first letter of each word, lowercase the
@@ -1712,14 +1715,14 @@ Tk_PostscriptFontName(
src++;
upper = 1;
}
- src += Tcl_UtfToUniChar(src, &ch);
+ src += TkUtfToUniChar(src, &ch);
if (upper) {
ch = Tcl_UniCharToUpper(ch);
upper = 0;
} else {
ch = Tcl_UniCharToLower(ch);
}
- dest += Tcl_UniCharToUtf(ch, dest);
+ dest += TkUniCharToUtf(ch, dest);
}
*dest = '\0';
Tcl_DStringSetLength(dsPtr, dest - Tcl_DStringValue(dsPtr));
@@ -3249,7 +3252,7 @@ Tk_TextLayoutToPostscript(
int i, j, len;
const char *p, *glyphname;
char uindex[5], c, *ps;
- Tcl_UniChar ch;
+ int ch;
Tcl_AppendToObj(psObj, "[(", -1);
for (i = 0; i < layoutPtr->numChunks; i++, chunkPtr++) {
@@ -3272,7 +3275,7 @@ Tk_TextLayoutToPostscript(
* international postscript fonts.
*/
- p += Tcl_UtfToUniChar(p, &ch);
+ p += TkUtfToUniChar(p, &ch);
if ((ch == '(') || (ch == ')') || (ch == '\\') || (ch < 0x20)) {
/*
* Tricky point: the "03" is necessary in the sprintf below,
@@ -3298,6 +3301,9 @@ Tk_TextLayoutToPostscript(
* use the full glyph name.
*/
+ if (ch > 0xffff) {
+ goto noMapping;
+ }
sprintf(uindex, "%04X", ch); /* endianness? */
glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0);
if (glyphname) {
@@ -3318,6 +3324,7 @@ Tk_TextLayoutToPostscript(
* No known mapping for the character into the space of
* PostScript glyphs. Ignore it. :-(
*/
+noMapping: ;
#ifdef TK_DEBUG_POSTSCRIPT_OUTPUT
fprintf(stderr, "Warning: no mapping to PostScript "