Both GDI and Pango have a list of canonical font weights that go in the range "thin, extra light, light, normal, medium, semibold, bold, extra bold, heavy". It appears CSS does too.
However, I don't see such a font list for Core Text (or even NSFont/NSFontDescriptor) on OS X. Instead, what I see is
kCTFontWeightTrait
, which is documented as going from -1.0 to 1.0 with 0.0 being "regular or medium" (so both normal and medium or just medium?), and-[NSFontManager fontWithFamily:traits:weight:size:]
, whose weight parameter is documented as going from 0 to 15 with 5 being normal/book (which I assume is between light and normal, if not normal) and 9 and higher all being boldSo what are the equivalents of the above canonical weight names? Thanks.
The canonical names are given in the headers:
APPKIT_EXTERN const CGFloat NSFontWeightUltraLight NS_AVAILABLE_MAC(10_11);
APPKIT_EXTERN const CGFloat NSFontWeightThin NS_AVAILABLE_MAC(10_11);
APPKIT_EXTERN const CGFloat NSFontWeightLight NS_AVAILABLE_MAC(10_11);
APPKIT_EXTERN const CGFloat NSFontWeightRegular NS_AVAILABLE_MAC(10_11);
APPKIT_EXTERN const CGFloat NSFontWeightMedium NS_AVAILABLE_MAC(10_11);
APPKIT_EXTERN const CGFloat NSFontWeightSemibold NS_AVAILABLE_MAC(10_11);
APPKIT_EXTERN const CGFloat NSFontWeightBold NS_AVAILABLE_MAC(10_11);
APPKIT_EXTERN const CGFloat NSFontWeightHeavy NS_AVAILABLE_MAC(10_11);
APPKIT_EXTERN const CGFloat NSFontWeightBlack NS_AVAILABLE_MAC(10_11);
To learn their values, just log each one in turn.
NSLog(@"%f", NSFontWeightUltraLight);
NSLog(@"%f", NSFontWeightThin);
// ... need I go on?