mysterious behavior of system font metrics
mysterious behavior of system font metrics
- Subject: mysterious behavior of system font metrics
- From: Alan Snyder <email@hidden>
- Date: Wed, 28 Oct 2015 12:17:09 -0700
I am using some code (Java) that assumes it is OK to create a size 1 font and then scale-transform it to render other font sizes.
I would not expect this to work with Yosemite system fonts, but most of the time it works better than expected. But sometimes it does not.
(The expected problem is that the glyph spacing is too large. That result is expected because the advance widths of a 12 point system font are smaller than 12 times the advance widths of a 1 point system font.)
The mysterious behavior that I observe is that the result of [NSFont systemFontOfSize:1] can change over time. For example:
2015-10-28 10:22:15.033 java[19620:15284886] ".HelveticaNeueDeskInterface-Regular 1.00 pt. P [] (0x7f8232e2a460) fobj=0x7f8232e2a2e0, spc=0.36"
2015-10-28 10:22:15.193 java[19620:15284886] ".HelveticaNeueDeskInterface-Regular 1.00 pt. P [] (0x7f8232e2a460) fobj=0x7f823504b5b0, spc=0.36"
2015-10-28 10:22:15.257 java[19620:15284886] ".HelveticaNeueDeskInterface-Regular 1.00 pt. P [] (0x7f8232e2a460) fobj=0x7f8232d157a0, spc=0.28"
Note that the space width changes from 0.36 (the normal value) to 0.28 (a value that works much better when scaled to 12 points).
Whether this change happens or not seems to depend upon the order in which things are done in the program, but I have not been able to pin down the exact difference.
I’ll take a wild guess — is there code in Cocoa that tries to identify apps that scale system fonts and alters the 1 point font to make scaling work better?
If so, is there a reliable way to make this happen? The problem I am having is that sometimes this does not happen.
(In case it is not obvious, I am not in a position to change how Java uses Cocoa fonts.)
Alan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden