summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-09-16 07:49:21 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-09-16 07:49:21 (GMT)
commit41d3c8f67e62fe307c46c91e5a42b71e39c59334 (patch)
tree0c7c6348e421d05be040ec77ef8a7200c85c391d /win
parent9759a4f9b6f61757dc505a923c07951e560e47a3 (diff)
downloadtk-41d3c8f67e62fe307c46c91e5a42b71e39c59334.zip
tk-41d3c8f67e62fe307c46c91e5a42b71e39c59334.tar.gz
tk-41d3c8f67e62fe307c46c91e5a42b71e39c59334.tar.bz2
Patch from Christian Werner, for evaluation
Diffstat (limited to 'win')
-rw-r--r--win/tkWinFont.c37
-rw-r--r--win/tkWinKey.c3
2 files changed, 30 insertions, 10 deletions
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 10ea1b9..e413e7d 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -26,9 +26,13 @@
* Under Windows, a "font family" is uniquely identified by its face name.
*/
-#define FONTMAP_SHIFT 10
-
-#define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT))
+#if TCL_UTF_MAX > 3
+#define FONTMAP_SHIFT 12
+#define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT))
+#else
+#define FONTMAP_SHIFT 10
+#define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT))
+#endif
#define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT)
typedef struct FontFamily {
@@ -229,6 +233,11 @@ static inline HFONT SelectFont(HDC hdc, WinFont *fontPtr,
SubFont *subFontPtr, double angle);
static inline void SwapLong(PULONG p);
static inline void SwapShort(USHORT *p);
+#if TCL_UTF_MAX == 4
+#define UtfToUniChar(src, chPtr) TkUtfToUniChar32(src, chPtr)
+#else
+#define UtfToUniChar(src, chPtr) Tcl_UtfToUniChar(src, chPtr)
+#endif
static int CALLBACK WinFontCanUseProc(ENUMLOGFONT *lfPtr,
NEWTEXTMETRIC *tmPtr, int fontType,
LPARAM lParam);
@@ -828,7 +837,11 @@ Tk_MeasureChars(
HFONT oldFont;
WinFont *fontPtr;
int curX, moretomeasure;
+#if TCL_UTF_MAX == 4
+ int ch;
+#else
Tcl_UniChar ch;
+#endif
SIZE size;
FontFamily *familyPtr;
Tcl_DString runString;
@@ -859,7 +872,7 @@ Tk_MeasureChars(
start = source;
end = start + numBytes;
for (p = start; p < end; ) {
- next = p + Tcl_UtfToUniChar(p, &ch);
+ next = p + UtfToUniChar(p, &ch);
thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
if (thisSubFontPtr != lastSubFontPtr) {
familyPtr = lastSubFontPtr->familyPtr;
@@ -921,7 +934,7 @@ Tk_MeasureChars(
familyPtr = lastSubFontPtr->familyPtr;
Tcl_DStringInit(&runString);
for (p = start; p < end; ) {
- next = p + Tcl_UtfToUniChar(p, &ch);
+ next = p + UtfToUniChar(p, &ch);
Tcl_UtfToExternal(NULL, familyPtr->encoding, p,
(int) (next - p), 0, NULL, buf, sizeof(buf), NULL,
&dstWrote, NULL);
@@ -970,13 +983,17 @@ Tk_MeasureChars(
*/
const char *lastWordBreak = NULL;
+#if TCL_UTF_MAX == 4
+ int ch2;
+#else
Tcl_UniChar ch2;
+#endif
end = p;
p = source;
ch = ' ';
while (p < end) {
- next = p + Tcl_UtfToUniChar(p, &ch2);
+ next = p + UtfToUniChar(p, &ch2);
if ((ch != ' ') && (ch2 == ' ')) {
lastWordBreak = p;
}
@@ -1443,7 +1460,11 @@ MultiFontTextOut(
* string when drawing. */
double angle)
{
+#if TCL_UTF_MAX == 4
+ int ch;
+#else
Tcl_UniChar ch;
+#endif
SIZE size;
HFONT oldFont;
FontFamily *familyPtr;
@@ -1458,7 +1479,7 @@ MultiFontTextOut(
end = source + numBytes;
for (p = source; p < end; ) {
- next = p + Tcl_UtfToUniChar(p, &ch);
+ next = p + UtfToUniChar(p, &ch);
thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
if (thisSubFontPtr != lastSubFontPtr) {
if (p > source) {
@@ -2188,7 +2209,7 @@ FontMapLoadPage(
{
FontFamily *familyPtr;
Tcl_Encoding encoding;
- char src[XMaxTransChars], buf[16];
+ char src[TCL_UTF_MAX], buf[16];
USHORT *startCount, *endCount;
int i, j, bitOffset, end, segCount;
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index 2698c4d..815ff3b 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.c
@@ -113,7 +113,6 @@ TkpGetString(
Tcl_DStringAppend(dsPtr, buf, len);
} else if (keyEv->send_event == -3) {
-
char buf[XMaxTransChars];
int len;
@@ -122,7 +121,7 @@ TkpGetString(
*/
len = Tcl_UniCharToUtf(keyEv->keycode, buf);
- if ((keyEv->keycode <= 0xffff) || (len == XMaxTransChars)) {
+ if ((keyEv->keycode <= 0xffff) || (len > 3)) {
Tcl_DStringAppend(dsPtr, buf, len);
} else {
Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) >> 10) | 0xd800, buf);