summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-15 14:56:05 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-15 14:56:05 (GMT)
commitbb089fa3ae014082fd1642a5c932f8c0c7422924 (patch)
treee917ce2bb4fc8961d0de782ce87d967679bb4de5 /generic
parentc257b74035bb102d5860b77c9484c8e7e5ee833c (diff)
downloadtk-bb089fa3ae014082fd1642a5c932f8c0c7422924.zip
tk-bb089fa3ae014082fd1642a5c932f8c0c7422924.tar.gz
tk-bb089fa3ae014082fd1642a5c932f8c0c7422924.tar.bz2
Another attempt to fix [434d294df8b053246ee86e7898d06bc3a6d1d771|434d294df8], this time (hopefully) suitable for 8.6. (less changes than the original attempt)
Diffstat (limited to 'generic')
-rw-r--r--generic/tkCanvPs.c2
-rw-r--r--generic/tkFont.c36
-rw-r--r--generic/tkFont.h6
3 files changed, 23 insertions, 21 deletions
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c
index c6470dd..2bfdcc5 100644
--- a/generic/tkCanvPs.c
+++ b/generic/tkCanvPs.c
@@ -825,7 +825,7 @@ Tk_PostscriptFont(
fontname = Tcl_DStringValue(&ds);
Tcl_AppendPrintfToObj(GetPostscriptBuffer(interp),
"/%s findfont %d scalefont%s setfont\n",
- fontname, TkFontGetPoints(psInfoPtr->tkwin, points),
+ fontname, (int)(TkFontGetPoints(psInfoPtr->tkwin, points) + 0.5),
strncasecmp(fontname, "Symbol", 7) ? " ISOEncode" : "");
Tcl_CreateHashEntry(&psInfoPtr->fontTable, Tcl_DStringValue(&ds), &i);
Tcl_DStringFree(&ds);
diff --git a/generic/tkFont.c b/generic/tkFont.c
index bec8807..9a70a65 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -1228,7 +1228,7 @@ Tk_AllocFontFromObj(
descent = fontPtr->fm.descent;
fontPtr->underlinePos = descent / 2;
- fontPtr->underlineHeight = TkFontGetPixels(tkwin, fontPtr->fa.size) / 10;
+ fontPtr->underlineHeight = (int) (TkFontGetPixels(tkwin, fontPtr->fa.size) / 10 + 0.5);
if (fontPtr->underlineHeight == 0) {
fontPtr->underlineHeight = 1;
}
@@ -3375,6 +3375,7 @@ ConfigAttributesObj(
int i, n, index;
Tcl_Obj *optionPtr, *valuePtr;
const char *value;
+ double d;
for (i = 0; i < objc; i += 2) {
optionPtr = objv[i];
@@ -3406,10 +3407,10 @@ ConfigAttributesObj(
faPtr->family = Tk_GetUid(value);
break;
case FONT_SIZE:
- if (Tcl_GetIntFromObj(interp, valuePtr, &n) != TCL_OK) {
+ if (Tcl_GetDoubleFromObj(interp, valuePtr, &d) != TCL_OK) {
return TCL_ERROR;
}
- faPtr->size = n;
+ faPtr->size = d;
break;
case FONT_WEIGHT:
n = TkFindStateNumObj(interp, optionPtr, weightMap, valuePtr);
@@ -3500,7 +3501,7 @@ GetAttributeInfoObj(
break;
case FONT_SIZE:
- valuePtr = Tcl_NewIntObj(faPtr->size);
+ valuePtr = Tcl_NewDoubleObj(faPtr->size);
break;
case FONT_WEIGHT:
@@ -3646,10 +3647,11 @@ ParseFontNameObj(
faPtr->family = Tk_GetUid(Tcl_GetString(objv[0]));
if (objc > 1) {
- if (Tcl_GetIntFromObj(interp, objv[1], &n) != TCL_OK) {
+ double d;
+ if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
return TCL_ERROR;
}
- faPtr->size = n;
+ faPtr->size = d;
}
i = 2;
@@ -3893,7 +3895,7 @@ TkFontParseXLFD(
* historical compatibility.
*/
- faPtr->size = 12;
+ faPtr->size = 12.0;
if (FieldSpecified(field[XLFD_POINT_SIZE])) {
if (field[XLFD_POINT_SIZE][0] == '[') {
@@ -3907,8 +3909,8 @@ TkFontParseXLFD(
* the purpose of, so I ignore them.
*/
- faPtr->size = atoi(field[XLFD_POINT_SIZE] + 1);
- } else if (Tcl_GetInt(NULL, field[XLFD_POINT_SIZE],
+ faPtr->size = atof(field[XLFD_POINT_SIZE] + 1);
+ } else if (Tcl_GetDouble(NULL, field[XLFD_POINT_SIZE],
&faPtr->size) == TCL_OK) {
faPtr->size /= 10;
} else {
@@ -3932,8 +3934,8 @@ TkFontParseXLFD(
* ignore them.
*/
- faPtr->size = atoi(field[XLFD_PIXEL_SIZE] + 1);
- } else if (Tcl_GetInt(NULL, field[XLFD_PIXEL_SIZE],
+ faPtr->size = atof(field[XLFD_PIXEL_SIZE] + 1);
+ } else if (Tcl_GetDouble(NULL, field[XLFD_PIXEL_SIZE],
&faPtr->size) != TCL_OK) {
return TCL_ERROR;
}
@@ -4010,10 +4012,10 @@ FieldSpecified(
*---------------------------------------------------------------------------
*/
-int
+double
TkFontGetPixels(
Tk_Window tkwin, /* For point->pixel conversion factor. */
- int size) /* Font size. */
+ double size) /* Font size. */
{
double d;
@@ -4024,7 +4026,7 @@ TkFontGetPixels(
d = size * 25.4 / 72.0;
d *= WidthOfScreen(Tk_Screen(tkwin));
d /= WidthMMOfScreen(Tk_Screen(tkwin));
- return (int) (d + 0.5);
+ return d;
}
/*
@@ -4044,10 +4046,10 @@ TkFontGetPixels(
*---------------------------------------------------------------------------
*/
-int
+double
TkFontGetPoints(
Tk_Window tkwin, /* For pixel->point conversion factor. */
- int size) /* Font size. */
+ double size) /* Font size. */
{
double d;
@@ -4058,7 +4060,7 @@ TkFontGetPoints(
d = -size * 72.0 / 25.4;
d *= WidthMMOfScreen(Tk_Screen(tkwin));
d /= WidthOfScreen(Tk_Screen(tkwin));
- return (int) (d + 0.5);
+ return d;
}
/*
diff --git a/generic/tkFont.h b/generic/tkFont.h
index b8de885..de479bf 100644
--- a/generic/tkFont.h
+++ b/generic/tkFont.h
@@ -23,7 +23,7 @@
struct TkFontAttributes {
Tk_Uid family; /* Font family, or NULL to represent plaform-
* specific default system font. */
- int size; /* Pointsize of font, 0 for default size, or
+ double size; /* Pointsize of font, 0.0 for default size, or
* negative number meaning pixel size. */
int weight; /* Weight flag; see below for def'n. */
int slant; /* Slant flag; see below for def'n. */
@@ -198,8 +198,8 @@ MODULE_SCOPE int TkFontParseXLFD(const char *string,
TkFontAttributes *faPtr, TkXLFDAttributes *xaPtr);
MODULE_SCOPE const char *const * TkFontGetAliasList(const char *faceName);
MODULE_SCOPE const char *const *const * TkFontGetFallbacks(void);
-MODULE_SCOPE int TkFontGetPixels(Tk_Window tkwin, int size);
-MODULE_SCOPE int TkFontGetPoints(Tk_Window tkwin, int size);
+MODULE_SCOPE double TkFontGetPixels(Tk_Window tkwin, double size);
+MODULE_SCOPE double TkFontGetPoints(Tk_Window tkwin, double size);
MODULE_SCOPE const char *const * TkFontGetGlobalClass(void);
MODULE_SCOPE const char *const * TkFontGetSymbolClass(void);
MODULE_SCOPE int TkCreateNamedFont(Tcl_Interp *interp, Tk_Window tkwin,