The IFont class manages the use of fonts. Use this class to select a font through the IFont functions. You can also use the font dialog to do the following:
IWindow::setFont changes the font used to draw text in a control.
The function beginUsingFont causes all subsequent text drawn to the specified presentation space to be in the font represented by the IFont object. You can use beginUsingFont in conjunction with an IPaintHandler object.
If you are porting a program to another operating system, be aware that the font names vary between these systems. The only fonts that you can be reasonably sure of finding on each operating system are Courier and Helvetica. If you try to construct an IFont object for a nonexistent font, you will get Courier as the default font.
Some of the set and use functions, such as setCharHeight and useBitmapOnly, accept an optional parameter of type IPresSpaceHandle. Because the AIX version of IFont does not support printer fonts, there is no need to supply the optional IPresSpaceHandle parameter.
The members in this class that refer to vector fonts use scalable fonts in the X-Motif environment.
Some of the set and use functions (such as setCharHeight and useBitmapOnly) accept an optional parameter of type IPresSpaceHandle. If you are using IFont to represent printer fonts, you must provide this parameter. If you do not specify a presentation space, IFont uses the presentation space of the desktop.
Use these members to construct, copy, assign, and destruct objects of this class.
![]() |
public:
virtual ~IFont()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IFont(const IFont& fntCopy)
You can construct objects of this class from another IFont object. The parameter for this constructor is the following:
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IFont( const char* faceName, unsigned long pointSize = 0, bool useFixedFont = false, bool useVectorFont = false, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
You can construct objects of this class by specifying the name and size of the font desired, along with additional parameters. The parameters for this constructor are the following:
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IFont(const IPresSpaceHandle& presSpaceHandle)
You can construct objects of this class using a presentation space. This constructs a font corresponding to the font used in the specified presentation space. The parameter for this constructor is the following:
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IFont(const IWindow* window = 0)
You can construct objects of this class using a window's font. This constructs a font from the current font being used in the window. The parameter for this constructor is the following:
Windows | OS/2 | AIX |
Yes | Yes | Yes |
In the AIX release, if you do not specify a window, the default font of the current display is used.
In the OS/2 operating system, if the IWindow* is a multi-line edit field (MLE), Presentation Manager returns the desktop presentation space instead of the MLE presentation space. In doing so, a different font is displayed.
![]() |
public:
IFont& operator =(const IFont& font)
Assigns the value of one font object to another.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Use these members to access operating system specific font information.
![]() |
public:
const struct _FATTRS* fattrs() const
Returns a pointer to the font's OS/2 Presentation Manager FATTRS structure.
Windows | OS/2 | AIX |
No | Yes | No |
![]() |
public:
const struct _FONTMETRICS* fontmetrics() const
Returns a pointer to the font's OS/2 Presentation Manager FONTMETRICS structure.
Windows | OS/2 | AIX |
No | Yes | No |
![]() |
public:
_XFontSet* fontSet()
Return a pointer to the internal _XFontSet structure.
Windows | OS/2 | AIX |
No | No | Yes |
![]() |
public:
const struct tagLOGFONTA* logfont() const
Returns a pointer to the font's Windows LOGFONT structure.
Windows | OS/2 | AIX |
Yes | No | No |
![]() |
public:
_XmFontListRec* mFontList()
Returns a pointer to the internal _XmFontListRec structure.
Windows | OS/2 | AIX |
No | No | Yes |
Use these members with a cursor to retrieve font information.
![]() |
public:
static IString faceNameAt( const FaceNameCursor& faceNameCursor )
Queries a font face name for the current position of the specified cursor.
Windows | OS/2 | AIX |
Yes | Yes | No |
![]() |
public:
static long pointSizeAt( const PointSizeCursor& pointSizeCursor )
Queries the point size of a font for the current position of the specified cursor.
Windows | OS/2 | AIX |
Yes | Yes | No |
Use these members to draw text using a font.
![]() |
public:
virtual IFont& beginUsingFont( const IPresSpaceHandle& presSpaceHandle )
Sets the presentation space to use the font.
IAccessError | The operating system is unable to create or set the font. |
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
virtual IFont& endUsingFont( const IPresSpaceHandle& presSpaceHandle )
Restores the presentation space to the default font.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Use these members to query and set the types of fonts used by the IFont object.
![]() |
public:
bool isBitmapOnly() const
If the IFont object uses only bitmap fonts, true is returned.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
bool isNonPropOnly() const
If the IFont object uses only nonproportional fonts, true is returned.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
bool isVectorOnly() const
If the IFont object uses only vector fonts, true is returned.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
virtual IFont& useBitmapOnly( bool bitmapOnly = true, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
Sets whether the IFont object uses only bitmap fonts.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
virtual IFont& useNonPropOnly( bool nonProportionalOnly = true, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
Sets whether the IFont object uses only nonproportional fonts.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
virtual IFont& useVectorOnly( bool vectorOnly = true, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
Sets whether the IFont object uses only vector fonts.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Use these members to query information about the size of the font.
![]() |
public:
unsigned long avgCharWidth() const
Returns the average character's width.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
unsigned long avgLowercase() const
Returns the nominal height above the baseline for lowercase characters.
Windows | OS/2 | AIX |
No | Yes | Yes |
![]() |
public:
unsigned long avgUppercase() const
Returns the height of the Em square. This corresponds to the point size.
Windows | OS/2 | AIX |
No | Yes | Yes |
![]() |
public:
unsigned long charWidth(char c) const
Returns the width of a specific single-byte character.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
This member function is not MBCS-enabled.
This member function is not DBCS-enabled.
![]() |
public:
unsigned long externalLeading() const
Returns the amount of white space that appears between adjacent rows of text for this font.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
![]() |
public:
unsigned long internalLeading() const
Returns the approximate position of the top of a row of characters. You can use this value to position the first line of a block of text by doing both of the following:
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
![]() |
public:
unsigned long maxAscender() const
Returns the height of the largest ascender above the baseline.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
unsigned long maxCharHeight() const
Returns the height portion of IFont::maxSize.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
unsigned long maxDescender() const
Returns the height of the largest descender below the baseline.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
unsigned long maxLowercaseAscender() const
Returns the height of the largest lowercase ascender.
Windows | OS/2 | AIX |
No | Yes | Yes |
![]() |
public:
unsigned long maxLowercaseDescender() const
Returns the height of the largest lowercase descender.
Windows | OS/2 | AIX |
No | Yes | Yes |
![]() |
public:
ISize maxSize() const
Returns the maximum width and height.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
ISize maxUppercaseSize() const
Returns the maximum size for an uppercase character.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
unsigned long minTextWidth(const char* line) const
Returns the width of the widest word.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
This member function is not MBCS-enabled.
This member function is not DBCS-enabled.
![]() |
public:
ISize subscriptOffset() const
Returns the recommended size of the baseline X-Y offset for subscripts.
Windows | OS/2 | AIX |
No | Yes | Yes |
![]() |
public:
ISize subscriptSize() const
Returns the recommended size for subscripts.
Windows | OS/2 | AIX |
No | Yes | Yes |
![]() |
public:
ISize superscriptOffset() const
Returns the recommended size of the baseline X-Y offset for superscripts.
Windows | OS/2 | AIX |
No | Yes | Yes |
![]() |
public:
ISize superscriptSize() const
Returns the recommended size for superscripts.
Windows | OS/2 | AIX |
No | Yes | Yes |
![]() |
public:
unsigned long textLines( const char* text, unsigned long lineWidth ) const
Returns the number of lines required to fit the specified text using the specified maximum line width.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
This member function is not MBCS-enabled.
This member function is not DBCS-enabled.
![]() |
Returns the width of the specified string.
public:
unsigned long textWidth( const char* text, IBidiSettings& settings ) const
Returns the width of the specified string using the specified bidirectional attributes. This member function is not DBCS-enabled.
Windows | OS/2 | AIX |
Yes | Yes | No |
public:
unsigned long textWidth(const char* text) const
Returns the width of the specified string. This member function is not DBCS-enabled.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
This member function is not MBCS-enabled.
This member function is not DBCS-enabled.
Use these members to query the attributes of the current font.
![]() |
public:
bool isBitmap() const
If the IFont object uses a bitmap font, true is returned. If the IFont object uses a vector font, false is returned.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
bool isFixed() const
If the IFont object uses a fixed-size (that is, nonproportional) font, true is returned.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IString name() const
Returns the face name of the font.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
unsigned long pointSize() const
Returns the point size of the font.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IString qualifiedName() const
Returns a tagged font descriptor which can be used to construct a specific font by passing the qualified name in as the facename parameter on the appropriate IFont constructor.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Returns the X Windows Logical Font Description (XLFD) in the following format: IOC:xlfd string
Returns the qualified name in the following format: IOC:faceName:pointSize
Returns the qualified name in the following format: IOC:faceName:pointSize
Use these members to query the appearance of a font.
![]() |
public:
bool isBold() const
If the IFont object uses a font that is bold, true is returned.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
bool isItalic() const
If the IFont object uses an italicized font, true is returned.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
bool isOutline() const
If the IFont object uses a font that appears hollow, true is returned.
Windows | OS/2 | AIX |
Ignored | Yes | Ignored |
![]() |
public:
bool isStrikeout() const
If the IFont object uses a font with a line drawn through the characters, true is returned.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
![]() |
public:
bool isUnderscore() const
If the IFont object uses a font with a line drawn under the characters, true is returned.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
![]() |
public:
ITextStyleSet styleSet() const
Returns a style set representing the current font.
Recommended usage of this function is to make all modifications to the font prior to querying the style set. Modifying the style set could result in a different font selected when used by 2D graphics, for example.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Use these members to set the direction that the font is drawn in.
![]() |
public:
virtual IFont& setDirection(Direction direction)
Sets the direction to draw the font in.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
In the AIX release, the system locale information determines the font direction.
Use these members to change the appearance of a font.
![]() |
public:
virtual IFont& setAllEmphasis(bool turnOn = true)
If you specify true, all of the styles are set on. If you specify false, all of the styles are set off.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
virtual IFont& setBold(bool bold = true)
Changes the font to bold.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
virtual IFont& setItalic(bool italics = true)
Changes the font to italic.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
virtual IFont& setOutline(bool outline = true)
Causes the font to appear hollow.
Windows | OS/2 | AIX |
Ignored | Yes | Ignored |
![]() |
public:
virtual IFont& setStrikeout(bool strikeout = true)
Draws a line through the characters.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
![]() |
public:
virtual IFont& setUnderscore(bool underscore = true)
Draws a line under the characters.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
Use these members to set the attributes of any font being managed by the IFont class.
![]() |
public:
virtual IFont& setName( const char* name, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
Sets the font's face name.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
virtual IFont& setPointSize( unsigned long size, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
Sets the font's point size.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Use these members to set the attributes of vector fonts. They have no effect when applied to a bitmap font.
![]() |
public:
virtual IFont& setCharHeight( unsigned long height, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
Sets the height of the characters of a vector font. This function has no effect when applied to a bitmap font.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
![]() |
public:
virtual IFont& setCharSize( const ISize& size, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
Sets the size of the characters of a vector font. This function has no effect when applied to a bitmap font.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
![]() |
public:
virtual IFont& setCharWidth( unsigned long width, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
Sets the width of the characters of a vector font. This function has no effect when applied to a bitmap font.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
![]() |
public:
virtual IFont& setFontAngle( const IPoint& point, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
Sets the angle used to draw the vector font. This function has no effect when applied to a bitmap font.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
![]() |
public:
virtual IFont& setFontShear( const IPoint& point, const IPresSpaceHandle& presSpaceHandle = IPresSpaceHandle ( ) )
Sets the amount of shear to apply to the vector font. This function has no effect when applied to a bitmap font.
Windows | OS/2 | AIX |
Yes | Yes | Ignored |
Use these members to apply the current font to an IWindow object.
![]() |
public:
virtual bool setWindowFont(IWindow* window) const
Sets the font for the specified IWindow to the current font. If the font is successfully changed, true is returned.
IAccessError | The operating system is unable to set the font for the window. |
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
enum Direction { defaultDir, leftToRight, topToBottom, rightToLeft, bottomToTop }
Use these enumerators to specify the direction in which a font is drawn. You can use these enumerators as input to setDirection.
Windows | OS/2 | AIX |
Yes | Yes | Yes |