1、保存与释放CGFont对象
void CGFontRelease (CGFontRef font) --- 递减Quartz font对象的计数器。
CGFontRef CGFontRetain (CGFontRef font) --- 递增Quartz font对象的计数器。
2、创建CGFont对象
CGFontRef CGFontCreateWithDataProvider (CGDataProviderRef provider) --- 从data provider提供的数据创建一个font对象。如果font不能被创建,font对象为NULL。你有责任负责利用CGFontRelease释放对象。描述:在绘画文本到Quartz content之前,你必须调用CGContextSetFontSize函数设置字体的图形状态。
CGFontRef CGFontCreateWithFontName (CFStringRef name) --- 通过匹配页描述语言中特殊的字体或者字体全名创建font对象。
CGFontRef CGFontCreateCopyWithVariations ( CGFontRef font,CFDictionaryRef variations) --- 使用特殊字典变量创建一个font对象拷贝。
3、使用PostScript字体
CFStringRef CGFontCopyPostScriptName (CGFontRef font) ---- 从字体中获取PostScript名称。
bool CGFontCanCreatePostScriptSubset (CGFontRef font,CGFontPostScriptFormat format) --- 判断Quartz能否创建页描述语言格式子集中的字体。
CFDataRef CGFontCreatePostScriptSubset (CGFontRef font,CFStringRef subsetName,CGFontPostScriptFormat format,const CGGlyph glyphs[],size_t count,const CGGlyph encoding[256]) --- 创建一个PostScript格式指定的子集中的字体。
CFDataRef CGFontCreatePostScriptEncoding (CGFontRef font,const CGGlyph encoding[256]) --- 创建PostScript编码的字体
4、使用字体表
CFArrayRef CGFontCopyTableTags(CGFontRef font) --- 返回字体符合字体表的数组标识。例子:
tag = (uint32_t)(uintptr_t)CFArrayGetValue(table, k); |
CFDataRef CGFontCopyTableForTag(CGFontRef font,uint32_t tag) --- 返回提供的tag所对应的字体表中的字体
5、获取字体信息
CFTypeID CGFontGetTypeID (void) --- 返回核心基础类型的Quartz字体
CFArrayRef CGFontCopyVariationAxes (CGFontRef font) --- 返回字体的变量轴字典的数组。
CFDictionaryRef CGFontCopyVariations (CGFontRef font) --- 返回字体指定变量字典。
CFStringRef CGFontCopyFullName (CGFontRef font) --- 返回字体对象的全名。
int CGFontGetAscent (CGFontRef font) --- 返回字体的上升值。
int CGFontGetDescent (CGFontRef font) --- 返回字体的下降值。
int CGFontGetLeading (CGFontRef font) --- 返回字体的行间距。
int CGFontGetCapHeight (CGFontRef font) --- 返回字体的盖高值。
int CGFontGetXHeight ( CGFontRef font) ---- 返回x高度值。
CGRect CGFontGetFontBBox (CGFontRef font) --- 返回字体的跳盒。
CFStringRef CGFontCopyGlyphNameForGlyph (CGFontRef font,CGGlyph glyph) --- 返回指定glyph指定字体的glyph全名。
bool CGFontGetGlyphAdvances (CGFontRef font,const CGGlyph glyphs[],size_t count,int advances[]) --- 获取每一个glyph所提供的数组中的增长宽度。
bool CGFontGetGlyphBBoxes ( CGFontRef font,const CGGlyph glyphs[],size_t count,CGRect bboxes[]) --- 获取每一glyph数组中的跳盒。
CGGlyph CGFontGetGlyphWithGlyphName (CGFontRef font,CFStringRef name) --- 返回指定字体对象中的glyph的glyph名称。
CGFloat CGFontGetItalicAngle (CGFontRef font) --- 返回字体的倾斜度。
size_t CGFontGetNumberOfGlyphs (CGFontRef font) --- 返回字体所包含的glyph总数。
int CGFontGetUnitsPerEm (CGFontRef font) --- 返回字体单元比率身长数值。
Data Types
CGFontRef
An opaque type that encapsulates font information.
typedef struct CGFont *CGFontRef;
Availability
- Available in iOS 2.0 and later.
Declared In
CGFont.h
CGFontIndex
An index into a font table.
typedef unsigned short CGFontIndex;
Discussion
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.
Availability
- Available in iOS 2.0 and later.
Declared In
CGFont.h
CGGlyph
An index into the internal glyph table of a font.
typedef unsigned short CGGlyph;
Discussion
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.
Availability
- Available in iOS 2.0 and later.
Declared In
CGFont.h
Constants
CGFontPostScriptFormat
Possible formats for a PostScript font subset.
enum CGFontPostScriptFormat { kCGFontPostScriptFormatType1 = 1, kCGFontPostScriptFormatType3 = 3, kCGFontPostScriptFormatType42 = 42 }; typedef enum CGFontPostScriptFormat CGFontPostScriptFormat;
Constants
-
This is documented in Adobe Type 1 Font Format, which is available from http://partners.adobe.com/.
Available in iOS 2.0 and later.
Declared in
CGFont.h
. -
This is documented in PostScript Language Reference, 3rd edition, which is available from http://partners.adobe.com/.
Available in iOS 2.0 and later.
Declared in
CGFont.h
. -
This is documented in Adobe Technical Note 5012, The Type 42 Font Format Specification, which is available fromhttp://partners.adobe.com/.
Available in iOS 2.0 and later.
Declared in
CGFont.h
.
kCGFontPostScriptFormatType1
kCGFontPostScriptFormatType3
kCGFontPostScriptFormatType42
Font Table Index Values
Possible values for an index into a font table.
enum { kCGFontIndexMax = ((1 << 16) - 2), kCGFontIndexInvalid = ((1 << 16) - 1), kCGGlyphMax = kCGFontIndexMax };
Constants
-
The maximum allowed value for
CGFontIndex
.Available in iOS 2.0 and later.
Declared in
CGFont.h
. -
An invalid font index (a value which never represents a valid glyph).
Available in iOS 2.0 and later.
Declared in
CGFont.h
. -
The same as
kCGFontIndexMax
.Available in iOS 2.0 and later.
Declared in
CGFont.h
.
kCGFontIndexMax
kCGFontIndexInvalid
kCGGlyphMax
Discussion
See CGFontIndex
.
Obsolete Font Table Index Values
Deprecated values for an index into a font table. (Deprecated. Use kCGGlyphMax
instead.)
enum { CGGlyphMin = 0, CGGlyphMax = kCGGlyphMax };
Constants
-
Minimum font index value.
Available in iOS 2.0 and later.
Declared in
CGFont.h
. -
Maximum font index value.
Available in iOS 2.0 and later.
Declared in
CGFont.h
.
CGGlyphMin
CGGlyphMax
Font Variation Axis Keys
Keys used for a font variation axis dictionary.
const CFStringRef kCGFontVariationAxisName const CFStringRef kCGFontVariationAxisMinValue const CFStringRef kCGFontVariationAxisMaxValue const CFStringRef kCGFontVariationAxisDefaultValue
Constants
-
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 iOS 2.0 and later.
Declared in
CGFont.h
. -
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 iOS 2.0 and later.
Declared in
CGFont.h
. -
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 iOS 2.0 and later.
Declared in
CGFont.h
. -
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 iOS 2.0 and later.
Declared in
CGFont.h
.
kCGFontVariationAxisName
kCGFontVariationAxisMinValue
kCGFontVariationAxisMaxValue
kCGFontVariationAxisDefaultValue