For each letter, we can build a histogram of contexts that letter occurs in for a sufficiently large corpus. An example is the letter "o", whose occurrences in the previous sentence have the following contexts: f_r (twice), t_g, c_n, _c, c_r.
Each letter's context histograms have some similarity with each other letter's. We want different letters that have similar contexts to have widely differing appearances, because if their appearances were similar, their contexts will be of less help to the reader in disambiguating. And letters with sufficiently different contexts may be allowed to be more similar in appearance (note e.g. the archaic long "s", which despite visual ſimilarity to "f" is easily distinguished from it by the different contexts it appears in).