Contents

convertWeight(_:of:)

Returns a font object whose weight is greater or lesser than that of the given font.

Declaration

func convertWeight(_ upFlag: Bool, of fontObj: NSFont) -> NSFont

Parameters

  • upFlag:

    If True, a heavier font is returned; if it’s False, a lighter font is returned.

  • fontObj:

    The font whose weight is increased or decreased.

Return Value

A font with matching traits except for the new weight, or aFont if it can’t be converted.

Discussion

Weights are graded along the following scale. The list on the left gives Apple’s terminology, and the list on the right gives the ISO equivalents. Names on the same line are treated as identical:

Apple Terminology

ISO Equivalent

1. ultralight

2. thin

W1. ultralight

3. light, extralight

W2. extralight

4. book

W3. light

5. regular, plain, display, roman

W4. semilight

6. medium

W5. medium

7. demi, demibold

8. semi, semibold

W6. semibold

9. bold

W7. bold

10. extra, extrabold

W8. extrabold

11. heavy, heavyface

12. black, super

W9. ultrabold

13. ultra, ultrablack, fat

14. extrablack, obese, nord

The NSFontManager implementation of this method refuses to convert a font’s weight if it can’t maintain all other traits, such as italic and condensed. You might wish to override this method to allow a looser interpretation of weight conversion.

See Also

Related Documentation

Converting Fonts Manually