summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixFont.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-10-25 21:06:25 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-10-25 21:06:25 (GMT)
commit0d5336db012f45753abace489f18f0ca299c6961 (patch)
treeb1bf3280a9046df99226158978502eeb26f5b0a3 /unix/tkUnixFont.c
parente97381a6d921de403516d5b761539a450f4af83c (diff)
parent1320b8a2a9c1269a345d44d673a7a35707fbbe9c (diff)
downloadtk-core-tip-626.zip
tk-core-tip-626.tar.gz
tk-core-tip-626.tar.bz2
Merge 9.0core-tip-626
Diffstat (limited to 'unix/tkUnixFont.c')
-rw-r--r--unix/tkUnixFont.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index da75d0f..6ff53cf 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -242,6 +242,33 @@ static int SeenName(const char *name, Tcl_DString *dsPtr);
/*
*-------------------------------------------------------------------------
*
+ * XLoadQueryFontNoXError --
+ *
+ * This function is XLoadQueryFont wrapped in a NULL error handler.
+ * It is a temporary workaround for ticket [36e379c01b],
+ * "macOS Ventura, X11 build with XQuartz: crash in XLoadQueryFont",
+ * which actually is issue #216 in XQuartz:
+ * https://github.com/XQuartz/XQuartz/issues/216
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static XFontStruct *
+XLoadQueryFontNoXError(Display *display, char *name)
+{
+ XFontStruct *fontStructPtr = NULL;
+ Tk_ErrorHandler handler;
+
+ /* 45 is the major opcode of X_OpenFont */
+ handler = Tk_CreateErrorHandler(display, BadValue, 45, -1, NULL, NULL);
+ fontStructPtr = XLoadQueryFont(display, name);
+ Tk_DeleteErrorHandler(handler);
+ return fontStructPtr;
+}
+
+/*
+ *-------------------------------------------------------------------------
+ *
* FontPkgCleanup --
*
* This function is called when an application is created. It initializes
@@ -490,7 +517,7 @@ TkpGetNativeFont(
return NULL;
}
- fontStructPtr = XLoadQueryFont(Tk_Display(tkwin), name);
+ fontStructPtr = XLoadQueryFontNoXError(Tk_Display(tkwin), (char *)name);
if (fontStructPtr == NULL) {
/*
* Handle all names that look like XLFDs here. Otherwise, when
@@ -745,7 +772,7 @@ void
TkpGetFontAttrsForChar(
Tk_Window tkwin, /* Window on the font's display */
Tk_Font tkfont, /* Font to query */
- int c, /* Character of interest */
+ int c, /* Character of interest */
TkFontAttributes *faPtr) /* Output: Font attributes */
{
FontAttributes atts;
@@ -2603,11 +2630,11 @@ GetScreenFont(
snprintf(buf, sizeof(buf), "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]],
(int)(-wantPtr->fa.size+0.5), rest);
*str = '-';
- fontStructPtr = XLoadQueryFont(display, buf);
+ fontStructPtr = XLoadQueryFontNoXError(display, buf);
bestScore[1] = INT_MAX;
}
if (fontStructPtr == NULL) {
- fontStructPtr = XLoadQueryFont(display, nameList[bestIdx[0]]);
+ fontStructPtr = XLoadQueryFontNoXError(display, nameList[bestIdx[0]]);
if (fontStructPtr == NULL) {
/*
* This shouldn't happen because the font name is one of the names
@@ -2647,9 +2674,9 @@ GetSystemFont(
{
XFontStruct *fontStructPtr;
- fontStructPtr = XLoadQueryFont(display, "fixed");
+ fontStructPtr = XLoadQueryFontNoXError(display, "fixed");
if (fontStructPtr == NULL) {
- fontStructPtr = XLoadQueryFont(display, "*");
+ fontStructPtr = XLoadQueryFontNoXError(display, "*");
if (fontStructPtr == NULL) {
Tcl_Panic("TkpGetFontFromAttributes: cannot get any font");
}