I'm trying to programmatically get the width of a character in Mathematica's default fixed-width font, Courier. I believe
CurrentValue holds the answer but I'm having trouble understanding correct usage.
In:= CurrentValue[$FrontEnd, FontFamily] Out= "Times"
Example 1: Expected Courier, since input is typed in Courier.
In:= s = Style["Confusion", FontFamily -> "Times"]; CurrentValue[s, FontFamily] Out= "Courier"
Example 2: Expected Times, since I specifically chose that font family for
In:= CurrentValue[s, "FontMWidth"] / CurrentValue[s, "FontNWidth"] Out= 2.
Example 3: Expected exactly 1, since since all letters should be equally wide in Courier.
In:= CurrentValue[$FrontEnd, "FontMWidth"] / CurrentValue[$FrontEnd, "FontNWidth"] Out= 2.
Example 4: Expected about 1.2, based on a quick measurement of the width ratio of Times' M to N.
A prior question about fonts and CurrentValue has an example of using
DynamicWrapper to get information out of dynamic objects, but I'm still curious how to use
CurrentValue correctly in non-dynamic settings, and why the ratio of
FontMWidth/FontNWidth is always 2.
I'm on Mac OS X 10.8.5 and Mathematica 220.127.116.11.