API 0.9.5
CPFont Class Reference

#import <CPFont.h>

Inheritance diagram for CPFont:

List of all members.

Instance Methods

(float) - ascender
(id) - copy
(CPString- cssString
(float) - defaultLineHeightForFont
(float) - descender
(CPString- description
(void) - encodeWithCoder:
(CPString- familyName
(id) - initWithCoder:
(BOOL) - isBold
(BOOL) - isEqual:
(BOOL) - isItalic
(float) - size

Class Methods

(CPFont+ boldFontWithName:size:
(CPFont+ boldFontWithName:size:italic:
(CPFont+ boldSystemFontOfSize:
(CPFont+ fontWithName:size:
(CPFont+ fontWithName:size:italic:
(void) + initialize
(CPString+ setSystemFontFace:
(float) + setSystemFontSize:
(CPString+ systemFontFace
(CPFont+ systemFontOfSize:
(float) + systemFontSize

Detailed Description

The CPFont class allows control of the fonts used for displaying text anywhere on the screen. The primary method for getting a particular font is through one of the class methods that take a name and/or size as arguments, and return the appropriate CPFont.

By default the system font face/size is Arial 12px, with a fallback to sans-serif. You may configure this at runtime in two ways:

  • By sending [CPFont setSystemFontFace:] and/or [CPFont setSystemFontSize:].
  • By configuring Info.plist for your application or for AppKit. You can set the font face by adding a CPSystemFontFace string item to the Info.plist, and you can set the font size by adding a CPSystemFontSize integer item to the Info.plist.

Note that in either case, you can specify a comma-delimited list of fonts as the font face. The browser will use the first available font in the list. CPFont always ensures that Arial and sans-serif are in the generated CSS string, so there is no need to add them to the end of your font list.

If you are using nib2cib, you should use the second method (using Info.plist), and be sure to run nib2cib again any time you modify the CPSystemFontFace or CPSystemFontSize items. For example, you might add this to your application's Info.plist to set the system font to Lucida Grande, with an automatic fallback to Arial or sans-serif:

<key>CPSystemFontFace</key>
<string>Lucida Grande</string>

Definition at line 2 of file CPFont.h.


Method Documentation

- (float) ascender

Returns the distance of the longest ascender's top y-coordinate from the baseline (in CSS px)

Definition at line 233 of file CPFont.j.

+ (CPFont) boldFontWithName: (CPString aName
size: (float)  aSize 

Returns a bold font with the specified name and size.

Parameters:
aNamethe name of the font
aSizethe size of the font (in px)
Returns:
the requested bold font

Definition at line 163 of file CPFont.j.

+ (CPFont) boldFontWithName: (CPString aName
size: (float)  aSize
italic: (BOOL)  italic 

Returns a bold font with the specified name, size and style.

Parameters:
aNamethe name of the font
aSizethe size of the font (in px)
italicwhether the font should be italicized
Returns:
the requested font

Definition at line 175 of file CPFont.j.

+ (CPFont) boldSystemFontOfSize: (CPSize)  aSize

Returns the bold system font scaled to the specified size

Parameters:
aSizethe size of the font (in px)
Returns:
the requested bold system font

Definition at line 195 of file CPFont.j.

- (id) copy

Definition at line 300 of file CPFont.j.

- (CPString) cssString

Returns the font as a CSS string

Definition at line 277 of file CPFont.j.

- (float) defaultLineHeightForFont

Returns the default line height.

NOTE: This was moved from NSFont to NSLayoutManager in Cocoa, but since there is no CPLayoutManager, it has been kept here.

Definition at line 258 of file CPFont.j.

- (float) descender

Returns the bottom y coordinate (in CSS px), offset from the baseline, of the receiver's longest descender. Thus, if the longest descender extends 2 px below the baseline, descender will return –2.

Definition at line 245 of file CPFont.j.

- (CPString) description

Definition at line 295 of file CPFont.j.

- (void) encodeWithCoder: (CPCoder aCoder

Writes the font information out to a coder.

Parameters:
aCoderthe coder to which the data will be written

Definition at line 342 of file CPFont.j.

- (CPString) familyName

Returns the font's family name

Definition at line 285 of file CPFont.j.

+ (CPFont) fontWithName: (CPString aName
size: (float)  aSize 

Returns a font with the specified name and size.

Parameters:
aNamethe name of the font
aSizethe size of the font (in px)
Returns:
the requested font

Definition at line 140 of file CPFont.j.

+ (CPFont) fontWithName: (CPString aName
size: (float)  aSize
italic: (BOOL)  italic 

Returns a font with the specified name, size and style.

Parameters:
aNamethe name of the font
aSizethe size of the font (in px)
italicwhether the font should be italicized
Returns:
the requested font

Definition at line 152 of file CPFont.j.

+ (void) initialize

Definition at line 82 of file CPFont.j.

- (id) initWithCoder: (CPCoder aCoder

Initializes the font from a coder.

Parameters:
aCoderthe coder from which to read the font data
Returns:
the initialized font

Definition at line 328 of file CPFont.j.

- (BOOL) isBold

Synthesized accessor method.

Definition at line 400 of file CPFont.j.

- (BOOL) isEqual: (id)  anObject

Definition at line 290 of file CPFont.j.

- (BOOL) isItalic

Synthesized accessor method.

Definition at line 408 of file CPFont.j.

+ (CPString) setSystemFontFace: (CPString aFace

Sets the default system font face, which may consist of several comma-separated family names.

Definition at line 112 of file CPFont.j.

+ (float) setSystemFontSize: (float)  size

Sets the default system font size.

Definition at line 128 of file CPFont.j.

- (float) size

Returns the font size (in CSS px)

Definition at line 269 of file CPFont.j.

+ (CPString) systemFontFace

Returns the default system font face, which may consist of several comma-separated family names.

Definition at line 104 of file CPFont.j.

+ (CPFont) systemFontOfSize: (CPSize)  aSize

Returns the system font scaled to the specified size

Parameters:
aSizethe size of the font (in px)
Returns:
the requested system font

Definition at line 185 of file CPFont.j.

+ (float) systemFontSize

Returns the default system font size.

Definition at line 120 of file CPFont.j.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Defines