From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- vendor/x11iraf/obm/ObmW/TextWidth.c | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 vendor/x11iraf/obm/ObmW/TextWidth.c (limited to 'vendor/x11iraf/obm/ObmW/TextWidth.c') diff --git a/vendor/x11iraf/obm/ObmW/TextWidth.c b/vendor/x11iraf/obm/ObmW/TextWidth.c new file mode 100644 index 00000000..b213d198 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/TextWidth.c @@ -0,0 +1,39 @@ +#include +#include +#include "TabString.h" + +/* + * Like TextWidth, except it takes an additional "tabs" + * argument, used to specify what horizontal pixel position to + * move to when tab characters are present in the string. If + * the "tabs" argument is NULL, works exactly like its + * counterpart. + */ +int +XfwfTextWidth(font, str, length, tabs) + XFontStruct *font; + String str; + int length; + int *tabs; +{ + register char *p, *ep; + register int tx, tab, rc; + + tab = tx = 0; + if (length == 0) return 0; + for (p = str; length; ) + { + ep = strnchr(p, '\t', length); + if (ep && tabs) + { + tx = tabs[tab++]; + length -= ep - p + 1; + p = ep + 1; + } + else + { + rc = XTextWidth(font, p, length); + if (rc < 0) return rc; else return rc + tx; + } + } +} -- cgit