Platforms to show: All Mac Windows Linux Cross-Platform

Back to CTFontMBS class.

CTFontMBS.AdvancesForGlyphs(orientation as Integer, glyphs() as Integer) as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Calculates the advances for an array of glyphs and returns the summed advance.

font: The font reference.
orientation
The intended drawing orientation of the glyphs. Used to determined which glyph metrics to return.
glyphs: An array of count number of glyphs.
advances: An array of count number of CGSizeMBS objects to receive the computed glyph advances. Optional.

Returns the summed glyph advance of an array of glyphs.

Individual glyph advances are passed back via the advances parameter. These are the ideal metrics for each glyph scaled and transformed in font space.

See also:

CTFontMBS.AdvancesForGlyphs(orientation as Integer, glyphs() as Integer, boundingRects() as CGSizeMBS) as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Calculates the advances for an array of glyphs and returns the summed advance.

font: The font reference.
orientation
The intended drawing orientation of the glyphs. Used to determined which glyph metrics to return.
glyphs: An array of count number of glyphs.
advances: An array of count number of CGSizeMBS objects to receive the computed glyph advances. Optional.

Returns the summed glyph advance of an array of glyphs.

Individual glyph advances are passed back via the advances parameter. These are the ideal metrics for each glyph scaled and transformed in font space.

See also:

CTFontMBS.AttributeValue(key as string) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the value associated with an arbitrary attribute of the given font.

key: The requested attribute.

Returns attribute value or nil if the requested attribute is not present.
Available in OS X v10.5 and later.

CTFontMBS.AvailableTables(options as Integer) as String()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns an array of font table tags.

options: The font table options.

Returns an array of Font Table Tag Constants values for the given font and the supplied options.
Available in OS X v10.5 and later.

CTFontMBS.BoundingRectsForGlyphs(orientation as Integer, glyphs() as Integer) as CGRectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Calculates the bounding rects for an array of glyphs and returns the overall bounding rectangle for the glyph run.

font: The font reference.
orientation: The intended drawing orientation of the glyphs. Used to determined which glyph metrics to return.
glyphs: An array of count number of glyphs.
boundingRects: Optional. On output, the computed glyph rectangles in an array of count number of CGRect objects.

Returns the overall bounding rectangle for an array or run of glyphs. Returns CGRectNull on error.

The bounding rectangles of the individual glyphs are returned through the boundingRects parameter. These are the design metrics from the font transformed in font space.

See also:

CTFontMBS.BoundingRectsForGlyphs(orientation as Integer, glyphs() as Integer, boundingRects() as CGRectMBS) as CGRectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Calculates the bounding rects for an array of glyphs and returns the overall bounding rectangle for the glyph run.

font: The font reference.
orientation: The intended drawing orientation of the glyphs. Used to determined which glyph metrics to return.
glyphs: An array of count number of glyphs.
boundingRects: Optional. On output, the computed glyph rectangles in an array of count number of CGRect objects.

Returns the overall bounding rectangle for an array or run of glyphs. Returns CGRectNull on error.

The bounding rectangles of the individual glyphs are returned through the boundingRects parameter. These are the design metrics from the font transformed in font space.

See also:

CTFontMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The private constructor.

CTFontMBS.CreateCopyWithAttributes(size as Double, Matrix as CGAffineTransformMBS, fontAttributes as CTFontDescriptorMBS) as CTFontMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new font with additional attributes based on the original font.
Example
// find PostScript names for a font
const nameOfAFont = "Arial"

dim FontName as string
dim FontFamilyName as string
dim FontPostscriptName as string
dim FontPostscriptNameBold as string
dim FontPostscriptNameItalic as string

dim f as CTFontMBS = CTFontMBS.CreateWithName(nameOfAFont, 13)

if f <> nil then
FontName = f.FullName
FontFamilyName = f.FamilyName
FontPostscriptName = f.PostScriptName

dim d as CTFontDescriptorMBS = f.FontDescriptor

dim db as CTFontDescriptorMBS = CTFontDescriptorMBS.CreateCopyWithSymbolicTraits(d, CoreTextMBS.kCTFontTraitBold, CoreTextMBS.kCTFontTraitBold)
dim di as CTFontDescriptorMBS = CTFontDescriptorMBS.CreateCopyWithSymbolicTraits(d, CoreTextMBS.kCTFontTraitItalic, CoreTextMBS.kCTFontTraitItalic)

dim fb as CTFontMBS = f.CreateCopyWithAttributes(f.Size, nil, db)
dim fi as CTFontMBS = f.CreateCopyWithAttributes(f.Size, nil, di)

FontPostscriptNameBold = fb.PostScriptName
FontPostscriptNameItalic = fi.PostScriptName

end if

Break // read names in debugger

size: The point size for the font reference. If 0.0 is specified, the original font’s size is preserved.
matrix: The transformation matrix for the font. In most cases, set this parameter to be nil. If nil is specified, the original font's matrix is preserved.
fontAttributes: A font descriptor containing additional attributes that the new font should contain.

Returns a new font reference converted from the original with the specified attributes.

This function provides a mechanism to change attributes quickly on a given font reference in response to user actions. For instance, the size can be changed in response to a user manipulating a size slider.
Available in OS X v10.5 and later.

CTFontMBS.CreateForString(text as string, location as Integer, length as Integer) as CTFontMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new font reference that can best map the given string range based on the current font.

string: A unicode string containing characters that cannot be encoded by the current font.
location and length: The range of the string that needs to be mapped.

Returns the best substitute font from the cascade list of the current font that can encode the specified string range. If the current font is capable of encoding the string range, then it is retained and returned.

CTFontMBS.CreatePathForGlyph(glyph as Integer, transform as CGAffineTransformMBS) as CGPathMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a path for the specified glyph.

glyph: The glyph.
transform: An affine transform applied to the path. Can be nil. If nil, CGAffineTransformIdentity is used.

Returns a CGPath object containing the glyph outlines, nil on error. Must be released by caller.

Creates a path from the outlines of the glyph for the specified font. The path reflects the font point size, matrix, and transform parameter, applied in that order. The transform parameter is most commonly be used to provide a translation to the desired glyph origin.

CTFontMBS.CreateWithFamily(size as Double, Matrix as CGAffineTransformMBS, family as string) as CTFontMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new font in the specified family based on the traits of the original font.

size: The point size for the font reference. If 0.0 is specified, the original font’s size is preserved.
matrix: The transformation matrix for the font. In most cases, set this parameter to be nil. If nil is specified, the original font's matrix is preserved.
family: The name of the desired family.

Returns a new font reference with the original traits in the given family, or nil if none is found in the system.
Available in OS X v10.5 and later.

CTFontMBS.CreateWithSymbolicTraits(size as Double, Matrix as CGAffineTransformMBS, symTraitValue as Integer, symTraitMask as Integer) as CTFontMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new font in the same font family as the original with the specified symbolic traits.
Example
dim helveticaBold as CTFontMBS = CTFontMBS.CreateWithName("Helvetica-Bold", 12)
MsgBox helveticaBold.FullName

// now create similar fonts with

dim Trait as Integer = CoreTextMBS.kCTFontTraitItalic
dim TraitMask as Integer = CoreTextMBS.kCTFontTraitItalic+CoreTextMBS.kCTFontTraitBold

dim helveticaItalic as CTFontMBS = helveticaBold.CreateWithSymbolicTraits(12, nil, Trait, TraitMask)
MsgBox helveticaItalic.FullName

size: The point size for the font reference. If 0.0 is specified, the original font’s size is preserved.
matrix: The transformation matrix for the font. In most cases, set this parameter to be nil. If nil is specified, the original font's matrix is preserved.
symTraitValue: The value of the symbolic traits.
symTraitMask: The mask bits of the symbolic traits.

Returns a new font reference in the same family with the given symbolic traits. or nil if none is found in the system.

Available in OS X v10.5 and later.

CTFontMBS.DefaultCascadeListForLanguages(languagePrefList() as string) as String()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Return an ordered list of CTFontDescriptorMBS's for font fallback derived from the system default fallback region according to the given language preferences.

The style of the given is also matched as well as the weight and width of the font is not one of the system UI font, otherwise the UI font fallback is applied.

languagePrefList: The language preference list - ordered array of CFStringRef's of ISO language codes.

The ordered list of fallback fonts - ordered array of CTFontDescriptors.

CTFontMBS.Draw(glyphs() as Integer, positions() as CGPointMBS, context as CGContextMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Renders the given glyphs of a font at the specified positions in the supplied graphics context.

font: The font with glyphs to render. If the font has a size or matrix attribute, context is set with these values.
glyphs: The glyphs to be rendered. The glyphs should be the result of proper Unicode text layout operations (such as with CTLine). Functions such as CTFontMBS.GetGlyphsForCharacters do not perform any Unicode text layout.
positions: The positions (origins) for each glyph in glyphs. The positions are in user space. The number of positions passed in must match the number of glyphs (in glyphs).
context: The graphics context used to render the glyphs.

This function modifies graphics state including font, text size, and text matrix if these attributes are specified in font. These attributes are not restored.

Available in OS X v10.7 and later.

CTFontMBS.Features as Dictionary()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns an array of font features.

Returns an array of font feature dictionaries for the font reference.

CTFontMBS.FeatureSettings as Dictionary()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns an array of font feature-setting tuples.

Returns a normalized array of font feature-setting dictionaries. The array contains only the non-default settings that should be applied to the font, or nil if the default settings should be used.

A feature-setting dictionary is a tuple of a kCTFontFeatureTypeIdentifierKey key-value pair and a kCTFontFeatureSelectorIdentifierKey key-value pair. Each setting dictionary indicates which setting is enabled. It is the caller's responsibility to handle exclusive and nonexclusive settings as necessary.

The feature settings are verified against those that the font supports and any that do not apply are removed. Further, feature settings that represent a default setting for the font are also removed.

CTFontMBS.GlyphsForCharacters(characters() as Integer) as Integer()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Provides basic Unicode encoding for the given font, returning by reference an array of CGGlyph values corresponding to a given array of Unicode characters for the given font.

If a glyph could not be encoded, a value of 0 is passed back at the corresponding index in the glyphs array and the function returns False. It is the responsibility of the caller to handle the Unicode properties of the input characters.

CTFontMBS.GlyphWithName(name as string) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the CGGlyph value for the specified glyph name in the given font.

Name: The glyph name as a CFString object.

Returns the glyph value for the named glyph as a CGGlyph object, or if the glyph name is not recognized, the .notdef glyph index value.
The returned CGGlyph object can be used with any of the subsequent glyph data accessors or directly with Core Graphics.

CTFontMBS.GraphicsFont(byref fontAttributes as CTFontDescriptorMBS) as CGFontMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a Core Graphics font reference and attributes.

attributes: On output, points to a font descriptor containing additional attributes from the font.

Returns a CGFontMBS object for the given font reference.

CTFontMBS.LigatureCaretPositions(glyph as Integer) as Double()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns caret positions within a glyph.

glyph: A reference to the glyph.

This function is used to obtain caret positions for a specific glyph. The return value is the maximum number of positions possible, and the function will populate the caller's positions buffer with available positions if possible. This function might not be able to produce positions if the font does not have the appropriate data, in which case it will return 0.

CTFontMBS.Name(nameKey as string) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a reference to the requested name of the given font.
Example
dim c as CTFontMBS = CTFontMBS.CreateWithName("Times", 12)
MsgBox c.name(CTFontMBS.kCTFontFullNameKey)

nameKey: The name specifier. See Name Specifier Constants for possible values.

Returns The requested name for the font, or "" if the font does not have an entry for the requested name. The Unicode version of the name is preferred, otherwise the first available version is returned.

See also:

CTFontMBS.Name(nameKey as string, byref language as string) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a reference to a localized name for the given font.
Example
dim c as CTFontMBS = CTFontMBS.CreateWithName("Times", 12)
dim lang as string
MsgBox c.name(CTFontMBS.kCTFontFullNameKey, lang)+EndOfLine+lang
// shows name and "en" as language.

nameKey: The name specifier. See Name Specifier Constants for possible values.
language: On output, points to the language string of the returned name string. The format of the language identifier conforms to the RFC 3066bis standard.

Returns a specific localized name from the font reference or "" if the font does not have an entry for the requested name key.

The name is localized based on the user's global language preference precedence. That is, the user’s language preference is a list of languages in order of precedence. So, for example, if the list had Japanese and English, in that order, then a font that did not have Japanese name strings but had English strings would return the English strings.

Available in OS X v10.5 and later.

See also:

CTFontMBS.OpticalBoundsForGlyphs(glyphs() as Integer, boundingRects() as CGRectMBS, options as Integer = 0) as CGRectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Calculates the optical bounding rects for an array of glyphs and returns the overall optical bounding rect for the run.

Fonts may specify the optical edges of glyphs that can be used to make the edges of lines of text line up in a more visually pleasing way. This function returns bounding rects corresponding to this information if present in a font, otherwise it returns typographic bounding rects (composed of the font's ascent and descent and a glyph's advance width).

font: The font reference.
glyphs: An array of count number of glyphs.
boundingRects: An array of count number of CGRects to receive the computed glyph rects. Can be nil, in which case only the overall bounding rect is calculated.
options: Reserved, set to zero.

This function returns the overall bounding rectangle for an array or run of glyphs. The bounding rects of the individual glyphs are returned through the boundingRects parameter. These are the design metrics from the font transformed in font space.

See also:

CTFontMBS.OpticalBoundsForGlyphs(glyphs() as Integer, options as Integer = 0) as CGRectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Calculates the optical bounding rects for an array of glyphs and returns the overall optical bounding rect for the run.

Fonts may specify the optical edges of glyphs that can be used to make the edges of lines of text line up in a more visually pleasing way. This function returns bounding rects corresponding to this information if present in a font, otherwise it returns typographic bounding rects (composed of the font's ascent and descent and a glyph's advance width).

font: The font reference.
glyphs: An array of count number of glyphs.
boundingRects: An array of count number of CGRects to receive the computed glyph rects. Can be nil, in which case only the overall bounding rect is calculated.
options: Reserved, set to zero.

This function returns the overall bounding rectangle for an array or run of glyphs. The bounding rects of the individual glyphs are returned through the boundingRects parameter. These are the design metrics from the font transformed in font space.

See also:

CTFontMBS.PlatformFont(byref fontAttributes as CTFontDescriptorMBS) as Integer   Deprecated

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
This item is deprecated and should no longer be used.
Returns an ATS font reference and attributes.

CTFontMBS.SupportedLanguages as String()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns an array of languages supported by the font.
Example
dim c as CTFontMBS = CTFontMBS.CreateWithName("Times", 12)
MsgBox Join(c.SupportedLanguages,EndOfLine)

CTFontMBS.Table(table as string, options as Integer) as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a reference to the font table data.

table: The font table identifier as a Font Table Tag Constants constant. See Font Table Tag Constants for possible values.
options: The font table options.

Returns a retained reference to the font table data as a Memoryblock.

CTFontMBS.VariationAxes as Dictionary()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns an array of variation axes.

An array of variation axes dictionaries. Each variation axis dictionary contains the five variation axis keys listed in Font Variation Axis Dictionary Keys.

CTFontMBS.VerticalTranslationsForGlyphs(glyphs() as Integer) as CGSizeMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Calculates the offset from the default (horizontal) origin to the vertical origin for an array of glyphs.

glyphs: An array of count number of glyphs.
Returns the computed origin offsets in an array of count number of CGSizeMBS objects.

The items on this page are in the following plugins: MBS MacCG Plugin.


The biggest plugin in space...