Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

Next items

NSFontManagerMBS.addCollection(collectionName as String, Options as Integer = 0) as Boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 17.3 Yes No No Yes, macOS only No
Function: Adds a specified font collection to the font manager with a given set of options.
Notes:
collectionName: The collection to add.
Options: Pass NSFontCollectionApplicationOnlyMask to make the collection available only to the application.
Return true if the font collection was successfully added; otherwise, false.

Feedback, Comments & Corrections

NSFontManagerMBS.addFontDescriptorsToCollection(descriptors() as NSFontDescriptorMBS, collectionName as String)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 17.3 Yes No No Yes, macOS only No
Function: Adds an array of font descriptors to the specified font collection.
Example:
dim fontManager as NSFontManagerMBS = NSFontManagerMBS.sharedFontManager

dim collectionNames() as string = fontManager.collectionNames
dim collectionName as string = collectionNames(collectionNames.Ubound) // get last one

dim fonts() as NSFontDescriptorMBS = fontManager.fontDescriptorsInCollection(collectionName)

// add Helvetica to this collection

dim font as NSFontMBS = NSFontMBS.fontWithName("Helvetica", 12)
dim fontDescriptor as NSFontDescriptorMBS = font.fontDescriptor

fontManager.addFontDescriptorsToCollection(array(fontDescriptor), collectionName)

dim fonts2() as NSFontDescriptorMBS = fontManager.fontDescriptorsInCollection(collectionName)

// fonts2 should have one more entry than fonts
Break
Notes:
descriptors: The font descriptors to add.
collectionName: The font collection to which descriptors are added.

Feedback, Comments & Corrections

NSFontManagerMBS.availableFontFamilies as string()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: Returns the names of the font families available in the system.
Example:
dim n as new NSFontManagerMBS
dim names() as string = n.availableFontFamilies

MsgBox Join(names,EndOfLine)
Notes: These fonts are in various system font directories.

Feedback, Comments & Corrections

NSFontManagerMBS.availableFontNamesMatchingFontDescriptor(descriptor as NSFontDescriptorMBS) as String()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 17.3 Yes No No Yes, macOS only No
Function: Returns the names of the fonts that match the attributes in the given font descriptor.

Feedback, Comments & Corrections

NSFontManagerMBS.availableFontNamesWithTraits(traits as Integer) as string()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.0 Yes No No Yes, macOS only No
Function: Returns the names of the fonts available in the system whose traits are described exactly by the given font trait mask (not the NSFont objects themselves).
Example:
dim n as new NSFontManagerMBS
dim names() as string = n.availableFontNamesWithTraits(n.NSBoldFontMask)

MsgBox str(UBound(names)+1)+" fonts: "+Join(names,", ")
Notes:
traits: The font traits for which to return font names. You specify the desired traits by combining the font trait mask values described in Constants using the bitwiseor operator.

Returns the names of the corresponding fonts.

These fonts are in various system font directories.

If fontTraitMask is 0, this method returns all fonts that are neither italic nor bold. This result is the same one you'd get if fontTraitMask were NSUnitalicFontMask | NSUnboldFontMask.

Feedback, Comments & Corrections

NSFontManagerMBS.availableFonts as string()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: Returns the names of the fonts available in the system (not the NSFont objects themselves).
Example:
dim n as new NSFontManagerMBS
dim names() as string = n.availableFonts

MsgBox Join(names,EndOfLine)
Notes: These fonts are in various system font directories.

Feedback, Comments & Corrections

NSFontManagerMBS.availableMembersOfFontFamily(FontFamily as string) as Variant()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: Returns an array with one entry for each available member of a font family.
Example:
dim n as new NSFontManagerMBS
dim members() as Variant = n.availableMembersOfFontFamily("Times")

for each m as Variant in members
dim member() as Variant = m

MsgBox "Postscript name: "+member(0)+EndOfLine+"Suffix: "+member(1)+EndOfLine+"Font weight: "+member(2)+EndOfLine+"Font trait: "+member(3)
next
Notes:
family: The name of a font family, like one that availableFontFamilies returns.

Returns the available members of family.

Each entry of the returned variant array is another variant array with four members, as follows:

0.The PostScript font name, as a string.
1.The part of the font name used in the font panel that's not the font name, as a string. This value is not localized—for example, "Roman", "Italic", or "Bold".
2.The font's weight, as a double.
3.The font's traits, as a double.

The members of the family are arranged in the font panel order (narrowest to widest, lightest to boldest, plain to italic).

Feedback, Comments & Corrections

NSFontManagerMBS.collectionNames as string()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 11.3 Yes No No Yes, macOS only No
Function: Returns the names of the currently loaded font collections.
Example:
dim n as new NSFontManagerMBS
dim names() as string = n.collectionNames

MsgBox Join(names,EndOfLine)
Notes: The names of the current font collections.

Feedback, Comments & Corrections

NSFontManagerMBS.Constructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Initializes the object with the shared instance of the font manager for the application, creating it if necessary.

Feedback, Comments & Corrections

NSFontManagerMBS.convertAttributes(dic as dictionary) as dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Converts attributes in response to an object initiating an attribute change, typically the Font panel or Font menu.

Feedback, Comments & Corrections

NSFontManagerMBS.convertFont(font as NSFontMBS) as NSFontMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Converts the given font according to the object that initiated a font change, typically the Font panel or Font menu.

Feedback, Comments & Corrections

NSFontManagerMBS.convertFontToFace(font as NSFontMBS, face as string) as NSFontMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Returns a font whose traits are as similar as possible to those of the given font except for the typeface, which is changed to the given typeface.
Example:
dim fontManager as new NSFontManagerMBS
// you have a font
dim font as NSFontMBS = NSFontMBS.fontWithName("Helvetica", 12)

// change font face
font = fontManager.convertFontToFace(font, "Helvetica-BoldOblique")

MsgBox font.fontName // shows Helvetica-BoldOblique
Notes:
Font: The font whose traits are matched.
face: The new typeface; a fully specified family-face name, such as Helvetica-BoldOblique or Times-Roman.

Returns a font with matching traits and the given typeface, or aFont if it can't be converted.

This method attempts to match the weight and posture of aFont as closely as possible. Italic is mapped to Oblique, for example. Weights are mapped based on an approximate numeric scale of 0 to 15.

Feedback, Comments & Corrections

NSFontManagerMBS.convertFontToFamily(font as NSFontMBS, family as string) as NSFontMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Returns a font whose traits are as similar as possible to those of the given font except for the font family, which is changed to the given family.
Example:
dim fontManager as new NSFontManagerMBS
// you have a font
dim font as NSFontMBS = NSFontMBS.fontWithName("Helvetica", 12)

// change font family
font = fontManager.convertFontToFamily(font, "Arial")

MsgBox font.fontName // shows ArialMT
Notes:
Font: The font whose traits are matched.
family: The new font famliy; a generic font name, such as Helvetica or Times.

Returns a font with matching traits and the given family, or aFont if it can't be converted.

This method attempts to match the weight and posture of aFont as closely as possible. Italic is mapped to Oblique, for example. Weights are mapped based on an approximate numeric scale of 0 to 15.

Feedback, Comments & Corrections

NSFontManagerMBS.convertFontToHaveTrait(font as NSFontMBS, trait as Integer) as NSFontMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.0 Yes No No Yes, macOS only No
Function: Returns a font whose traits are the same as those of the given font, except that the traits are changed to include the single specified trait.
Example:
dim n as new NSFontManagerMBS
dim f as NSFontMBS = NSFontMBS.fontWithName("Times", 12.0)
dim g as NSFontMBS = n.convertFontToHaveTrait(f, n.NSBoldFontMask)

MsgBox g.fontName // Times-Bold
Notes:
Font: The font whose traits are matched.
Trait: The new trait; may be any one of the traits described in Constants. Using NSUnboldFontMask or NSUnitalicFontMask removes the bold or italic trait, respectively.

Returns a font with matching traits including the given trait, or font if it can't be converted.
Using NSUnboldFontMask or NSUnitalicFontMask removes the bold or italic trait, respectively.

Feedback, Comments & Corrections

NSFontManagerMBS.convertFontToNotHaveTrait(font as NSFontMBS, trait as Integer) as NSFontMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.0 Yes No No Yes, macOS only No
Function: Returns an NSFont object with the same traits as the given font, except for the traits in the given font trait mask, which are removed.
Example:
dim n as new NSFontManagerMBS
dim f as NSFontMBS = NSFontMBS.fontWithName("Times-Bold", 12.0)
dim g as NSFontMBS = n.convertFontToHaveTrait(f, n.NSUnBoldFontMask)

MsgBox g.fontName // Times-Roman
Notes:
Font: The font whose traits are matched.
trait: The mask for the traits to remove, created using the bitwiseOr operator to combine the traits described in Constants. Using NSUnboldFontMask or NSUnitalicFontMask removes the bold or italic trait, respectively.
Returns a font with matching traits minus the given traits, or font if it can't be converted.

Feedback, Comments & Corrections

NSFontManagerMBS.convertFontToSize(font as NSFontMBS, size as Double) as NSFontMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Returns an NSFont object whose traits are the same as those of the given font, except for the size, which is changed to the given size.
Example:
dim fontManager as new NSFontManagerMBS
// you have a font
dim font as NSFontMBS = NSFontMBS.fontWithName("Helvetica", 12)

// change font size
font = fontManager.convertFontToSize(font, 20)

MsgBox str(font.pointSize)
Notes:
Font: The font whose traits are matched.
size: The new font size.

Returns a font with matching traits except in the new size, or aFont if it can't be converted.

Feedback, Comments & Corrections

NSFontManagerMBS.convertFontTraits(traits as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.0 Yes No No Yes, macOS only No
Function: Converts font traits to a new traits mask value.
Notes:
traits: The current font traits.

Returns the new traits mask value to be used by convertFont:.

This method is intended to be invoked to query the font traits while the action message (usually changeFont:) is being invoked when the current font action is either NSAddTraitFontAction or NSRemoveTraitFontAction.

Available in Mac OS X v10.5 and later.

Feedback, Comments & Corrections

NSFontManagerMBS.convertWeightOfFont(font as NSFontMBS, up as boolean) as NSFontMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.0 Yes No No Yes, macOS only No
Function: Returns an NSFont object whose weight is greater or lesser than that of the given font, if possible.
Example:
dim n as new NSFontManagerMBS
dim f as NSFontMBS = NSFontMBS.fontWithName("Times", 12.0)
dim g as NSFontMBS = n.convertWeightOfFont(f, true)

MsgBox g.fontName // Times-Bold
Notes:
up: If true, a heavier font is returned; if it's false, a lighter font is returned.
Font: The font whose weight is increased or decreased.

Returns a font with matching traits except for the new weight, or font if it can't be converted.

Feedback, Comments & Corrections

NSFontManagerMBS.Enabled as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Whether the font conversion system's user interface items (the Font panel and Font menu items) are enabled.
Notes:
True if the font conversion system's user interface items (the Font panel and Font menu items) are enabled; false if they're not.
(Read and Write computed property)

Feedback, Comments & Corrections

NSFontManagerMBS.fontDescriptorsInCollection(collectionName as String) as NSFontDescriptorMBS()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 17.3 Yes No No Yes, macOS only No
Function: Returns an array of the font descriptors in the collection specified by the given collection name.
Example:
dim fontManager as NSFontManagerMBS = NSFontManagerMBS.sharedFontManager
dim collectionNames() as string = fontManager.collectionNames
dim collectionName as string = collectionNames(collectionNames.Ubound) // get last one
dim fonts() as NSFontDescriptorMBS = fontManager.fontDescriptorsInCollection(collectionName)
Break

Feedback, Comments & Corrections

NSFontManagerMBS.fontHasTraits(fontName as string, Traits as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.2 Yes No No Yes, macOS only No
Function: Indicates whether the given font has all the specified traits.
Example:
dim n as NSFontMBS = NSFontMBS.boldSystemFontOfSize(12)
dim m as new NSFontManagerMBS

dim isBold as Boolean = m.fontHasTraits(n.fontName, m.NSBoldFontMask)
dim isItalic as Boolean = m.fontHasTraits(n.fontName, m.NSItalicFontMask)

MsgBox "is bold: "+str(isBold)+_
EndOfLine+"is italic: "+str(isItalic)
Notes:
typeface: The name of the font.
fontTraitMask: The font traits to test, specified by combining the font trait mask values described in Constants using the bitwiseOR operation.

Returns true if the font named typeface has all the traits specified in fontTraitMask; false if it doesn't.

Using NSUnboldFontMask returns true if the font is not bold, false otherwise. Using NSUnitalicFontMask returns true if the font is not italic, false otherwise.

Feedback, Comments & Corrections

NSFontManagerMBS.isMultiple as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Indicates whether the last font selection recorded has multiple fonts.
Notes: Returns true if the last font selection recorded has multiple fonts; false if it's a single font.

Feedback, Comments & Corrections

NSFontManagerMBS.orderFrontFontPanel
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 16.4 Yes No No Yes, macOS only No
Function: This action method opens the Font panel by sending it an orderFront message, creating the Font panel if necessary.

Feedback, Comments & Corrections

NSFontManagerMBS.orderFrontStylesPanel
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 16.4 Yes No No Yes, macOS only No
Function: This action method opens the Font styles panel.

Feedback, Comments & Corrections

NSFontManagerMBS.removeCollection(collectionName as String) as Boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 17.3 Yes No No Yes, macOS only No
Function: Removes the specified font collection.
Notes: Returns true on success and false on failure.

Feedback, Comments & Corrections

NSFontManagerMBS.removeFontDescriptorFromCollection(descriptor as NSFontDescriptorMBS, collectionName as String)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 17.3 Yes No No Yes, macOS only No
Function: Removes the specified font descriptor from the specified collection.
Notes:
descriptor: The font descriptor to remove.
collection: The font collection from which to remove the descriptor.

Feedback, Comments & Corrections

NSFontManagerMBS.selectedFont as NSFontMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Returns the last font recorded.

Feedback, Comments & Corrections

NSFontManagerMBS.setSelectedAttributes(dic as dictionary, isMultiple as boolean)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Informs the paragraph and character formatting panels when text in a selection has changed attributes.
Notes:
dic: The new attributes.
isMultiple: If true, informs the panel that multiple fonts or attributes are enclosed within the selection.

This method is used primarily by NSTextView.
Available in Mac OS X v10.3 and later.

Feedback, Comments & Corrections

NSFontManagerMBS.setSelectedFont(font as NSFontMBS, isMultiple as boolean)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 9.8 Yes No No Yes, macOS only No
Function: Records the given font as the currently selected font and updates the Font panel to reflect this.
Notes:
font: The font to set as selected.
isMultiple: If true, the Font panel indicates that more than one font is contained in the selection; if false, it does not.

An object that manipulates fonts should invoke this method whenever it becomes first responder and whenever its selection changes. It shouldn't invoke this method in the process of handling a changeFont message, as this causes the font manager to lose the information necessary to effect the change. After all fonts have been converted, the font manager itself records the new selected font.

Feedback, Comments & Corrections

Next items

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




Links
MBS Xojo Plugins