Xojo 2020r2 introduced the new Font class to deal with any font that you want to use in your iOS apps. The Constructor method for the class receives the font name (the PostScript one) and the font size.
You can find fonts on websites like iosfonts.com. But wouldn’t it be great to access these directly from code? Let’s learn how your iOS app can offer the user the option to select the font they want from a list (or any other UI control of your choice) just like in Desktop apps.
To do this, use a little helper class included in the iOS example project (download from this link). This class uses the Singleton pattern, and if a font is not installed on the iOS version of the device running the app, then it fallbacks to the default font used in iOS.
With this class at hand, you only need to call the shared method:
iOSSystemFonts.Fonts As String()
In order to receive an Array of Strings containing the name of the fonts. The class also provides the following shared methods:
iOSSystemFonts.FontCount As Integer
iOSSystemFonts.LastFontIndex As Integer
iOSSystemFonts.FontAt(Index As Integer, Optional size As Integer = 0) As Font
To try this out for yourself, download and run the sample project.