Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | fixes in tk's font rendering when using libxft |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
843e00e7fc4000090d53e568500a2c49 |
User & Date: | chw 2023-11-25 13:00:26.458 |
Context
2023-11-26
| ||
07:48 | fixes in ttk object caching check-in: 8891f0f092 user: chw tags: trunk | |
2023-11-25
| ||
13:00 | fixes in tk's font rendering when using libxft check-in: 843e00e7fc user: chw tags: trunk | |
10:54 | update sqlite to version 3.44.2 check-in: 0415c31dd6 user: chw tags: trunk | |
Changes
Changes to jni/sdl2tk/generic/tkFont.c.
︙ | ︙ | |||
1192 1193 1194 1195 1196 1197 1198 | /* * This is a stale reference: it refers to a TkFont that's no * longer in use. Clear the reference. */ FreeFontObj(objPtr); oldFontPtr = NULL; | | > > > > > | 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 | /* * This is a stale reference: it refers to a TkFont that's no * longer in use. Clear the reference. */ FreeFontObj(objPtr); oldFontPtr = NULL; } else if (Tk_Screen(tkwin) == oldFontPtr->screen #ifdef HAVE_XFT && Tk_Colormap(tkwin) == oldFontPtr->colormap && Tk_Visual(tkwin) == oldFontPtr->visual #endif ) { oldFontPtr->resourceRefCount++; return (Tk_Font) oldFontPtr; } } /* * Next, search the list of fonts that have the name we want, to see if |
︙ | ︙ | |||
1214 1215 1216 1217 1218 1219 1220 | } else { cacheHashPtr = Tcl_CreateHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr), &isNew); } firstFontPtr = (TkFont *)Tcl_GetHashValue(cacheHashPtr); for (fontPtr = firstFontPtr; (fontPtr != NULL); fontPtr = fontPtr->nextPtr) { | | > > > > > | 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 | } else { cacheHashPtr = Tcl_CreateHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr), &isNew); } firstFontPtr = (TkFont *)Tcl_GetHashValue(cacheHashPtr); for (fontPtr = firstFontPtr; (fontPtr != NULL); fontPtr = fontPtr->nextPtr) { if (Tk_Screen(tkwin) == fontPtr->screen #ifdef HAVE_XFT && Tk_Colormap(tkwin) == fontPtr->colormap && Tk_Visual(tkwin) == fontPtr->visual #endif ) { fontPtr->resourceRefCount++; fontPtr->objRefCount++; objPtr->internalRep.twoPtrValue.ptr1 = fontPtr; objPtr->internalRep.twoPtrValue.ptr2 = fiPtr; return (Tk_Font) fontPtr; } } |
︙ | ︙ | |||
1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 | } fontPtr->resourceRefCount = 1; fontPtr->objRefCount = 1; fontPtr->cacheHashPtr = cacheHashPtr; fontPtr->namedHashPtr = namedHashPtr; fontPtr->screen = Tk_Screen(tkwin); fontPtr->nextPtr = firstFontPtr; Tcl_SetHashValue(cacheHashPtr, fontPtr); Tk_MeasureChars((Tk_Font) fontPtr, "0", 1, -1, 0, &fontPtr->tabWidth); if (fontPtr->tabWidth == 0) { fontPtr->tabWidth = fontPtr->fm.maxWidth; } | > > > > | 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 | } fontPtr->resourceRefCount = 1; fontPtr->objRefCount = 1; fontPtr->cacheHashPtr = cacheHashPtr; fontPtr->namedHashPtr = namedHashPtr; fontPtr->screen = Tk_Screen(tkwin); #ifdef HAVE_XFT fontPtr->colormap = Tk_Colormap(tkwin); fontPtr->visual = Tk_Visual(tkwin); #endif fontPtr->nextPtr = firstFontPtr; Tcl_SetHashValue(cacheHashPtr, fontPtr); Tk_MeasureChars((Tk_Font) fontPtr, "0", 1, -1, 0, &fontPtr->tabWidth); if (fontPtr->tabWidth == 0) { fontPtr->tabWidth = fontPtr->fm.maxWidth; } |
︙ | ︙ | |||
1377 1378 1379 1380 1381 1382 1383 | /* * This is a stale reference: it refers to a TkFont that's no * longer in use. Clear the reference. */ FreeFontObj(objPtr); fontPtr = NULL; | | > > > > > | > > > > > | 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 | /* * This is a stale reference: it refers to a TkFont that's no * longer in use. Clear the reference. */ FreeFontObj(objPtr); fontPtr = NULL; } else if (Tk_Screen(tkwin) == fontPtr->screen #ifdef HAVE_XFT && Tk_Colormap(tkwin) == fontPtr->colormap && Tk_Visual(tkwin) == fontPtr->visual #endif ) { return (Tk_Font) fontPtr; } } /* * Next, search the list of fonts that have the name we want, to see if * one of them is for the right screen. */ if (fontPtr != NULL) { hashPtr = fontPtr->cacheHashPtr; FreeFontObj(objPtr); } else { hashPtr = Tcl_FindHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr)); } if (hashPtr != NULL) { for (fontPtr = (TkFont *)Tcl_GetHashValue(hashPtr); fontPtr != NULL; fontPtr = fontPtr->nextPtr) { if (Tk_Screen(tkwin) == fontPtr->screen #ifdef HAVE_XFT && Tk_Colormap(tkwin) == fontPtr->colormap && Tk_Visual(tkwin) == fontPtr->visual #endif ) { fontPtr->objRefCount++; objPtr->internalRep.twoPtrValue.ptr1 = fontPtr; objPtr->internalRep.twoPtrValue.ptr2 = fiPtr; return (Tk_Font) fontPtr; } } } |
︙ | ︙ |
Changes to jni/sdl2tk/generic/tkFont.h.
︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | Tcl_HashEntry *cacheHashPtr;/* Entry in font cache for this structure, * used when deleting it. */ Tcl_HashEntry *namedHashPtr;/* Pointer to hash table entry that * corresponds to the named font that the * tkfont was based on, or NULL if the tkfont * was not based on a named font. */ Screen *screen; /* The screen where this font is valid. */ int tabWidth; /* Width of tabs in this font (pixels). */ int underlinePos; /* Offset from baseline to origin of underline * bar (used for drawing underlines on a * non-underlined font). */ int underlineHeight; /* Height of underline bar (used for drawing * underlines on a non-underlined font). */ | > > > > | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | Tcl_HashEntry *cacheHashPtr;/* Entry in font cache for this structure, * used when deleting it. */ Tcl_HashEntry *namedHashPtr;/* Pointer to hash table entry that * corresponds to the named font that the * tkfont was based on, or NULL if the tkfont * was not based on a named font. */ Screen *screen; /* The screen where this font is valid. */ #ifdef HAVE_XFT Colormap colormap; Visual *visual; #endif int tabWidth; /* Width of tabs in this font (pixels). */ int underlinePos; /* Offset from baseline to origin of underline * bar (used for drawing underlines on a * non-underlined font). */ int underlineHeight; /* Height of underline bar (used for drawing * underlines on a non-underlined font). */ |
︙ | ︙ |
Changes to jni/sdl2tk/unix/tkUnixRFont.c.
︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | UnixFtFace *faces; int nfaces; FcFontSet *fontset; FcPattern *pattern; Display *display; int screen; XftDraw *ftDraw; int ncolors; int firstColor; UnixFtColorList colors[MAX_CACHED_COLORS]; } UnixFtFont; /* | > > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | UnixFtFace *faces; int nfaces; FcFontSet *fontset; FcPattern *pattern; Display *display; int screen; Colormap colormap; Visual *visual; XftDraw *ftDraw; int ncolors; int firstColor; UnixFtColorList colors[MAX_CACHED_COLORS]; } UnixFtFont; /* |
︙ | ︙ | |||
401 402 403 404 405 406 407 408 409 410 411 412 413 414 | fontPtr->faces[i].charset = 0; } fontPtr->faces[i].angle = 0.0; } fontPtr->display = Tk_Display(tkwin); fontPtr->screen = Tk_ScreenNumber(tkwin); fontPtr->ftDraw = 0; fontPtr->ncolors = 0; fontPtr->firstColor = -1; /* * Fill in platform-specific fields of TkFont. */ | > > | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | fontPtr->faces[i].charset = 0; } fontPtr->faces[i].angle = 0.0; } fontPtr->display = Tk_Display(tkwin); fontPtr->screen = Tk_ScreenNumber(tkwin); fontPtr->colormap = Tk_Colormap(tkwin); fontPtr->visual = Tk_Visual(tkwin); fontPtr->ftDraw = 0; fontPtr->ncolors = 0; fontPtr->firstColor = -1; /* * Fill in platform-specific fields of TkFont. */ |
︙ | ︙ | |||
967 968 969 970 971 972 973 | last = fontPtr->ncolors++; } /* * Translate the pixel value to a color. Needs a server round-trip. */ xcolor.pixel = pixel; | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | last = fontPtr->ncolors++; } /* * Translate the pixel value to a color. Needs a server round-trip. */ xcolor.pixel = pixel; XQueryColor(display, fontPtr->colormap, &xcolor); fontPtr->colors[last].color.color.red = xcolor.red; fontPtr->colors[last].color.color.green = xcolor.green; fontPtr->colors[last].color.color.blue = xcolor.blue; fontPtr->colors[last].color.color.alpha = 0xFFFF; fontPtr->colors[last].color.pixel = pixel; |
︙ | ︙ | |||
1023 1024 1025 1026 1027 1028 1029 | Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (fontPtr->ftDraw == 0) { #ifdef DEBUG_FONTSEL printf("Switch to drawable 0x%x\n", drawable); #endif /* DEBUG_FONTSEL */ fontPtr->ftDraw = XftDrawCreate(display, drawable, | | < | 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 | Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (fontPtr->ftDraw == 0) { #ifdef DEBUG_FONTSEL printf("Switch to drawable 0x%x\n", drawable); #endif /* DEBUG_FONTSEL */ fontPtr->ftDraw = XftDrawCreate(display, drawable, fontPtr->visual, fontPtr->colormap); } else { Tk_ErrorHandler handler = Tk_CreateErrorHandler(display, -1, -1, -1, NULL, NULL); XftDrawChange(fontPtr->ftDraw, drawable); Tk_DeleteErrorHandler(handler); } |
︙ | ︙ | |||
1164 1165 1166 1167 1168 1169 1170 | int originX, originY; if (fontPtr->ftDraw == 0) { #ifdef DEBUG_FONTSEL printf("Switch to drawable 0x%x\n", drawable); #endif /* DEBUG_FONTSEL */ fontPtr->ftDraw = XftDrawCreate(display, drawable, | | < | 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 | int originX, originY; if (fontPtr->ftDraw == 0) { #ifdef DEBUG_FONTSEL printf("Switch to drawable 0x%x\n", drawable); #endif /* DEBUG_FONTSEL */ fontPtr->ftDraw = XftDrawCreate(display, drawable, fontPtr->visual, fontPtr->colormap); } else { Tk_ErrorHandler handler = Tk_CreateErrorHandler(display, -1, -1, -1, NULL, NULL); XftDrawChange(fontPtr->ftDraw, drawable); Tk_DeleteErrorHandler(handler); } |
︙ | ︙ | |||
1268 1269 1270 1271 1272 1273 1274 | double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0); if (fontPtr->ftDraw == 0) { #ifdef DEBUG_FONTSEL printf("Switch to drawable 0x%x\n", drawable); #endif /* DEBUG_FONTSEL */ fontPtr->ftDraw = XftDrawCreate(display, drawable, | | < | 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 | double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0); if (fontPtr->ftDraw == 0) { #ifdef DEBUG_FONTSEL printf("Switch to drawable 0x%x\n", drawable); #endif /* DEBUG_FONTSEL */ fontPtr->ftDraw = XftDrawCreate(display, drawable, fontPtr->visual, fontPtr->colormap); } else { Tk_ErrorHandler handler = Tk_CreateErrorHandler(display, -1, -1, -1, NULL, NULL); XftDrawChange(fontPtr->ftDraw, drawable); Tk_DeleteErrorHandler(handler); } |
︙ | ︙ |