我想在可移植文件夾(不是iOS和安卓)的xamarinforms中的xaml
文件中使用自定義字體,該文件爲所有此平臺獲取輸出。在xamarin表格中使用自定義字體
0
A
回答
3
- 如解釋here所示,將字體添加到您的平臺中。
創建一個平臺像反映了一個字體樣式:
<OnPlatform x:Key="NormalFont" x:TypeArguments="x:String" iOS="Montserrat" Android="Montserrat" WinPhone="Assets/Fonts/Montserrat-Regular.ttf#Montserrat"/>
與任何下列選項中使用它:
直接使用:
<Label Text="test" FontFamily="{StaticResource NormalFont}"/>
使用帶匿名樣式(影響應用中的所有標籤):
<Style TargetType="Label"> <Setter Property="FontFamily" Value="{StaticResource NormalFont}"/> </Style>
使用名爲風格:
<Style x:Key="TitleStyle" TargetType="Label"> <Setter Property="FontFamily" Value="{StaticResource Boldfont}"/> </Style> <Label Text="Options" Style="{StaticResource TitleStyle}"/>
0
如果你不想做實現這個你自己,你可以使用CustomFontEffect
我們增加在CommunityToolkit爲Xamarin形式:https://github.com/FormsCommunityToolkit/FormsCommunityToolkit/tree/dev/src
有一個示例項目增加了,但總體使用如下:
<Label Text="Comic Sans is tha bomb!">
<Label.Effects>
<effects:CustomFontEffect FontPath="ComicSaaaaaans.ttf" FontFamilyName="Comic Sans MS" />
</Label.Effects>
</Label>
相關問題
- 1. 如何在Xamarin跨平臺中使用自定義字體
- 2. 我在Xamarin Android中使用自定義字體是否正確?
- 3. Xamarin Forms自定義字體CrossPlatform
- 4. 自定義使用Xamarin在UWP進度條顏色表格
- 5. 在UIWebView中使用自定義字體
- 6. 在css中使用自定義字體?
- 7. 在Cocos2d中使用自定義字體
- 8. 在CSS中使用自定義字體
- 9. 在xaml中使用自定義字體
- 10. 在Xcode中使用自定義字體
- 11. 在CSS中使用自定義字體
- 12. 在viewpagerindicator中使用自定義字體
- 13. 在電子表格devexpress字體選擇器下拉使用自定義字體
- 14. 使用自定義字體
- 15. 使用自定義字體
- 16. 如何在自定義BaseAdapter中使用自定義字體
- 17. 自定義MasterDetail頁在Xamarin窗體
- 18. 在wordpress中使用HTML格式的自定義字體
- 19. 用Xamarin Forms和Prism在Android上顯示的自定義字體
- 20. Xamarin Android TypefaceSpan在Assets文件夾中具有自定義字體
- 21. 如何在Xamarin.Android中使用自定義字體?字體問題
- 22. 在CSS中使用字體的自定義字體
- 23. 在C#窗口中使用的自定義.ttf字體。表單
- 24. Xamarin - 在自定義列表視圖中使用圖像ViewCell
- 25. Xaml綁定到Xamarin表格中的自定義類
- 26. 自定義字體不顯示在Xamarin Storyboard
- 27. Xamarin窗體Windows Azure自定義登錄
- 28. lwuit中表的自定義字體?
- 29. 在Xamarin窗體中綁定自定義對象類型
- 30. 使用自定義裝配體中的自定義裝配體
你試過Google嗎? – roottraveller