Class: TFont

Declaration: Font.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

MCollectible

Inherited By:

None.

Purpose:

TFont describes a single font at a certain configuration of attributes (for example, style, point size, variation, and transformation.) Each attribute is represented by a TFontStyle or one of its derived classes. Font styles are bundled into a TStyleSet similar to the way graphic attributes are bundled into a TGrafBundle. Use TStyleSet::CreateIterator to create an iterator for iterating through the styles in the style set. The set of font styles, when taken together, either fully describes a font, or is used to find a font most closely matching the set of font styles. You can modify a style set by adding or removing styles, and then use the new style set to locate a font on the system or the most closely matching font. Use CreateListOfAvailableFonts, CreateListOfAvailableFamilies, and CreateListOfAvailableStylesPerFamily to locate fonts. Use the member functions that return information about glyph codes and glyph sizes along with TGlyphRun to display text.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

Derive from this class when needed.

Concurrency:

Multithread safe.

Resource Use:

No special requirements.

Member Function: TFont::TFont

  1. TFont (const TStyleSet & requested, bool & successfulMatch)
  2. TFont ()
  3. TFont (const TFont &)

Interface Category:

API.

Purpose:

  1. Creates a TFont with respect to the TFontStyles specified in the requested TStyleSet; it returns true in successfulMatch if this font matches exactly as requested. It returns false if no match is found and this is set to the default system font.
  2. Default constructor. The TFontIdentifier of this font is the default system font.
  3. Copy constructor.

Calling Context:

  1. Call this function directly. Used by various classes, frameworks and servers.
  2. Call this function directly. Used by various classes, frameworks and servers.
  3. Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::~TFont

virtual ~ TFont ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::operator=

TFont & operator =(const TFont &)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::operator>>=

virtual TStream & operator >>=(TStream &) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::operator<<=

virtual TStream & operator <<= (TStream &)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::Hash

virtual long Hash () const

Interface Category:

API.

Purpose:

Returns the hash value of this font.

Calling Context:

Call this function directly.

Parameters:

Return Value:

The hash value of this font.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::GetAttributes

virtual void GetAttributes (TStyleSet &) const

Interface Category:

API.

Purpose:

Returns the set of styles that describes the font.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::GetFullName

virtual void GetFullName (const TLocale & language, TToken &) const

Interface Category:

API.

Purpose:

Returns the full name of this font in the specified language.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::GetFamilyName

virtual void GetFamilyName (const TLocale & language, TToken &) const

Interface Category:

API.

Purpose:

Returns the family name of this font in the specified language.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::GetStyleName

virtual void GetStyleName (const TLocale & language, TToken &) const

Interface Category:

API.

Purpose:

Returns the style name (or subfamily name) of this font in the language specified.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::CreateListOfAvailableFonts

static void CreateListOfAvailableFonts (TCollectionOf < TFontIdentifierStyle > & fontIdentifiers)

Interface Category:

API.

Purpose:

Returns a collection of TFontIdentifierStyles of all available fonts in the system.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

All allocated TFontIdentifierStyles are adopted by the caller. It is the caller's responsibility to dispose of these TFontIdentifierStyles.

Member Function: TFont::CreateListOfAvailableFamilyNames

static void CreateListOfAvailableFamilyNames (const TLocale & language, TCollectionOf < TToken > & familyNames)

Interface Category:

API.

Purpose:

Returns a collection of all unique family names of all available fonts in the system.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

All TTokens returned are adopted by the caller. It is the caller's responsibility to dispose of these TTokens.

Member Function: TFont::CreateListOfAvailableStyleNamesPerFamily

static void CreateListOfAvailableStyleNamesPerFamily (const TLocale & language, const TToken & familyName, TCollectionOf < TToken > & styleNames)

Interface Category:

API.

Purpose:

Returns a collection of all unique style names (or subfamily name) of a specified family of fonts in the system.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

All TTokens returned are adopted by the caller. It is the caller's responsibility to dispose of these TTokens.

Member Function: TFont::GetAdvanceWidths

  1. virtual void GetAdvanceWidths (unsigned long numberOfGlyphs, const GlyphCode glyphs [], GCoordinate widths [], const TGrafMatrix & resolution) const
  2. virtual void GetAdvanceWidths (unsigned long numberOfGlyphs, const GlyphCode glyphs [], GCoordinate widths []) const

Interface Category:

API.

Purpose:

  1. Calculates the advance widths of the specified array of glyphs, and returns the device resolution specific widths in an array of GCoordinates allocated by the caller.
  2. Calculates the advance widths of the specified array of glyphs, and returns the widths in an array of GCoordinates allocated by the caller.

Calling Context:

  1. Call this function directly. Used by various classes, frameworks and servers.
  2. Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The caller must provide sufficient storage for the widths array. Use 1. only when absolute display accuracy is required, otherwise use 2. which is more efficient and is device independent.

Member Function: TFont::GetAdvanceHeights

  1. virtual void GetAdvanceHeights (unsigned long numberOfGlyphs, const GlyphCode glyphs [], GCoordinate heights [], const TGrafMatrix & resolution) const
  2. virtual void GetAdvanceHeights (unsigned long numberOfGlyphs, const GlyphCode glyphs [], GCoordinate heights []) const

Interface Category:

API.

Purpose:

  1. Calculates the advance heights of the specified array of glyphs, and returns the device resolution dependent heights in an array of GCoordinates allocated by the caller.
  2. Calculates the advance heights of the specified array of glyphs, and returns the heights in an array of GCoordinates allocated by the caller.

Calling Context:

  1. Call this function directly. Used by various classes, frameworks and servers.
  2. Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The caller must provide sufficient storage for the heights array. Use 1. only when absolute display accuracy is required, otherwise use 2. which is more efficient and is device independent.

Member Function: TFont::MapCharactersToGlyphs

virtual void MapCharactersToGlyphs (long numberOfCharacters, const UniChar characters [], GlyphCode glyphs []) const

Interface Category:

API.

Purpose:

Maps the specified Unicode characters into font-specific glyph codes. The glyph codes are used to construct graphical objects such as TGlyphRun, which can be rendered.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The caller must provide sufficient storage for the glyphs array.

Member Function: TFont::GetCaretInfo

virtual void GetCaretInfo (GCoordinate & rise, GCoordinate & run, GCoordinate & offset) const

Interface Category:

API.

Purpose:

Returns the caret information for displaying an editor caret of this font. The caret is specified as rise, run, and offset. The angle of the caret is specified by the rise (the vertical ratio component) and the run (the horizontal ratio component) so that the arctan of the specified angle is equal to the rise, divided by the run. The offset of the caret position from the origin of a glyph is also returned.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::GetLineGap

virtual GCoordinate GetLineGap () const

Interface Category:

API.

Purpose:

Returns the line gap of the font in GCoordinate.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

Returns the line gap of the type GCoordinate in units of points.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::GetMaxAdvanceHeight

virtual GCoordinate GetMaxAdvanceHeight () const

Interface Category:

API.

Purpose:

Returns the maximum advance height in GCoordinate. The advance height is the vertical distance from the baseline of a glyph to the baseline of the next glyph.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

Returns the maximum advance height in GCoordinate.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::GetMaxAdvanceWidth

virtual GCoordinate GetMaxAdvanceWidth () const

Interface Category:

API.

Purpose:

Returns the maximum advance width in GCoordinate. The advance width is the horizontal distance from the origin of a glyph to the origin of the next glyph.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

Returns the maximum advance width in GCoordinate.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::GetAscent

virtual GCoordinate GetAscent () const

Interface Category:

API.

Purpose:

Returns the ascent of a glyph in GCoordinate. The ascent is the vertical distance from the baseline of a glyph to the highest point of the glyph.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

Returns the ascent in GCoordinate.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::GetDescent

virtual GCoordinate GetDescent () const

Interface Category:

API.

Purpose:

Returns the descent of a glyph in GCoordinate. The descent is the vertical distance from the highest point of a glyph to the baseline of the glyph.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

Returns the descent in GCoordinate.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::GetUnitsPerEm

virtual unsigned long GetUnitsPerEm () const

Interface Category:

API.

Purpose:

Returns the number of units per em (the original resolution units of the em space) of the designed font. This is used as the denominator to calculate the scale factor for rendering the font into user-desired sizes. For example: if the units per em is 1024 and the desired font size is 12, then the scale factor for rendering the font is 12/1024 =0.01171875.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

Returns the units per em in unsigned long.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::IsMonospacedWidth

virtual bool IsMonospacedWidth () const

Interface Category:

API.

Purpose:

Returns true if the font is monospaced width. All glyphs have the same advance width in a monospaced-width font.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns true if font is monospaced width.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::IsMonospacedHeight

virtual bool IsMonospacedHeight () const

Interface Category:

API.

Purpose:

Returns true if the font is monospaced height. All glyphs have the same advance height in a monospaced-height font.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns true if font is monospaced height.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::CreateOutline

virtual TGLoop * CreateOutline (const TGGlyphRun & glyphRun, const TGrafMatrix & transform =TGrafMatrix :: GetIdentity (), const TGrafMatrix & resolution =TGrafMatrix :: GetIdentity ()) const

Interface Category:

API.

Purpose:

Creates the outlines of the glyphs specified in a TGGlyphRun and returns the results in an orphaned TGLoop object. This can be used for graphical manipulation and rendering.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

The TGLoop object of the outlines of the specified glyphs.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The caller assumes ownership of the resultant TGLoop object.

Member Function: TFont::CreateUnscaledOutline

virtual TGLoop * CreateUnscaledOutline (const GlyphCode glyph, GCoordinate & advancement, GCoordinate & sideBearing, bool vertical =false) const

Interface Category:

API.

Purpose:

Creates an outline of a single glyph without scaling the outline into the font point size and returns the results in an orphaned TGLoop object. This outline is in the original resolution of the glyph. The horizontal advancement and the side bearing are also returned in this resolution.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the unscaled outline in a TGLoop object.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The caller assumes ownership of the resultant TGLoop object.

Member Function: TFont::GetPostScriptName

virtual void GetPostScriptName (TToken & name) const

Interface Category:

API.

Purpose:

Returns the PostScript name of this font.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::CreateFontHandler

virtual TFontHandler * CreateFontHandler () const

Interface Category:

API.

Purpose:

Creates a clone of the TFontHandler of this font and returns the orphaned pointer. This TFontHandler gets access to features of the font that otherwise cannot be accessed through the TFont interface. These features include direct access to the font file and several font table objects.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a pointer to the cloned TFontHandler.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The caller assumes ownership of the resultant TGLoop object.

Member Function: TFont::LookupFontSlant

static void LookupFontSlant (const TLocale & language, const TToken & slantName, TFontSlantAngleStyle & resultingSlant)

Interface Category:

API.

Purpose:

Returns the slant style of the specified slant name.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::LookupFontWidth

static void LookupFontWidth (const TLocale & language, const TToken & widthName, TFontWidthStyle & resultingWidth)

Interface Category:

API.

Purpose:

Returns the font width style of the specified width name.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::LookupFontWeight

static void LookupFontWeight (const TLocale & language, const TToken & weightName, TFontWeightStyle & resultingWeight)

Interface Category:

API.

Purpose:

Returns the weight style of the specified weight name.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::LookupAttributes

static void LookupAttributes (const TLocale & language, const TToken & familyName, const TToken & styleName, TFontFamilyStyle & resultingFamily, TFontWeightStyle & resultingWeight, TFontWidthStyle & resultingWidth, TFontSlantAngleStyle & resultingSlant)

Interface Category:

API.

Purpose:

Returns the attributes in TStyle of the font specified by the family name and the style name.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::LookupFont

static void LookupFont (const TLocale & language, const TToken & familyName, const TToken & styleName, TFontIdentifierStyle & resultingStyle)

Interface Category:

API.

Purpose:

Returns the font identifier of the font specified by the family name and the style name.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::LookupFontFamily

static void LookupFontFamily (const TLocale & language, const TToken & familyName, TFontFamilyStyle & resultingStyle)

Interface Category:

API.

Purpose:

Returns the font family style of the specified font family name.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::CreateListOfAvailableSlantNames

static void CreateListOfAvailableSlantNames (const TLocale & language, TCollectionOf < TToken > & slantNames)

Interface Category:

API.

Purpose:

Creates a list of names of the available slant styles of all the fonts currently in the system.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::CreateListOfAvailableWidthNames

static void CreateListOfAvailableWidthNames (const TLocale & language, TCollectionOf < TToken > & widthNames)

Interface Category:

API.

Purpose:

Creates a list of names of the available width styles of all the fonts currently in the system.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TFont::CreateListOfAvailableWeightNames

static void CreateListOfAvailableWeightNames (const TLocale & language, TCollectionOf < TToken > & weightNames)

Interface Category:

API.

Purpose:

Creates a list of names of the available weights of all the fonts in the system currently.

Calling Context:

Call this function directly. Used by various classes, frameworks and servers.

Parameters:

Return Value:

None.

Exceptions:

Throws TGraphicsInternalException when FontServer is not accessible, passes all other exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.