Figure 6.1 on this page shows the font metrics you can get from an NSFont: https://developer.apple.com/library/archive/documentation/TextFonts/Conceptual/CocoaTextArchitecture/FontHandling/FontHandling.html
If I create an Arial font with a size of 256, I get the following values:
nsfont pointSize 256
nsfont ascender 231.75
nsfont descender -54.25
nsfont leading 8.375
nsfont capHeight 183.375
nsfont xHeight 132.75
I don't understand how the font size (256) relates to the metrics. I would have expected the font size to be equal to the ascent plus the descent or maybe equal to the Cap height. Thank you for any help.
Let's take a look at the Arial font on macOS. Open it with FontForge (or any other tool) and look at metrics.
Simplified explanation:
How does macOS get all these values you listed:
I would have expected the font size to be equal to the ascent plus the descent or maybe equal to the Cap height.
Nope. When you ask for 256pt font size you're basically saying that you'd like to scale Em size container to 256pt. And everything else depends on metrics in the font itself. This vary a lot per font.