Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Slightly use of more "int" in stead of double, for 100% compatibility at script level. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | bug-434d294df |
Files: | files | file ages | folders |
SHA1: |
36c5cf9403e120945cb0cbe3189742c9 |
User & Date: | jan.nijtmans 2017-05-19 12:45:35 |
Context
2017-05-19
| ||
12:56 | Change internal field TkFontAttributes.size from type integer to double. This causes less roundings overall in various font calculations. Hopefully this fixes bug [434d294df], still to be confirmed, and makes Tk work again on modern Linux Mint/Fedora systems. check-in: 6c1859a0 user: jan.nijtmans tags: core-8-6-branch | |
12:45 | Slightly use of more "int" in stead of double, for 100% compatibility at script level. Closed-Leaf check-in: 36c5cf94 user: jan.nijtmans tags: bug-434d294df | |
2017-05-18
| ||
12:19 | merge trunk. Make "font actual" return integers, for compatibility. check-in: 09eec5d4 user: jan.nijtmans tags: bug-434d294df | |
12:18 | autoconf-2.59 check-in: 9c5ab47c user: dgp tags: core-8-6-branch | |
Changes
Changes to generic/tkFont.c.
︙ | ︙ | |||
1796 1797 1798 1799 1800 1801 1802 | Tcl_DStringAppend(dsPtr, weightString, -1); } if (slantString != NULL) { Tcl_DStringAppend(dsPtr, slantString, -1); } } | | | 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 | Tcl_DStringAppend(dsPtr, weightString, -1); } if (slantString != NULL) { Tcl_DStringAppend(dsPtr, slantString, -1); } } return (int)(fontPtr->fa.size + 0.5); } /* *--------------------------------------------------------------------------- * * Tk_TextWidth -- * |
︙ | ︙ | |||
3371 3372 3373 3374 3375 3376 3377 | TkFontAttributes *faPtr) /* Font attributes structure whose fields are * to be modified. Structure must already be * properly initialized. */ { int i, n, index; Tcl_Obj *optionPtr, *valuePtr; const char *value; | < | 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 | TkFontAttributes *faPtr) /* Font attributes structure whose fields are * to be modified. Structure must already be * properly initialized. */ { int i, n, index; Tcl_Obj *optionPtr, *valuePtr; const char *value; for (i = 0; i < objc; i += 2) { optionPtr = objv[i]; if (Tcl_GetIndexFromObj(interp, optionPtr, fontOpt, "option", 1, &index) != TCL_OK) { return TCL_ERROR; |
︙ | ︙ | |||
3403 3404 3405 3406 3407 3408 3409 | switch (index) { case FONT_FAMILY: value = Tcl_GetString(valuePtr); faPtr->family = Tk_GetUid(value); break; case FONT_SIZE: | | | | 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 | switch (index) { case FONT_FAMILY: value = Tcl_GetString(valuePtr); faPtr->family = Tk_GetUid(value); break; case FONT_SIZE: if (Tcl_GetIntFromObj(interp, valuePtr, &n) != TCL_OK) { return TCL_ERROR; } faPtr->size = (double)n; break; case FONT_WEIGHT: n = TkFindStateNumObj(interp, optionPtr, weightMap, valuePtr); if (n == TK_FW_UNKNOWN) { return TCL_ERROR; } faPtr->weight = n; |
︙ | ︙ | |||
3647 3648 3649 3650 3651 3652 3653 | Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", string, NULL); } return TCL_ERROR; } faPtr->family = Tk_GetUid(Tcl_GetString(objv[0])); if (objc > 1) { | < | | | 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 | Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", string, NULL); } return TCL_ERROR; } faPtr->family = Tk_GetUid(Tcl_GetString(objv[0])); if (objc > 1) { if (Tcl_GetIntFromObj(interp, objv[1], &n) != TCL_OK) { return TCL_ERROR; } faPtr->size = (double)n; } i = 2; if (objc == 3) { if (Tcl_ListObjGetElements(interp, objv[2], &objc, &objv) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
3910 3911 3912 3913 3914 3915 3916 | * * where N1 is the point size (in points, not decipoints!), and * N2, N3, and N4 are some additional numbers that I don't know * the purpose of, so I ignore them. */ faPtr->size = atof(field[XLFD_POINT_SIZE] + 1); | | | | | 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 | * * where N1 is the point size (in points, not decipoints!), and * N2, N3, and N4 are some additional numbers that I don't know * the purpose of, so I ignore them. */ faPtr->size = atof(field[XLFD_POINT_SIZE] + 1); } else if (Tcl_GetInt(NULL, field[XLFD_POINT_SIZE], &i) == TCL_OK) { faPtr->size = i/10.0; } else { return TCL_ERROR; } } /* * Pixel height of font. If specified, overrides pointsize. |
︙ | ︙ | |||
3935 3936 3937 3938 3939 3940 3941 | * * where N1 is the pixel size, and where N2, N3, and N4 are some * additional numbers that I don't know the purpose of, so I * ignore them. */ faPtr->size = atof(field[XLFD_PIXEL_SIZE] + 1); | | | > | 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 | * * where N1 is the pixel size, and where N2, N3, and N4 are some * additional numbers that I don't know the purpose of, so I * ignore them. */ faPtr->size = atof(field[XLFD_PIXEL_SIZE] + 1); } else if (Tcl_GetInt(NULL, field[XLFD_PIXEL_SIZE], &i) != TCL_OK) { faPtr->size = (double)i; return TCL_ERROR; } } faPtr->size = -faPtr->size; /* XLFD_RESOLUTION_X ignored. */ |
︙ | ︙ | |||
4015 4016 4017 4018 4019 4020 4021 | * *--------------------------------------------------------------------------- */ double TkFontGetPixels( Tk_Window tkwin, /* For point->pixel conversion factor. */ | | | | 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 | * *--------------------------------------------------------------------------- */ double TkFontGetPixels( Tk_Window tkwin, /* For point->pixel conversion factor. */ double size) /* Font size. */ { double d; if (size <= 0.0) { return -size; } d = size * 25.4 / 72.0; d *= WidthOfScreen(Tk_Screen(tkwin)); d /= WidthMMOfScreen(Tk_Screen(tkwin)); return d; |
︙ | ︙ | |||
4053 4054 4055 4056 4057 4058 4059 | double TkFontGetPoints( Tk_Window tkwin, /* For pixel->point conversion factor. */ double size) /* Font size. */ { double d; | | | 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 | double TkFontGetPoints( Tk_Window tkwin, /* For pixel->point conversion factor. */ double size) /* Font size. */ { double d; if (size >= 0.0) { return size; } d = -size * 72.0 / 25.4; d *= WidthMMOfScreen(Tk_Screen(tkwin)); d /= WidthOfScreen(Tk_Screen(tkwin)); return d; |
︙ | ︙ |
Changes to unix/configure.
︙ | ︙ | |||
5351 5352 5353 5354 5355 5356 5357 | LDFLAGS="$LDFLAGS -Wl,-Bexport" CC_SEARCH_FLAGS="" LD_SEARCH_FLAGS="" ;; OpenBSD-*) arch=`arch -s` case "$arch" in | < < < < < < < < < | | | | | | | | | < < | | | | | < < < < < < < < < < | < < | 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 | LDFLAGS="$LDFLAGS -Wl,-Bexport" CC_SEARCH_FLAGS="" LD_SEARCH_FLAGS="" ;; OpenBSD-*) arch=`arch -s` case "$arch" in alpha|sparc64) SHLIB_CFLAGS="-fPIC" ;; *) SHLIB_CFLAGS="-fpic" ;; esac SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' SHLIB_SUFFIX=".so" if test $doRpath = yes; then CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' fi LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}' LDFLAGS="-Wl,-export-dynamic" CFLAGS_OPTIMIZE="-O2" if test "${TCL_THREADS}" = "1"; then # On OpenBSD: Compile with -pthread # Don't link with -lpthread LIBS=`echo $LIBS | sed s/-lpthread//` CFLAGS="$CFLAGS -pthread" |
︙ | ︙ |
Changes to unix/tkUnixFont.c.
︙ | ︙ | |||
1531 1532 1533 1534 1535 1536 1537 | int scalable; unsigned score; if (TkFontParseXLFD(nameList[nameIdx], &got.fa, &got.xa) != TCL_OK) { continue; } IdentifySymbolEncodings(&got); | | | 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 | int scalable; unsigned score; if (TkFontParseXLFD(nameList[nameIdx], &got.fa, &got.xa) != TCL_OK) { continue; } IdentifySymbolEncodings(&got); scalable = (got.fa.size == 0.0); score = RankAttributes(&want, &got); if (score < bestScore[scalable]) { bestIdx[scalable] = nameIdx; bestScore[scalable] = score; } if (score == 0) { break; |
︙ | ︙ | |||
2449 2450 2451 2452 2453 2454 2455 | srcLen = Tcl_UniCharToUtf(ch, src); want.fa = fontPtr->font.fa; want.xa = fontPtr->xa; want.fa.family = Tk_GetUid(faceName); | | | 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 | srcLen = Tcl_UniCharToUtf(ch, src); want.fa = fontPtr->font.fa; want.xa = fontPtr->xa; want.fa.family = Tk_GetUid(faceName); want.fa.size = (double)-fontPtr->pixelSize; hateFoundry = NULL; hateCharset = NULL; numEncodings = 0; Tcl_DStringInit(&dsEncodings); charset = NULL; /* lint, since numNames must be > 0 to get here. */ |
︙ | ︙ | |||
2532 2533 2534 2535 2536 2537 2538 | goto crossout; } /* * D. Rank each name and pick the best match. */ | | | 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 | goto crossout; } /* * D. Rank each name and pick the best match. */ scalable = (got.fa.size == 0.0); score = RankAttributes(&want, &got); if (score < bestScore[scalable]) { bestIdx[scalable] = nameIdx; bestScore[scalable] = score; } if (score == 0) { break; |
︙ | ︙ | |||
2661 2662 2663 2664 2665 2666 2667 | if (gotPtr->xa.slant != wantPtr->xa.slant) { penalty += 10; } if (gotPtr->xa.setwidth != wantPtr->xa.setwidth) { penalty += 1000; } | | | | | 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 | if (gotPtr->xa.slant != wantPtr->xa.slant) { penalty += 10; } if (gotPtr->xa.setwidth != wantPtr->xa.setwidth) { penalty += 1000; } if (gotPtr->fa.size == 0.0) { /* * A scalable font is almost always acceptable, but the corresponding * bitmapped font would be better. */ penalty += 10; } else { int diff; /* * It's worse to be too large than to be too small. */ diff = (int) (150 * (-gotPtr->fa.size - -wantPtr->fa.size)); if (diff > 0) { penalty += 600; } else if (diff < 0) { penalty += 150; diff = -diff; } penalty += diff; } if (gotPtr->xa.charset != wantPtr->xa.charset) { int i; const char *gotAlias, *wantAlias; penalty += 65000; gotAlias = GetEncodingAlias(gotPtr->xa.charset); |
︙ | ︙ |
Changes to unix/tkUnixRFont.c.
︙ | ︙ | |||
178 179 180 181 182 183 184 | &ptsize) == XftResultMatch) { size = ptsize; } else if (XftPatternGetDouble(ftFont->pattern, XFT_PIXEL_SIZE, 0, &ptsize) == XftResultMatch) { size = -ptsize; } else if (XftPatternGetInteger(ftFont->pattern, XFT_PIXEL_SIZE, 0, &pxsize) == XftResultMatch) { | | | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | &ptsize) == XftResultMatch) { size = ptsize; } else if (XftPatternGetDouble(ftFont->pattern, XFT_PIXEL_SIZE, 0, &ptsize) == XftResultMatch) { size = -ptsize; } else if (XftPatternGetInteger(ftFont->pattern, XFT_PIXEL_SIZE, 0, &pxsize) == XftResultMatch) { size = (double)-pxsize; } else { size = 12.0; } if (XftPatternGetInteger(ftFont->pattern, XFT_WEIGHT, 0, &weight) != XftResultMatch) { weight = XFT_WEIGHT_MEDIUM; } |
︙ | ︙ |
Changes to win/tkWinFont.c.
︙ | ︙ | |||
759 760 761 762 763 764 765 | oldfont = SelectObject(hdc, thisSubFontPtr->hFont0); GetTextMetrics(hdc, &tm); SelectObject(hdc, oldfont); ReleaseDC(fontPtr->hwnd, hdc); faPtr->family = familyPtr->faceName; faPtr->size = TkFontGetPoints(tkwin, | | | 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 | oldfont = SelectObject(hdc, thisSubFontPtr->hFont0); GetTextMetrics(hdc, &tm); SelectObject(hdc, oldfont); ReleaseDC(fontPtr->hwnd, hdc); faPtr->family = familyPtr->faceName; faPtr->size = TkFontGetPoints(tkwin, (double)(tm.tmInternalLeading - tm.tmHeight)); faPtr->weight = (tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL; faPtr->slant = tm.tmItalic ? TK_FS_ITALIC : TK_FS_ROMAN; faPtr->underline = (tm.tmUnderlined != 0); faPtr->overstrike = fontPtr->font.fa.overstrike; } /* |
︙ | ︙ | |||
1596 1597 1598 1599 1600 1601 1602 | fontPtr->hwnd = hwnd; fontPtr->pixelSize = tm.tmHeight - tm.tmInternalLeading; faPtr = &fontPtr->font.fa; faPtr->family = Tk_GetUid(Tcl_DStringValue(&faceString)); faPtr->size = | | | 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 | fontPtr->hwnd = hwnd; fontPtr->pixelSize = tm.tmHeight - tm.tmInternalLeading; faPtr = &fontPtr->font.fa; faPtr->family = Tk_GetUid(Tcl_DStringValue(&faceString)); faPtr->size = TkFontGetPoints(tkwin, (double)-(fontPtr->pixelSize)); faPtr->weight = (tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL; faPtr->slant = (tm.tmItalic != 0) ? TK_FS_ITALIC : TK_FS_ROMAN; faPtr->underline = (tm.tmUnderlined != 0) ? 1 : 0; faPtr->overstrike = overstrike; fmPtr = &fontPtr->font.fm; |
︙ | ︙ |