| Framework | CommonPanels.framework |
| Declared in | FontPanel.h |
The Fonts Panel programming interface is a collection of functions and data types that support the use of a Fonts panel in a Carbon application. The Fonts panel is the preferred user interface for fonts in Mac OS X.
Checks whether the Fonts panel is visible.
Boolean FPIsFontPanelVisible ( void );
Returns true if the Fonts panel is visible; false otherwise. See the Mac Types documentation for a description of the Boolean data type.
FontPanel.h
Shows or hides the Fonts panel.
OSStatus FPShowHideFontPanel ( void );
A result code. See “Fonts Panel Results Codes.”
The function FPShowHideFontPanel shows the Fonts panel if the panel is not visible and hides the Fonts panel if the panel is visible.
FontPanel.h
Sets the selections that appear in the Fonts panel.
OSStatus SetFontInfoForSelection ( OSType iStyleType, UInt32 iNumStyles, void *iStyles, EventTargetRef iFPEventTarget );
The type of style data you are passing to the Fonts panel. Pass kFontSelectionQDType if you supply a FontSelectionQDStyle data structure in the iStyles parameter. Pass kFontSelectionATSUIType if you supply ATSUStyle data in the iStyles parameter.
The number of styles passed in the iStyles parameter.
A pointer to an array of data structures that correspond to the style type specified by the iStyleType parameter.
The event target you want to receive the Carbon event kEventFontSelection that is associated with the Fonts panel. You typically specify the event target for the window that is sending the style selection to the Fonts panel.
A result code. See “Fonts Panel Results Codes.”
You can programmatically set a selection in the Fonts panel by calling the function SetFontInfoForSelection. You can call this function even when the Fonts panel is not open or visible. When the Fonts panel becomes visible later, the style information specified in the most recent call to SetFontInfoForSelection is selected in the panel.
FontPanel.hContains QuickDraw style font information.
struct FontSelectionQDStyle {
UInt32 version;
FMFontFamilyInstance instance;
FMFontSize size;
Boolean hasColor;
UInt8 reserved;
RGBColor color;
};
typedef struct FontSelectionQDStyle FontSelectionQDStyle;
typedef FontSelectionQDStyle * FontSelectionQDStylePtr;
versionSpecifies the version number of the data structure.
instanceSpecifies a font family instance.
sizeSpecifies the font size in points.
hasColorSpecifies whether the font has a color other than black.
reservedReserved for future use.
colorSpecifies the font color.
You should use this data structure to specify QuickDraw-style font information when you call the function SetFontInfoForSelection. When you use this data structure, you must pass the constant kFontSelectionQDType in the iStyleType parameter of the function.
FontPanel.h
A pointer to a data structure that contains QuickDraw style font information.
typedef FontSelectionQDStyle * FontSelectionQDStylePtr;
See FontSelectionQDStyle for more information.
FontPanel.hSpecifies a Carbon event related to font selection or handling.
enum {
kEventClassFont = 'font'
};
kEventClassFontSpecifies a Carbon event related to font selection or handling.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
FontPanel.h
Specify a Fonts panel Carbon event.
enum {
kEventFontPanelClosed = 1,
kEventFontSelection = 2
};
kEventFontPanelClosedSpecifies a close event in the Fonts panel. Your application should update the user interface as necessary. For example, you may need to change a Hide Fonts Panel menu command to Show Fonts Panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
kEventFontSelectionSpecifies a selection event in the Fonts panel. Your application can obtain the selections from the event parameters associated with this event. Your application must check for all those parameters it handles and apply the selections to the text.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
When the user closes the Fonts panel, the action generates the Carbon event kEventWindowClosed. You can then update any menu items or other controls whose state may need to change. The event kEventWindowClosed has no parameters. However, when the user selects an item in the Fonts panel, the system sends the Carbon event kEventFontSelection to the event target you specified when your application called the Fonts Panel function SetFontInfoForSelection. The event kEventFontSelection has parameters that reflect the current Fonts panel selection.
FontPanel.h
Specify the type of font information.
enum {
kFontSelectionATSUIType = 'astl',
kFontSelectionQDType = 'qstl'
};
kFontSelectionATSUITypeSpecifies ATSUI data (ATSUStyle).
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
kFontSelectionQDTypeSpecifies QuickDraw data (FontSelectionQDStyle).
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
These constants specify the type of font information passed to the function SetFontInfoForSelection.
FontPanel.h
Specify the supported versions of the FontSelectionQDStyle data structure.
enum {
kFontSelectionQDStyleVersionZero = 0
};
kFontSelectionQDStyleVersionZeroSpecifies version 0 of a QuickDraw font selection.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
You should always set the version field in the FontSelectionQDStyle data structure to this constant
FontPanel.h
Specifies the four-character code for the show/hide Fonts panel command.
enum {
kHICommandShowHideFontPanel = 'shfp'
};
kHICommandShowHideFontPanelSpecifies the four-character code for the show/hide Fonts panel command.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
If the user closes the Fonts panel directly, your application receives a kEventFontPanelClosed Carbon event. You can then call the Carbon Event Manager function GetEventParameter to extract the HI command from the event.
FontPanel.h
Specify font event parameters and their associated data types.
enum {
typeATSUFontID = typeUInt32,
typeATSUSize = typeFixed,
typeFMFontFamily = typeSInt16,
typeFMFontStyle = typeSInt16,
typeFMFontSize = typeSInt16,
typeFontColor = typeRGBColor,
kEventParamATSUFontID = 'auid',
kEventParamATSUFontSize = 'ausz',
kEventParamFMFontFamily = 'fmfm',
kEventParamFMFontStyle = 'fmst',
kEventParamFMFontSize = 'fmsz',
kEventParamFontColor = 'fclr'
};
typeATSUFontIDSpecifies that an ATSUFontID is of type UInt32.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
typeATSUSizeSpecifies that an ATSUSize is of type Fixed.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
typeFMFontFamilySpecifies that an FMFontFamily is of type SInt16.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
typeFMFontStyleSpecifies that an FMFontStyle is of type SInt16.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
typeFMFontSizeSpecifies that an FMFontSize is of type SInt16.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
typeFontColorSpecifies that a font color is of type RGBColor.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
kEventParamATSUFontIDSpecifies the four-character code associated with an ATSUFontID selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
kEventParamATSUFontSizeSpecifies the four-character code associated with an ATSUFontSize selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
kEventParamFMFontFamilySpecifies the four-character code associated with an FMFontFamily selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
kEventParamFMFontStyleSpecifies the four-character code associated with an FMFontStyle selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
kEventParamFMFontSizeSpecifies the four-character code associated with an FMFontSize selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
kEventParamFontColorSpecifies the four-character code associated with a font color selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
Table 1 lists the parameters and data types associated with the Carbon event kEventFontSelection.
Parameter |
Data type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
FontPanel.hThe most common result codes returned by the Fonts Panel programming interface are listed below.
| Result Code | Value | Description |
|---|---|---|
fontPanelShowErr |
-8880 | The Fonts panel could not be opened. Available in Mac OS X v10.2 and later. |
fontPanelSelectionStyleErr |
-8881 | Your application specified an invalid style
type in the Available in Mac OS X v10.2 and later. |
fontPanelFontSelectionQDStyleVersionErr |
-8882 | Your application specified an invalid version
in the Available in Mac OS X v10.2 and later. |
Last updated: 2007-02-26