summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <dkf@noemail.net>2003-08-20 10:26:37 (GMT)
committerdkf <dkf@noemail.net>2003-08-20 10:26:37 (GMT)
commit627a86bcfe8ccbd28ffb27b2f01bbc779ccd0877 (patch)
treef77b4055616a4b07eb16d12a6ec62f37e331b78e
parentd2f61c13f622c5f8c6e2f5ac2249d48ffdbd316a (diff)
downloadtk-627a86bcfe8ccbd28ffb27b2f01bbc779ccd0877.zip
tk-627a86bcfe8ccbd28ffb27b2f01bbc779ccd0877.tar.gz
tk-627a86bcfe8ccbd28ffb27b2f01bbc779ccd0877.tar.bz2
Use Tcl_Obj-based interfaces for working with user-supplied font maps.
FossilOrigin-Name: fbaf06b4fd742ec373d5c508b3f162c38935b8fb
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkCanvPs.c51
2 files changed, 29 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index f29d830..2d7acce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-08-20 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+
+ * generic/tkCanvPs.c (Tk_PostscriptFont): Use Tcl_Obj-based
+ interfaces for working with user-supplied font maps.
+
2003-08-19 Joe English <jenglish@users.sourceforge.net>
* generic/tkPanedWindow.c(PanedWindowWorldChanged):
Set window background from the -background resource.
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c
index e987b5d..e786a14 100644
--- a/generic/tkCanvPs.c
+++ b/generic/tkCanvPs.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: tkCanvPs.c,v 1.13 2003/02/18 21:54:18 hobbs Exp $
+ * RCS: @(#) $Id: tkCanvPs.c,v 1.14 2003/08/20 10:26:38 dkf Exp $
*/
#include "tkInt.h"
@@ -736,7 +736,6 @@ Tk_PostscriptFont(interp, psInfo, tkfont)
* is to be printed. */
{
TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo;
- char *end;
char pointString[TCL_INTEGER_SPACE];
Tcl_DString ds;
int i, points;
@@ -747,44 +746,42 @@ Tk_PostscriptFont(interp, psInfo, tkfont)
* containing font name and size. Use this information.
*/
- Tcl_DStringInit(&ds);
-
if (psInfoPtr->fontVar != NULL) {
- CONST char *list;
- int argc;
+ CONST char *name = Tk_NameOfFont(tkfont);
+ Tcl_Obj **objv;
+ int objc;
double size;
- CONST char **argv;
- CONST char *name;
+ Tcl_Obj *list = Tcl_GetVar2Ex(interp, psInfoPtr->fontVar, name, 0);
- name = Tk_NameOfFont(tkfont);
- list = Tcl_GetVar2(interp, psInfoPtr->fontVar, name, 0);
if (list != NULL) {
- if (Tcl_SplitList(interp, list, &argc, &argv) != TCL_OK) {
- badMapEntry:
+ CONST char *fontname;
+ if (Tcl_ListObjGetElements(interp, list, &objc, &objv) != TCL_OK
+ || objc != 2
+ || Tcl_GetString(objv[0])[0]=='\0'
+ || Tcl_GetDoubleFromObj(interp, objv[1], &size) != TCL_OK
+ || size <= 0) {
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "bad font map entry for \"", name,
- "\": \"", list, "\"", (char *) NULL);
+ "\": \"", Tcl_GetString(list), "\"", (char *) NULL);
return TCL_ERROR;
}
- if (argc != 2) {
- goto badMapEntry;
- }
- size = strtod(argv[1], &end);
- if ((size <= 0) || (*end != 0)) {
- goto badMapEntry;
- }
- Tcl_DStringAppend(&ds, argv[0], -1);
- points = (int) size;
-
- ckfree((char *) argv);
- goto findfont;
+ fontname = Tcl_GetString(objv[0]);
+ sprintf(pointString, "%d", (int)size);
+
+ Tcl_AppendResult(interp, "/", fontname, " findfont ",
+ pointString, " scalefont ", NULL);
+ if (strncasecmp(fontname, "Symbol", 7) != 0) {
+ Tcl_AppendResult(interp, "ISOEncode ", (char *) NULL);
+ }
+ Tcl_AppendResult(interp, "setfont\n", (char *) NULL);
+ Tcl_CreateHashEntry(&psInfoPtr->fontTable, fontname, &i);
+ return TCL_OK;
}
}
+ Tcl_DStringInit(&ds);
points = Tk_PostscriptFontName(tkfont, &ds);
-
- findfont:
sprintf(pointString, "%d", points);
Tcl_AppendResult(interp, "/", Tcl_DStringValue(&ds), " findfont ",
pointString, " scalefont ", (char *) NULL);