Closed Digifais closed 5 years ago
/cc @yourina and @jkpu , PTAL
Could you write your code of label that used the custom font(Lato font). Above code snippet has only including font resource using "Utility.AppendGlobalFontPath". In the guide, custom font postscriptname (e.g YiSunShinBold) should be inserted at Label code. please refer to below code.
new Label {
HorizontalTextAlignment = TextAlignment.Center,
FontFamily = "YiSunShinBold",
Text = "Welcome to Xamarin Forms!"
}
$fc-query ./Lato-Bold.ttf
Pattern has 22 elts (size 32)
family: "Lato"(s)
familylang: "en"(s)
style: "Bold"(s)
stylelang: "en"(s)
fullname: "Lato Bold"(s)
.............................
decorative: False(s)
hash: "sha256:14f7de6b616950395062902eb8f70f01c0a901223db5d40f2a05728ac4a830f6"(s)
postscriptname: "Lato-Bold"(s)
You should insert FontFamily value with "Lato-Bold".
new Label {
HorizontalTextAlignment = TextAlignment.Center,
FontFamily = "Lato-Bold",
Text = "Welcome to Xamarin Forms!"
}
I am using XAML to build my layouts though. You can see an example snippet below which doesn't work either.
<Label
Style="{StaticResource StyleBodyText}"
FontFamily="Lato-Regular"
Text="Test" />
When I have tested with following to the guide. Custom font is working properly But only Lato font was not applied.
device default font
Yisunshin font
Lato font
Bloomsburg font
I'm attaching my test app code. please refer to the following code.
When I have tested more font file with downloading from the internet. Some font file was not applied as "postscriptname". I found the way fixing this problem. Setting FontFamily property with real family name will work properly. and style can be set with FontAttribute property. (But Xamarin's FontAttribute property is enum value, so only enum value(Regular, Bold, Italic) can be applied ) Please refer to following code and attached test app code. You can find the way appliying your custom font.
<Label Text="Lato Regular"
FontFamily="Lato" />
<Label Text="Lato Bold"
FontFamily="Lato"
FontAttributes="Bold" />
<Label Text="Lato BoldItalic"
FontFamily="Lato"
FontAttributes="Bold, Italic" />
Thanks for the amazing support jkpu, I can confirm this does work!
Custom fonts are not working in Tizen .NET as described by the following guide: https://samsung.github.io/Tizen.CircularUI/guide/HowToSetTheCustomFont.html
I add the resources path as a global font path as described in the guide and then try to set the FontFamily of a Label control in XAML to the PostScript name of the font as described in the guide, but it doesn't do anything.
You can find the fonts in this ZIP file attached here: Lato Fonts.zip