Example: /MacCocoa/Fonts and Font Families

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Fonts and Font Families


Required plugins for this example: MBS MacBase Plugin, MBS MacOSX Plugin, MBS Main Plugin, MBS MacCocoa Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/Fonts and Font Families

This example is the version from Fri, 23th May 2013.

Project "Fonts and Font Families.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub Change() if me.ListIndex < 0 then FontPath.Text = "" else FontPath.text = me.Cell(me.ListIndex,3) end if End EventHandler
EventHandler Sub ExpandRow(row As Integer) dim fontFamilyName as string = me.Cell(row,0) dim members() as variant = fontManager.availableMembersOfFontFamily(fontFamilyName) for each m as Variant in members dim member() as Variant = m dim PostscriptName as string = member(0) dim suffix as string = member(1) dim FontWeight as double = member(2) dim FontTrait as string = member(3) dim n as NSFontMBS = NSFontMBS.fontWithName(PostscriptName, 12) if n<>Nil then dim file as FolderItem = n.file dim filepath as string dim filename as string if file<>Nil then filepath = file.UnixpathMBS filename = file.name end if me.AddRow suffix, PostscriptName, filename, filepath end if next End EventHandler
End Control
Control FontPath Inherits TextField
ControlInstance FontPath Inherits TextField
End Control
EventHandler Sub Open() fontManager = new NSFontManagerMBS dim fontFamilyNames() as string = fontManager.availableFontFamilies for each fontFamilyName as string in fontFamilyNames list.AddFolder fontFamilyName dim n as NSFontMBS = NSFontMBS.fontWithName(fontFamilyName, 12) if n<>nil then dim file as FolderItem = n.file dim filepath as string dim filename as string if file<>Nil then filepath = file.UnixpathMBS filename = file.name end if list.Cell(List.LastIndex,1) = n.fontName list.Cell(List.LastIndex,2) = filename list.Cell(List.LastIndex,3) = filepath end if List.Expanded(List.LastIndex) = true next End EventHandler
Property fontManager As NSFontManagerMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

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


💬 Ask a question or report a problem