|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T X
Length: 1314 (0x522) Types: TextFile Names: »XStringWidth.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─⟦526ad3590⟧ »EUUGD11/gnu-31mar87/X.V10.R4.tar.Z« └─⟦2109abc41⟧ └─⟦this⟧ »./X.V10R4/Xlib/XStringWidth.c«
#include <X/mit-copyright.h> /* $Header: XStringWidth.c,v 10.4 86/02/01 15:40:32 tony Rel $ */ /* Copyright Massachusetts Institute of Technology 1985 */ #include "XlibInternal.h" int XStringWidth (string, info, charpad, spacepad) register char *string; register FontInfo *info; register int charpad, spacepad; { register int result = 0; if (!*string) /* zero length string */ return (0); if (info->fixedwidth) { int length = strlen (string); result = length * (info->width + charpad) - charpad; /* don't pad last character */ if (spacepad) { char *sub = string, *index(); while (sub = index (sub, ' ')) { result += spacepad; sub++; } if (string[length-1] == ' ') result -= spacepad; /* don't pad terminating space character */ } } else { /* variable width font */ unsigned char c; register short *widths = info->widths - info->firstchar; while (c = *(string++)) { if ((c >= info->firstchar) && (c <= info->lastchar)) result += (widths[c] + charpad); if (c == ' ') result += spacepad; } result -= charpad; /* don't pad last character */ if (*(string-1) == ' ') result -= spacepad; /* don't pad terminating space character */ } return (result); }