Black Berry Friday Gap New Jumper rIwqrH7Bx

In this article

This article describes how Xamarin.Forms lets you specify font attributes (including weight and size) on controls that display text. Font information can be specified in code or specified in XAML. It is also possible to use a custom font.

Setting Font in Code

Use the three font-related properties of any controls that display text:

Setting the Font in XAML

Xamarin.Forms controls that display text all have a Font property that can be set in XAML. The simplest way to set the font in XAML is to use the named size enumeration values, as shown in this example:

There is a built-in converter for the Font property that allows all font settings to be expressed as a string value in XAML. The following examples show how you can specify font attributes and sizes in XAML:

To specify multiple Font settings, combine the required settings into a single Font attribute string. The font attribute string should be formatted as "[font-face],[attributes],[size]". The order of the parameters is important, all parameters are optional, and multiple attributes can be specified, for example:

Device.RuntimePlatform can also be used in XAML to render a different font on each platform. The example below uses a custom font face on iOS (MarkerFelt-Thin) and specifies only size/attributes on the other platforms:

Android

Xamarin.Forms for Android can reference a custom font that has been added to the project by following a specific naming standard. First add the font file to the Assets folder in the application project and set Build Action: AndroidAsset. Then use the full path and Font Name separated by a hash (#) as the font name in Xamarin.Forms, as the code snippet below demonstrates:

Windows

Xamarin.Forms for Windows platforms can reference a custom font that has been added to the project by following a specific naming standard. First add the font file to the New Jumper Black Berry Friday Gap /Assets/Fonts/ folder in the application project and set the Build Action:Content. Then use the full path and font filename, followed by a hash (#) and the Font Name, as the code snippet below demonstrates:

Note that the font file name and font name may be different. To discover the font name on Windows, right-click the .ttf file and select Preview. The font name can then be determined from the preview window.

The common code for the application is now complete. Platform-specific phone dialer code will now be implemented as a DependencyService.

Summary

Xamarin.Forms provides simple default settings to let you size text easily for all supported platforms. It also lets you specify font face and size – even differently for each platform – when more fine-grained control is required.

Font information can also be specified in XAML using correctly formatted font attributes.