Font

From Xojo Documentation
Jump to: navigation, search
Method

Used to access the names the installed fonts (0-based).


Syntax

result=Font(index)

Part Type Description
result String The name of the font whose index number is passed. Result is in the appropriate WorldScript encoding.
index Integer The number of the font (0-based).

Notes

Fonts are accessed in alphabetical order where font 0 is the first font. Use the FontCount function to determine the number of fonts.

Under Mac OS X Cocoa, Font returns font families instead of fonts. This is closer to the Carbon behavior, but it does not return identical results.

Using Custom Fonts in your Applications

Both OS X and Windows have techniques for loading fonts for a specific application.

On OS X, you can use ATSApplicationFontsPath key in Info.plist. You add this key, specifying the relative path of the fonts in the Resources folder of your app bundle.

For Windows, the open-source Windows Functionality Suite provides a method (TemporarilyInstallFont) to do this.

Examples

This is an example of a function that determines if the font named passed is installed on the user’s computer:

Function FontAvailable(FontName As String) as Boolean
Dim fc As Integer
fc = FontCount-1

For i As Integer = 0 To fc
If Font(i) = FontName Then
Return True
End If
Next
Return False
End Function

See Also

FontCount function.

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About