summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2003-08-20 10:26:37 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2003-08-20 10:26:37 (GMT)
commitd6703f5a8c28ebe155adaf2e6ed1bd2882ba2343 (patch)
treef77b4055616a4b07eb16d12a6ec62f37e331b78e
parentb7812a47335ec807df0066262c381e3f5848910c (diff)
downloadtk-d6703f5a8c28ebe155adaf2e6ed1bd2882ba2343.zip
tk-d6703f5a8c28ebe155adaf2e6ed1bd2882ba2343.tar.gz
tk-d6703f5a8c28ebe155adaf2e6ed1bd2882ba2343.tar.bz2
Use Tcl_Obj-based interfaces for working with user-supplied font maps.
-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);