Calculating text width programmatically
There are times when you need to calculate the width of a string of text but do not have access to a text rendering engine.
Letters in a (non-monospaced) font all take up different widths so at minimum we have to build a map of all the available characters we will need. After that there is the complexity of taking into account kerning, this is where certain character pairs are specifically moved closer or further from each other to improve the look of the font.