My understanding of how TeX makes things look so nice is that it goes over each paragraph and spaces each letter/word to look 'right' based on how dark it is, how wide it is, and the characteristics of the letters around it.
My question is: How does this work with different typefaces? Each one could have totally different letter sizes and empty space within them and whatnot. Is it based on some trait of the typeface that TeX can determine, such as width? Is it embedded in the fonts file? Or am I giving TeX far too much credit?
I am wondering as I always assumed that this was part of what the packages that I used to activate the font did, but LuaTeX and XeTeX allow you to use TTF and OTF font files, which I'm assuming don't contain anything fancy like this.