aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/stdgraph/stgtxsize.x
diff options
context:
space:
mode:
Diffstat (limited to 'sys/gio/stdgraph/stgtxsize.x')
-rw-r--r--sys/gio/stdgraph/stgtxsize.x31
1 files changed, 31 insertions, 0 deletions
diff --git a/sys/gio/stdgraph/stgtxsize.x b/sys/gio/stdgraph/stgtxsize.x
new file mode 100644
index 00000000..71829e04
--- /dev/null
+++ b/sys/gio/stdgraph/stgtxsize.x
@@ -0,0 +1,31 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <gki.h>
+include "stdgraph.h"
+
+# STG_TXSIZE -- Given the relative character size as a packed real, select
+# the discreet closest device character size.
+
+int procedure stg_txsize (pksize)
+
+int pksize # packed real relative character size
+int i, best_size
+real txsize, diff, least_diff
+include "stdgraph.com"
+
+begin
+ txsize = GKI_UNPACKREAL (pksize)
+
+ best_size = 1
+ least_diff = abs (txsize - SG_CHARSIZE(g_sg,1))
+
+ do i = 2, SG_NCHARSIZES(g_sg) {
+ diff = abs (txsize - SG_CHARSIZE(g_sg,i))
+ if (diff < least_diff) {
+ best_size = i
+ least_diff = diff
+ }
+ }
+
+ return (best_size)
+end