Platforms to show: All Mac Windows Linux Cross-Platform

Back to CTFontDescriptorMBS class.

CTFontDescriptorMBS.Available as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Whether this class is available.

Returns true in OS X v10.5 and later.

CTFontDescriptorMBS.CreateCopyWithFamily(orignal as CTFontDescriptorMBS, family as String) as CTFontDescriptorMBS

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

original: The original font descriptor reference.
family: The name of the desired family.

Returns a new font reference with the original traits in the given family, or nil if none found in the system.

CTFontDescriptorMBS.CreateCopyWithSymbolicTraits(orignal as CTFontDescriptorMBS, symTraitValue as Integer, symTraitMask as Integer) as CTFontDescriptorMBS

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

Var FontName as string
Var FontFamilyName as string
Var FontPostscriptName as string
Var FontPostscriptNameBold as string
Var FontPostscriptNameItalic as string

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

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

Var d as CTFontDescriptorMBS = f.FontDescriptor

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

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

FontPostscriptNameBold = fb.PostScriptName
FontPostscriptNameItalic = fi.PostScriptName

end if

Break // read names in debugger

original: The original font descriptor reference.
symTraitValue: The value of the symbolic traits. This bitfield is used to indicate the desired value for the traits specified by the symTraitMask parameter. Used in conjunction, they can allow for trait removal as well as addition.
symTraitMask: The mask bits of the symbolic traits. This bitfield is used to indicate the traits that should be changed.

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

Requires Mac OS X 10.9 or newer.

CTFontDescriptorMBS.CreateWithAttributes(attributeValues as Dictionary) as CTFontDescriptorMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new font descriptor reference from a dictionary of attributes.

The provided attribute dictionary can contain arbitrary attributes that are preserved; however, unrecognized attributes are ignored on font creation and and may not be preserved over the round trip from descriptor to font and back to descriptor.

CTFontDescriptorMBS.CreateWithNameAndSize(Name as string, Size as Double = 0.0) as CTFontDescriptorMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method CoreText MBS MacCG Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new font descriptor with the provided PostScript name and size.
Example
Var c as CTFontDescriptorMBS = CTFontDescriptorMBS.CreateWithNameAndSize("Times", 12)
MsgBox c.AttributeValue(c.kCTFontFamilyNameAttribute)

name: The PostScript name to be used for the font descriptor as a string.
size: The point size. If 0.0, the font size attribute (kCTFontSizeAttribute) is omitted from the returned font descriptor.

Return sa new font descriptor reference with the given PostScript name and point size.

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


The biggest plugin in space...