fabien van mook

all packages "fvm-*"

package "fvm-textblock"

function file "textblockalign.m"

Function s = textblockalign(s)
         s = textblockalign(s,opt)

aligns each individual line in the given string, and
returns the resulting string. The function does not change
line-breaking!

The input argument s is a character row vector or a
cell-array of character row vectors. The output argument
will have the same form as the input argument s.

The optional input arugment opt is a struct or a row
cell-array of key-value pairs. Below, settings are
indicated by opt as a struct, and the default value of
each field are given too:

  opt.align1 = "l+";
    opt.align1 has one of the values "l", "l+", "c", "c+"
    or "r" for left, centre and right alignment,
    respectively. The plus "+" sign indicates to fill with
    opt.fillchar until the line counts opt.minwidth1
    characters. opt.align1 is applied on the first line
    only.

  opt.minwidth1 = 20;
    opt.minwidth1 indicates the minimal number of
    characters on the first line.

  opt.align2 = "l+";
    opt.align2 is similar to opt.align1, but is applied
    on the second and following lines.

  opt.minwidth2 = 20;
    opt.minwidth2 indicates the minimal number of
    characters on the second or a following line.

  opt.linedelim = "\n";
    opt.linedelim contains the line delimiter, i.e. the
    character by which lines are separated within a
    string.

  opt.fillchar = " ";
    opt.fillchar contains the character which is inserted
    to get the desired alignment or line-filling. If
    opt.fillchar contains more than one character, it is
    repeated and clipped (!) to get the exact number of
    characters needed in the insertion or filling.

The function takes care of the utf-8 encoding of strings,
and accounts for the real number of characters instead of
simply counting the number of bytes in a string.

The function internally calls the following non-standard
m-files:
-- kvpairs2struct.m
-- unicodelength.m
-- repmatfit.m


(c) 2026 fabien van mook

2026.08.20 release of this file within package "fvm-textblock" under GNU GPLv3+