Legibility in writing systems emerges spontaneously, rather than evolving over time

The visual appearance of most scripts corresponds with the basic constraints of the human visual system, thus facilitating the perception and processing of letters. For example, cardinals (horizontal and vertical lines) are more numerous than oblique lines. But how did it happen? Has the legibility of writing systems gradually evolved through cultural transformation or cultural selection? Or do human cognitive preferences directly affect the shape of the characters?