summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcc_benny <cc_benny>2007-05-28 17:12:31 (GMT)
committercc_benny <cc_benny>2007-05-28 17:12:31 (GMT)
commitade1f04a03ea0e05c52bec613ef2690da765794c (patch)
tree9aa785c6df562186e3ffe3537f10cf2b08b7c7f3
parent20eeeb7974cb31ad570850fa36c1c4459a7d76af (diff)
downloadtk-ade1f04a03ea0e05c52bec613ef2690da765794c.zip
tk-ade1f04a03ea0e05c52bec613ef2690da765794c.tar.gz
tk-ade1f04a03ea0e05c52bec613ef2690da765794c.tar.bz2
* macosx/tkMacOSXFont.c (TkpMeasureCharsInContext): Fix short
measures with flags=TK_WHOLE_WORDS|TK_AT_LEAST_ONE [Bug 1716141]. Make some casts unnecessary by changing variable types.
-rw-r--r--ChangeLog6
-rw-r--r--macosx/tkMacOSXFont.c104
2 files changed, 56 insertions, 54 deletions
diff --git a/ChangeLog b/ChangeLog
index 3621829..cc02f68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-28 Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net>
+
+ * macosx/tkMacOSXFont.c (TkpMeasureCharsInContext): Fix short
+ measures with flags=TK_WHOLE_WORDS|TK_AT_LEAST_ONE [Bug 1716141].
+ Make some casts unnecessary by changing variable types.
+
2007-05-25 Joe English <jenglish@users.sourceforge.net>
* library/ttk/ttk.tcl: Omit ttk::dialog and dependencies.
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 1a4a399..3804902 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -35,7 +35,7 @@
* that such fonts can not be used for controls, because controls
* definitely require a family id (this assertion needs testing).
*
- * RCS: @(#) $Id: tkMacOSXFont.c,v 1.24 2007/04/23 21:24:33 das Exp $
+ * RCS: @(#) $Id: tkMacOSXFont.c,v 1.25 2007/05/28 17:12:31 cc_benny Exp $
*/
#include "tkMacOSXInt.h"
@@ -704,7 +704,8 @@ TkpMeasureCharsInContext(
const MacFont *fontPtr = (const MacFont *) tkfont;
int curX = -1, curByte = 0;
UniChar *uchars;
- int ulen, urstart, urlen, urend;
+ int ulen;
+ UniCharArrayOffset urstart, urlen, urend;
Tcl_DString ucharBuffer;
/*
@@ -792,53 +793,47 @@ TkpMeasureCharsInContext(
* also something we like to decide for ourself.
*/
- while ((offset > (UniCharArrayOffset)urstart) &&
+ while ((offset > urstart) &&
(uchars[offset-1] == ' ')) {
offset--;
}
-
- /*
- * Fix up left-overs for the TK_WHOLE_WORDS case.
- */
-
- if (flags & TK_WHOLE_WORDS) {
- if (flags & TK_AT_LEAST_ONE) {
- /*
- * If we are the the start of the range, we need to look
- * forward. If we are not at the end of a word, we must
- * be in the middle of the first word, so we also look
- * forward.
- */
-
- if ((offset == (UniCharArrayOffset)urstart) ||
- (uchars[offset] != ' ')) {
- while ((offset < (UniCharArrayOffset)urend)
- && (uchars[offset] != ' ')) {
- offset++;
- }
- }
- } else {
- /*
- * If we are not at the end of a word, we need to look
- * backward.
- */
-
- if ((offset != (UniCharArrayOffset)urend) &&
- (uchars[offset] != ' ')) {
- while ((offset > (UniCharArrayOffset)urstart)
- && (uchars[offset-1] != ' ')) {
- offset--;
- }
- while ((offset > (UniCharArrayOffset)urstart)
- && (uchars[offset-1] == ' ')) {
- offset--;
- }
- }
- }
- }
- }
-
- if (offset > (UniCharArrayOffset)urend) {
+ }
+
+ /*
+ * Fix up left-overs for the TK_WHOLE_WORDS case.
+ */
+
+ if (flags & TK_WHOLE_WORDS) {
+ if (flags & TK_AT_LEAST_ONE) {
+ /*
+ * If we are the the start of the range, we need to look
+ * forward. If we are not at the end of a word, we must be in
+ * the middle of the first word, so we also look forward.
+ */
+
+ if ((offset == urstart) || (uchars[offset] != ' ')) {
+ while ((offset < urend) && (uchars[offset] != ' ')) {
+ offset++;
+ }
+ }
+ } else {
+ /*
+ * If we are not at the end of a word, we need to look
+ * backward.
+ */
+
+ if ((offset != urend) && (uchars[offset] != ' ')) {
+ while ((offset > urstart) && (uchars[offset-1] != ' ')) {
+ offset--;
+ }
+ while ((offset > urstart) && (uchars[offset-1] == ' ')) {
+ offset--;
+ }
+ }
+ }
+ }
+
+ if (offset > urend) {
offset = urend;
}
@@ -850,13 +845,13 @@ TkpMeasureCharsInContext(
if ((err != kATSULineBreakInWord)
&& !(flags & TK_WHOLE_WORDS)
- && (offset <= (UniCharArrayOffset)urend)) {
+ && (offset <= urend)) {
UniCharArrayOffset lastOffset = offset;
UniCharArrayOffset nextoffset;
int lastX = -1;
int wantonemorechar = -1; /* undecided */
- while (offset <= (UniCharArrayOffset)urend) {
+ while (offset <= urend) {
if (flags & TK_ISOLATE_END) {
LayoutSetString(fontPtr, NULL, uchars, offset);
}
@@ -876,7 +871,7 @@ TkpMeasureCharsInContext(
if (wantonemorechar == -1) {
wantonemorechar = ((flags & TK_AT_LEAST_ONE) &&
- (lastOffset == (UniCharArrayOffset)urstart)) ||
+ (lastOffset == urstart)) ||
((flags & TK_PARTIAL_OK) &&
(lastX != maxLength));
if (!wantonemorechar) {
@@ -907,7 +902,7 @@ TkpMeasureCharsInContext(
* into account.
*/
- if (offset >= (UniCharArrayOffset)urend) {
+ if (offset >= urend) {
break;
}
nextoffset = 0;
@@ -952,13 +947,14 @@ TkpMeasureCharsInContext(
Tcl_DStringFree(&ucharBuffer);
#ifdef TK_MAC_DEBUG_FONTS
- TkMacOSXDbgMsg("measure: '%.*s', maxpix=%d, -> width=%d, bytes=%d, "
- "flags=%s%s%s%s", rangeLength, source+rangeStart, maxLength, curX,
- curByte,
+ TkMacOSXDbgMsg("measure: '%.*s', maxLength=%d, flags=%s%s%s%s "
+ "-> width=%d, bytes=%d",
+ rangeLength, source+rangeStart, maxLength,
flags & TK_PARTIAL_OK ? "partialOk " : "",
flags & TK_WHOLE_WORDS ? "wholeWords " : "",
flags & TK_AT_LEAST_ONE ? "atLeastOne " : "",
- flags & TK_ISOLATE_END ? "isolateEnd " : "");
+ flags & TK_ISOLATE_END ? "isolateEnd " : "",
+ curX, curByte);
#endif
*lengthPtr = curX;