summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-05-05 09:39:36 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-05-05 09:39:36 (GMT)
commit6537a2d1e074434eb560cd0bab189190e0dba106 (patch)
treed3af85b2b2acc80ea0fee4d624c5fc85fe550eb8 /win
parentcfa2caa8be76ffed4179c1f51779095c837cab14 (diff)
downloadtk-6537a2d1e074434eb560cd0bab189190e0dba106.zip
tk-6537a2d1e074434eb560cd0bab189190e0dba106.tar.gz
tk-6537a2d1e074434eb560cd0bab189190e0dba106.tar.bz2
Fix FMR in subfont handling on Windows. [Bug 618872]
Diffstat (limited to 'win')
-rw-r--r--win/tkWinFont.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index e78cd81..5ab0150 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinFont.c,v 1.22 2004/01/13 02:06:02 davygrvy Exp $
+ * RCS: @(#) $Id: tkWinFont.c,v 1.23 2004/05/05 09:39:39 dkf Exp $
*/
#include "tkWinInt.h"
@@ -188,12 +188,15 @@ static Tcl_Encoding systemEncoding;
static FontFamily * AllocFontFamily(HDC hdc, HFONT hFont, int base);
static SubFont * CanUseFallback(HDC hdc, WinFont *fontPtr,
- char *fallbackName, int ch);
+ char *fallbackName, int ch,
+ SubFont **subfontPtrPtr);
static SubFont * CanUseFallbackWithAliases(HDC hdc, WinFont *fontPtr,
- char *faceName, int ch, Tcl_DString *nameTriedPtr);
+ char *faceName, int ch, Tcl_DString *nameTriedPtr,
+ SubFont **subfontPtrPtr);
static int FamilyExists(HDC hdc, CONST char *faceName);
static char * FamilyOrAliasExists(HDC hdc, CONST char *faceName);
-static SubFont * FindSubFontForChar(WinFont *fontPtr, int ch);
+static SubFont * FindSubFontForChar(WinFont *fontPtr, int ch,
+ SubFont **subfontPtrPtr);
static void FontMapInsert(SubFont *subFontPtr, int ch);
static void FontMapLoadPage(SubFont *subFontPtr, int row);
static int FontMapLookup(SubFont *subFontPtr, int ch);
@@ -640,7 +643,7 @@ Tk_MeasureChars(
end = start + numBytes;
for (p = start; p < end; ) {
next = p + Tcl_UtfToUniChar(p, &ch);
- thisSubFontPtr = FindSubFontForChar(fontPtr, ch);
+ thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
if (thisSubFontPtr != lastSubFontPtr) {
familyPtr = lastSubFontPtr->familyPtr;
Tcl_UtfToExternalDString(familyPtr->encoding, start,
@@ -996,7 +999,7 @@ MultiFontTextOut(
end = source + numBytes;
for (p = source; p < end; ) {
next = p + Tcl_UtfToUniChar(p, &ch);
- thisSubFontPtr = FindSubFontForChar(fontPtr, ch);
+ thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
if (thisSubFontPtr != lastSubFontPtr) {
if (p > source) {
familyPtr = lastSubFontPtr->familyPtr;
@@ -1445,7 +1448,9 @@ static SubFont *
FindSubFontForChar(
WinFont *fontPtr, /* The font object with which the character
* will be displayed. */
- int ch) /* The Unicode character to be displayed. */
+ int ch, /* The Unicode character to be displayed. */
+ SubFont **subfontPtrPtr) /* Pointer to var to be fixed up if we
+ * reallocate the subfont table. */
{
HDC hdc;
int i, j, k;
@@ -1509,7 +1514,7 @@ FindSubFontForChar(
for (j = 0; fontFallbacks[i][j] != NULL; j++) {
fallbackName = fontFallbacks[i][j];
subFontPtr = CanUseFallbackWithAliases(hdc, fontPtr, fallbackName,
- ch, &ds);
+ ch, &ds, subfontPtrPtr);
if (subFontPtr != NULL) {
goto end;
}
@@ -1524,7 +1529,7 @@ FindSubFontForChar(
for (i = 0; anyFallbacks[i] != NULL; i++) {
fallbackName = anyFallbacks[i];
subFontPtr = CanUseFallbackWithAliases(hdc, fontPtr, fallbackName,
- ch, &ds);
+ ch, &ds, subfontPtrPtr);
if (subFontPtr != NULL) {
goto end;
}
@@ -1592,7 +1597,8 @@ WinFontCanUseProc(
fallbackName = Tcl_DStringValue(&faceString);
if (SeenName(fallbackName, nameTriedPtr) == 0) {
- subFontPtr = CanUseFallback(hdc, fontPtr, fallbackName, ch);
+ subFontPtr = CanUseFallback(hdc, fontPtr, fallbackName, ch,
+ subfontPtrPtr);
if (subFontPtr != NULL) {
canUsePtr->subFontPtr = subFontPtr;
Tcl_DStringFree(&faceString);
@@ -1800,17 +1806,19 @@ CanUseFallbackWithAliases(
char *faceName, /* Desired face name for new screen font. */
int ch, /* The Unicode character that the new
* screen font must be able to display. */
- Tcl_DString *nameTriedPtr) /* Records face names that have already
+ Tcl_DString *nameTriedPtr, /* Records face names that have already
* been tried. It is possible for the same
* face name to be queried multiple times when
* trying to find a suitable screen font. */
+ SubFont **subfontPtrPtr) /* Variable to fixup if we reallocate the
+ * array of subfonts. */
{
int i;
char **aliases;
SubFont *subFontPtr;
if (SeenName(faceName, nameTriedPtr) == 0) {
- subFontPtr = CanUseFallback(hdc, fontPtr, faceName, ch);
+ subFontPtr = CanUseFallback(hdc, fontPtr, faceName, ch, subfontPtrPtr);
if (subFontPtr != NULL) {
return subFontPtr;
}
@@ -1819,7 +1827,8 @@ CanUseFallbackWithAliases(
if (aliases != NULL) {
for (i = 0; aliases[i] != NULL; i++) {
if (SeenName(aliases[i], nameTriedPtr) == 0) {
- subFontPtr = CanUseFallback(hdc, fontPtr, aliases[i], ch);
+ subFontPtr = CanUseFallback(hdc, fontPtr, aliases[i], ch,
+ subfontPtrPtr);
if (subFontPtr != NULL) {
return subFontPtr;
}
@@ -1898,8 +1907,10 @@ CanUseFallback(
WinFont *fontPtr, /* The font object that will own the new
* screen font. */
char *faceName, /* Desired face name for new screen font. */
- int ch) /* The Unicode character that the new
+ int ch, /* The Unicode character that the new
* screen font must be able to display. */
+ SubFont **subfontPtrPtr) /* Variable to fix-up if we realloc the array
+ * of subfonts. */
{
int i;
HFONT hFont;
@@ -1938,7 +1949,7 @@ CanUseFallback(
if (fontPtr->numSubFonts >= SUBFONT_SPACE) {
SubFont *newPtr;
-
+
newPtr = (SubFont *) ckalloc(sizeof(SubFont)
* (fontPtr->numSubFonts + 1));
memcpy((char *) newPtr, fontPtr->subFontArray,
@@ -1946,6 +1957,11 @@ CanUseFallback(
if (fontPtr->subFontArray != fontPtr->staticSubFonts) {
ckfree((char *) fontPtr->subFontArray);
}
+ /*
+ * Fix up the variable pointed to by subfontPtrPtr so it still
+ * points into the live array. [Bug 618872]
+ */
+ *subfontPtrPtr = newPtr + (*subfontPtrPtr - fontPtr->subFontArray);
fontPtr->subFontArray = newPtr;
}
fontPtr->subFontArray[fontPtr->numSubFonts] = subFont;