From 4e133576bad75e1a28062fe47dc26bacf38ee324 Mon Sep 17 00:00:00 2001 From: jenglish Date: Tue, 19 Apr 2005 05:50:04 +0000 Subject: Tk_MeasureChars: Use Tcl_UtfToUnichar() for lax UTF-8 parsing instead of strict parsing with FcUtf8ToUcs4() [fix/workaround for #1185640] --- ChangeLog | 6 ++++++ unix/tkUnixRFont.c | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5be9374..2c20f95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-04-18 Joe English + + * unix/tkUnixRFont.c(Tk_MeasureChars): Use Tcl_UtfToUnichar() + for lax UTF-8 parsing instead of strict parsing with FcUtf8ToUcs4() + [fix/workaround for #1185640] + 2003-04-18 Vince Darley * library/text.tcl diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 2557ab0..cd4a4f0 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixRFont.c,v 1.8 2004/11/28 19:00:49 jenglish Exp $ + * RCS: @(#) $Id: tkUnixRFont.c,v 1.9 2005/04/19 05:50:06 jenglish Exp $ */ #include "tkUnixInt.h" @@ -511,15 +511,15 @@ Tk_MeasureChars(tkfont, source, numBytes, maxLength, flags, lengthPtr) curByte = 0; sawNonSpace = 0; while (numBytes > 0) { - clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes); + Tcl_UniChar unichar; + + clen = Tcl_UtfToUniChar(source, &unichar); + c = (FcChar32)unichar; if (clen <= 0) { - /* - * This should not happen, but it can, due to bugs in Tcl - * (i.e., [encoding convertfrom identity]). - */ + /* This can't happen (but see #1185640) */ *lengthPtr = curX; - return ++curByte; + return curByte; } source += clen; -- cgit v0.12