summaryrefslogtreecommitdiffstats
path: root/generic/tkFont.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-20 16:51:57 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-20 16:51:57 (GMT)
commit38d1c0b4e30e546ebe17c179e46e99884dcab433 (patch)
tree626a91a7efdd0b61978a1ff2c0ccf262ada91491 /generic/tkFont.c
parent51d384bfda7a3eb5a915b19d343c8bb657268d75 (diff)
parent75d83ece93c7c0f3a2a3c8e3a925b35353ccddeb (diff)
downloadtk-38d1c0b4e30e546ebe17c179e46e99884dcab433.zip
tk-38d1c0b4e30e546ebe17c179e46e99884dcab433.tar.gz
tk-38d1c0b4e30e546ebe17c179e46e99884dcab433.tar.bz2
Add (and use) new internal function TkUtfAtIndex(), which does the same as Tcl_UtfAtIndex() only it protects against ending in the middle of a 4-byte UTF-8 sequence. This should fix another part of [a179564826] when handling copy-pasted Emoji in Text/Entry (and other) widgets.
Diffstat (limited to 'generic/tkFont.c')
-rw-r--r--generic/tkFont.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c
index bf35626..53855ac 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -2021,7 +2021,7 @@ Tk_ComputeTextLayout(
curX = 0;
- end = Tcl_UtfAtIndex(string, numChars);
+ end = TkUtfAtIndex(string, numChars);
special = string;
flags &= TK_IGNORE_TABS | TK_IGNORE_NEWLINES;
@@ -2325,14 +2325,14 @@ Tk_DrawTextLayout(
firstChar = 0;
firstByte = chunkPtr->start;
} else {
- firstByte = Tcl_UtfAtIndex(chunkPtr->start, firstChar);
+ firstByte = TkUtfAtIndex(chunkPtr->start, firstChar);
Tk_MeasureChars(layoutPtr->tkfont, chunkPtr->start,
firstByte - chunkPtr->start, -1, 0, &drawX);
}
if (lastChar < numDisplayChars) {
numDisplayChars = lastChar;
}
- lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars);
+ lastByte = TkUtfAtIndex(chunkPtr->start, numDisplayChars);
Tk_DrawChars(display, drawable, gc, layoutPtr->tkfont, firstByte,
lastByte - firstByte, x+chunkPtr->x+drawX, y+chunkPtr->y);
}
@@ -2387,14 +2387,14 @@ TkDrawAngledTextLayout(
firstChar = 0;
firstByte = chunkPtr->start;
} else {
- firstByte = Tcl_UtfAtIndex(chunkPtr->start, firstChar);
+ firstByte = TkUtfAtIndex(chunkPtr->start, firstChar);
Tk_MeasureChars(layoutPtr->tkfont, chunkPtr->start,
firstByte - chunkPtr->start, -1, 0, &drawX);
}
if (lastChar < numDisplayChars) {
numDisplayChars = lastChar;
}
- lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars);
+ lastByte = TkUtfAtIndex(chunkPtr->start, numDisplayChars);
dx = cosA * (chunkPtr->x + drawX) + sinA * (chunkPtr->y);
dy = -sinA * (chunkPtr->x + drawX) + cosA * (chunkPtr->y);
if (angle == 0.0) {
@@ -2736,7 +2736,7 @@ Tk_CharBbox(
goto check;
}
} else if (index < chunkPtr->numChars) {
- end = Tcl_UtfAtIndex(chunkPtr->start, index);
+ end = TkUtfAtIndex(chunkPtr->start, index);
if (xPtr != NULL) {
Tk_MeasureChars(tkfont, chunkPtr->start,
end - chunkPtr->start, -1, 0, &x);