*** truncate-string-to-width shortens a string, if necessary,
to fit within a certain number of columns. (Of course, it does not alter the string that you give it; it returns a new string which contains all or just part of the existing string.)

(truncate-string-to-width STR END-COLUMN &optional START-COLUMN PADDING)

This returns the part of STR up to column END-COLUMN.

The optional argument START-COLUMN specifies the starting column. If this is non-nil, then the first START-COLUMN columns of the string are not included in the resulting value.

The optional argument PADDING, if non-nil, is a padding character to be added at the beginning and end the resulting string, to extend it to exactly WIDTH columns. If PADDING is nil, that means do not pad; then, if STRING is narrower than WIDTH, the value is equal to STRING.

If PADDING and START-COLUMN are both non-nil, and if there is no clean place in STRING that corresponds to START-COLUMN (because one character extends across that column), then the padding character PADDING is added one or more times at the beginning of the result string, so that its columns line up as if it really did start at column START-COLUMN.