From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/gio/stdgraph/stgtxsize.x | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 sys/gio/stdgraph/stgtxsize.x (limited to 'sys/gio/stdgraph/stgtxsize.x') 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 +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 -- cgit