Derived from | |
Framework | ApplicationServices/ApplicationServices.h |
Companion guide | |
Declared in | CGFont.h |
The CGFontRef
opaque type encapsulates font information. A font is a set of shapes or glyphs associated with a character set. A glyph can represent a single character (such as ‘b’), more than one character (such as the “fi” ligature), or a special character such as a space. Quartz retrieves the glyphs for the font from ATS (Apple Type Services) and paints the glyphs based on the relevant parameters of the current graphics state.
Quartz provides a limited, low-level interface for drawing text. For information on text-drawing functions, see CGContext Reference. For full Unicode and text-layout support, use the services provided by Core Text or ATSUI).
CGFontCreateWithDataProvider
CGFontCreateWithFontName
CGFontCreateCopyWithVariations
CGFontCreateWithPlatformFont
CGFontCopyPostScriptName
CGFontCanCreatePostScriptSubset
CGFontCreatePostScriptSubset
CGFontCreatePostScriptEncoding
CGFontGetTypeID
CGFontCopyVariationAxes
CGFontCopyVariations
CGFontCopyFullName
CGFontGetAscent
CGFontGetDescent
CGFontGetLeading
CGFontGetCapHeight
CGFontGetXHeight
CGFontGetFontBBox
CGFontGetItalicAngle
CGFontGetStemV
CGFontGetGlyphBBoxes
CGFontGetGlyphWithGlyphName
CGFontCopyGlyphNameForGlyph
CGFontGetNumberOfGlyphs
CGFontGetGlyphAdvances
CGFontGetUnitsPerEm
Determines whether Quartz can create a subset of the font in PostScript format.
bool CGFontCanCreatePostScriptSubset ( CGFontRef font, CGFontPostScriptFormat format );
A font object.
Returns true
if a subset in the PostScript format can be created for the font; false
otherwise.
For more information on PostScript format, see Adobe Type 1 Font Format, which is available from http://partners.adobe.com/.
CGFont.h
Returns the full name associated with a font object.
CFStringRef CGFontCopyFullName ( CGFontRef font );
A font object.
The full name associated with the font.
CGFont.h
Returns the glyph name associated with a font object.
CFStringRef CGFontCopyGlyphNameForGlyph ( CGFontRef font );
A font object.
A glyph name, or NULL
if there isn’t a glyph associated with the font object.
CGFont.h
Obtains the PostScript name of a font.
CFStringRef CGFontCopyPostScriptName ( CGFontRef font );
A font object.
The PostScript name of the font.
CGFont.h
Returns the font table that corresponds to the provided tag.
CFDataRef CGFontCopyTableForTag( CGFontRef font, uint32_t tag );
A font object.
The tag for the table you want to obtain.
The font table that corresponds to the tag, or NULL
if no such table exists.
CGFont.h
Returns an array of tags that correspond to the font tables for a font.
CFArrayRef CGFontCopyTableTags( CGFontRef font );
A CGFont object.
An array of font table tags.
Each entry in the returned array is a four-byte value that represents a single TrueType or OpenType font table tag. To obtain a tag at index k
in a manner that is appropriate for 32-bit and 64-bit architectures, you need to use code similar to the following:
tag = (uint32_t)(uintptr_t)CFArrayGetValue(table, k); |
CGFont.h
Returns an array of the variation axis dictionaries for a font.
CFArrayRef CGFontCopyVariationAxes ( CGFontRef font );
A CGFont object.
An array of the variation axis dictionaries. Returns NULL
if the font doesn't support variations.
A variation axis is a range included in a font by the font designer that allows a font to produce different type styles. Each variation axis dictionary contains key-value pairs that specify the variation axis name and the minimum, maximum, and default values for that variation axis.
CGFont.h
Returns the variation specification dictionary for a font.
CFDictionaryRef CGFontCopyVariations ( CGFontRef font );
A font object.
The variation specification dictionary for the font. Returns NULL
if the font doesn't support variations.
The variation specification dictionary contains keys that correspond to the variation axis names of the font. Each key is a variation axis name. The value for each key is the value specified for that particular variation axis represented as a CFNumber object.
CGFont.h
Creates a copy of a font using a variation specification dictionary.
CGFontRef CGFontCreateCopyWithVariations ( CGFontRef font, CFDictionaryRef variations );
The Quartz font to copy.
A variation specification dictionary that contains keys corresponding to the variation axis names of the font. Each key in the dictionary is a variation axis name. The value for each key is the value specified for that particular variation axis represented as a CFNumber object. If a variation axis name is not specified in variations
, then the current value from font
is used.
The font object.
CGFont.h
Creates a PostScript encoding of a font.
CFDataRef CGFontCreatePostScriptEncoding ( CGFontRef font, const CGGlyph encoding[256] );
A CGFont object.
The encoding to use.
A PostScript encoding of the font that contains glyphs in the specified encoding.
For more information on PostScript format, see Adobe Type 1 Font Format, which is available from http://partners.adobe.com/.
CGFont.h
Creates a subset of the font in the specified PostScript format.
CFDataRef CGFontCreatePostScriptSubset ( CGFontRef font, CFStringRef subsetName, CGFontPostScriptFormat format, const CGGlyph glyphs[], size_t count, const CGGlyph encoding[256] );
A font object.
The name of the subset.
The PostScript format of the font.
An array that contains the glyphs in the subset.
The number of glyphs specified by the glyphs
array.
The default encoding for the subset. You can pass NULL
if you do not want to specify an encoding.
A subset of the font created from the supplied parameters.
For more information on PostScript format, see Adobe Type 1 Font Format, which is available from http://partners.adobe.com/.
CGFont.h
Creates a font object from data supplied from a data provider.
CGFontRef CGFontCreateWithDataProvider ( CGDataProviderRef provider );
A data provider.
The font object or NULL
if the font can't be created. You are responsible for releasing this object using CGFontRelease
.
Before drawing text in a Quartz context, you must set the font in the current graphics state by calling the function CGContextSetFontSize
.
CGFont.h
Creates a font object corresponding to the font specified by a PostScript or full name.
CGFontRef CGFontCreateWithFontName ( CFStringRef name );
The PostScript or full name of a font.
The font object or NULL
if the font can't be created. You are responsible for releasing this object using CGFontRelease
.
Before drawing text in a Quartz context, you must set the font in the current graphics state by calling the function CGContextSetFont
.
CGFont.h
Creates a font object from an Apple Type Services (ATS) font.
CGFontRef CGFontCreateWithPlatformFont ( void *platformFontReference );
A generic pointer to a font object. The font should be of a type appropriate to the platform on which your program is running. For Mac OS X, you should pass a pointer to an ATS font.
The font object, or NULL
if the platform font could not be located. You are responsible for releasing this object using CGFontRelease
.
Before drawing text in a Quartz context, you must set the font in the current graphics state. For ATS Fonts, call this function to create a Quartz font, and pass it to CGContextSetFont
.
CGFont.h
Returns the ascent of a font.
int CGFontGetAscent ( CGFontRef font );
A font object.
The ascent of the font.
The ascent is the maximum distance above the baseline of glyphs in a font. The value is specified in glyph space units.
CGFont.h
Returns the cap height of a font.
int CGFontGetCapHeight ( CGFontRef font );
A font object.
The cap height of the font.
The cap height is the distance above the baseline of the top of flat capital letters of glyphs in a font. The value is specified in glyph space units.
CGFont.h
Returns the descent of a font.
int CGFontGetDescent ( CGFontRef font );
A font object.
The descent of the font .
The descent is the maximum distance below the baseline of glyphs in a font. The value is specified in glyph space units.
CGFont.h
Returns the bounding box of a font.
CGRect CGFontGetFontBBox ( CGFontRef font );
A font object.
The bounding box of the font.
The font bounding box is the union of all of the bounding boxes for all the glyphs in a font. The value is specified in glyph space units.
CGFont.h
Gets the bound box of each glyph in the provided array.
bool CGFontGetGlyphAdvances ( CGFontRef font, const CGGlyph glyphs[], size_t count, int advances[] );
The font object associated with the provided glyphs.
An array of glyphs.
The number of glyphs in the array.
On output, an array of of advances for the provided glyphs.
TRUE
unless the advances can’t be provided for some reason.
CGFont.h
Get the bounding box of each glyph in an array.
bool CGFontGetGlyphBBoxes ( CGFontRef font, const CGGlyph glyphs[], size_t count, CGRect bboxes[] );
A font object.
A array of glyphs.
The number of items in the glyphs
array.
On return, the bounding boxes for each glyph.
false
if bounding boxes can't be retrieved for any reason; true
otherwise.
CGFont.h
Returns the glyph for the font name associated with the specified font object.
CGGlyph CGFontGetGlyphWithGlyphName ( CGFontRef font );
A font object.
A glyph, or 0
if there isn’t a name associated with the font object.
CGFont.h
Returns the italic angle of a font.
CGFloat CGFontGetItalicAngle ( CGFontRef font );
A font object.
The italic angle of the font, measured in degrees counter-clockwise from the vertical.
CGFont.h
Returns the leading of a font.
int CGFontGetLeading ( CGFontRef font );
A font object.
The leading of the font.
The leading is the spacing between consecutive lines of text in a font. The value is specified in glyph space units.
CGFont.h
Returns the number of glyphs in a font.
size_t CGFontGetNumberOfGlyphs ( CGFontRef font );
A CGFont
object.
The number of glyphs in the provided font.
CGFont.h
Returns the thickness of the dominant vertical stems of glyphs in a font.
CGFloat CGFontGetItalicAngle ( CGFontRef font );
A font object.
The thickness of the dominant vertical stems of glyphs in a font.
CGFont.h
Returns the Core Foundation type identifier for Quartz fonts.
CFTypeID CGFontGetTypeID ( void );
The Core Foundation identifier for the opaque type CGFontRef
.
CGFont.h
Returns the number of glyph space units per em for the provided font.
int CGFontGetUnitsPerEm ( CGFontRef font );
A CGFont
object.
The number of glyph space units per em for the provided font.
CGFont.h
Returns the x-height of a font.
int CGFontGetXHeight ( CGFontRef font );
A font object.
The x-height of the font.
The x-height is the distance above the baseline of the top of flat, non-ascending lowercase letters (such as x
) of glyphs in a font. The value is specified in glyph space units.
CGFont.h
Decrements the retain count of a Quartz font.
void CGFontRelease ( CGFontRef font );
The Quartz font to release.
This function is equivalent to CFRelease
, except that it does not cause an error if the font
parameter is NULL
.
CGFont.h
Increments the retain count of a Quartz font.
CGFontRef CGFontRetain ( CGFontRef font );
The Quartz font to retain.
The same font you specified in the font
parameter.
This function is equivalent to CFRetain
, except that it does not cause an error if the font
parameter is NULL
.
CGFont.h
An opaque type that encapsulates font information.
typedef struct CGFont *CGFontRef;
CGFont.h
An index into a font table.
typedef unsigned short CGFontIndex;
This integer type provides an additional way to specify a glyph identifier. CGFontIndex
is equivalent to CGGlyph
, and you can use constants of either type interchangeably.
CGFont.h
An index into the internal glyph table of a font.
typedef unsigned short CGGlyph;
When drawing text, you typically specify a sequence of characters. However, Quartz also allows you to use CGGlyph
values to specify glyphs. In either case, Quartz renders the text using font data provided by the Apple Type Services (ATS) framework.
You provide CGGlyph
values to the functions CGContextShowGlyphs
and CGContextShowGlyphsAtPoint
. These functions display an array of glyphs at the current text position or at a position you specify, respectively.
CGFont.h
Possible formats for a PostScript font subset.
enum CGFontPostScriptFormat { kCGFontPostScriptFormatType1 = 1, kCGFontPostScriptFormatType3 = 3, kCGFontPostScriptFormatType42 = 42 }; typedef enum CGFontPostScriptFormat CGFontPostScriptFormat;
kCGFontPostScriptFormatType1
This is documented in Adobe Type 1 Font Format, which is available from http://partners.adobe.com/.
Available in Mac OS X v10.4 and later.
Declared in CGFont.h
.
kCGFontPostScriptFormatType3
This is documented in PostScript Language Reference, 3rd edition, which is available from http://partners.adobe.com/.
Available in Mac OS X v10.4 and later.
Declared in CGFont.h
.
kCGFontPostScriptFormatType42
This is documented in Adobe Technical Note 5012, The Type 42 Font Format Specification, which is available from http://partners.adobe.com/.
Available in Mac OS X v10.4 and later.
Declared in CGFont.h
.
CGFont.h
Possible values for an index into a font table.
enum { kCGFontIndexMax = ((1 << 16) - 2), kCGFontIndexInvalid = ((1 << 16) - 1), kCGGlyphMax = kCGFontIndexMax };
kCGFontIndexMax
The maximum allowed value for CGFontIndex
.
Available in Mac OS X v10.1 and later.
Declared in CGFont.h
.
kCGFontIndexInvalid
An invalid font index (a value which never represents a valid glyph).
Available in Mac OS X v10.1 and later.
Declared in CGFont.h
.
kCGGlyphMax
The same as kCGFontIndexMax
.
Available in Mac OS X v10.1 and later.
Declared in CGFont.h
.
See CGFontIndex
.
CGFont.h
Keys used for a font variation axis dictionary.
const CFStringRef kCGFontVariationAxisName const CFStringRef kCGFontVariationAxisMinValue const CFStringRef kCGFontVariationAxisMaxValue const CFStringRef kCGFontVariationAxisDefaultValue
kCGFontVariationAxisName
The key used to obtain the variation axis name from a variation axis dictionary. The value obtained with this key is a CFStringRef
that specifies the name of the variation axis.
Available in Mac OS X v10.4 and later.
Declared in CGFont.h
.
kCGFontVariationAxisMinValue
The key used to obtain the minimum variation axis value from a variation axis dictionary. The value obtained with this key is a CFNumberRef
that specifies the minimum value of the variation axis.
Available in Mac OS X v10.4 and later.
Declared in CGFont.h
.
kCGFontVariationAxisMaxValue
The key used to obtain the maximum variation axis value from a variation axis dictionary. The value obtained with this key is a CFNumberRef
that specifies the maximum value of the variation axis.
Available in Mac OS X v10.4 and later.
Declared in CGFont.h
.
kCGFontVariationAxisDefaultValue
The key used to obtain the default variation axis value from a variation axis dictionary. The value obtained with this key is a CFNumberRef
that specifies the default value of the variation axis.
Available in Mac OS X v10.4 and later.
Declared in CGFont.h
.
CGFont.h
© 2003, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-07-17)