The size values are measured in device-independent units.
Helvetica font android windows#
The following table shows the NamedSize members, and their default sizes on iOS, Android, and the Universal Windows Platform (UWP): Member Xamarin.Forms defines fields in the NamedSize enumeration that represent specific font sizes. For information about the OnPlatform markup extension, see OnPlatform markup extension. Label.FontFamily = Device.RuntimePlatform = Device.iOS ? "MarkerFelt-Thin" :ĭevice.RuntimePlatform = Device.Android ? "Lobster-Regular" : "ArimaMadurai-Black" įor more information about providing platform-specific values, see Provide platform-specific values. Label.FontSize = Device.RuntimePlatform = Device.iOS ? 20 :ĭevice.RuntimePlatform = Device.Android ? Device.GetNamedSize(NamedSize.Medium, label) : 24 Text = "Different font properties on different platforms"
Helvetica font android code#
The Device.RuntimePlatform property can be used in code to set font properties per platform Label label = new Label The example below sets different font families and sizes on each platform: The OnPlatform and On classes can be used in XAML to set font properties per platform. For more information, see Troubleshooting. The following example shows the Lobster-Regular font being registered with the assembly, along with an alias: using Xamarin.Forms įor release builds on Windows, ensure the assembly containing the custom font is passed as an argument in the Forms.Init method call. Register the font file with the assembly, in a file such as AssemblyInfo.cs, using the ExportFont attribute.Add the font to your Xamarin.Forms shared project as an embedded resource ( Build Action: EmbeddedResource).The process for accomplishing this is as follows: Therefore, the most reliable approach for specifying a font family is to use a custom font.Ĭustom fonts can be added to your Xamarin.Forms shared project and consumed by platform projects without any additional work. In addition, the fonts installed on a platform can change with platform version. However, the presence of a TTF (True Type Format) font file does not necessarily imply a font family, and TTFs are often included that are not intended for use in applications. There are a number of techniques that can be used to attempt to derive the fonts that are available on a platform. However, this will only work if that font family is supported on the particular platform. Set the font familyĬontrols that display text can set the FontFamily property to a font family name, such as "Times Roman". For more information, see Units of Measurement.įor more information about named font sizes, see Understand named font sizes. The FontSize value, when specified as a double, is measured in device-independent units.
MyLabel.FontSize = Device.GetNamedSize(NamedSize.Large, myLabel) The FontSize property can be set to a double value directly, or by a NamedSize enumeration value: įontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))Īlternatively, the Device.GetNamedSize method has an override that specifies the second argument as an Element: Label myLabel = new Label The equivalent C# code is: Label label1 = new LabelįontAttributes = FontAttributes.Bold | FontAttributes.ItalicĬontrols that display text can set the FontSize property to specify the font size. Set font attributesĬontrols that display text can set the FontAttributes property to specify font attributes: These properties are backed by BindableProperty objects, which means that they can be targets of data bindings, and styled. The default value of this property is None.
FontAttributes, of type FontAttributes, which is an enumeration with three members: None, Bold, and Italic.However, controls that display text define properties that you can use to change this font: By default, Xamarin.Forms uses a system font defined by each platform.