Instance Method

convertWeight:ofFont:

Returns an NSFont object whose weight is greater or lesser than that of the given font, if possible.

Declaration

- (NSFont *)convertWeight:(BOOL)upFlag ofFont:(NSFont *)fontObj;

Parameters

increaseFlag

If YES, a heavier font is returned; if it’s NO, a lighter font is returned.

aFont

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

Converting Fonts Manually

- convertFont:toFace:

Returns a font whose traits are as similar as possible to those of the given font except for the typeface, which is changed to the given typeface.

- convertFont:toFamily:

Returns a font whose traits are as similar as possible to those of the given font except for the font family, which is changed to the given family.

- convertFont:toHaveTrait:

Returns a font whose traits are the same as those of the given font, except that the traits are changed to include the single specified trait.

- convertFont:toNotHaveTrait:

Returns an NSFont object with the same traits as the given font, except for the traits in the given font trait mask, which are removed.

- convertFont:toSize:

Returns an NSFont object whose traits are the same as those of the given font, except for the size, which is changed to the given size.

currentFontAction

The current font conversion action.

- convertFontTraits:

Converts font traits to a new traits mask value.