Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Change fonts #6035


User avatar
0
avanekar02 created

where exactly do i need to change the font inthe source...


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @avanekar02

    You can create a similar file to fonts-roboto.css (under wwwroot/fonts folder) and create a folder with font files similar to wwwroot/fonts/Robot.

  • User Avatar
    0
    avanekar02 created

    Thanks, let us say i do add a mohareb folder with mohareb-1.ttk and a a font-mohareb.css for the same, how do i set it commonly across for all arabic page in mobile.shared app.

    thanks Anwar

  • User Avatar
    0
    ismcagdas created
    Support Team

    @avanekar02

    I thought you were talking about Web App. You can check https://forums.xamarin.com/discussion/37410/how-to-set-font-family-to-whole-application for that.

  • User Avatar
    0
    avanekar02 created

    i copied the font cairo under mobile.shared project in ui/assets folder then i added the font int app.xaml in the same project and reference it in label control

      <!--  font families  -->
                <OnPlatform x:Key="RegularFontFamily" x:TypeArguments="x:String">
                    <On Platform="iOS">HelveticaNeue</On>
                    <On Platform="Android">/UI/Assets/Cairo-Black.ttf#Cairo-Black</On>
                    <!--<On Platform="Android">sans-serif</On>-->
                </OnPlatform>
                
                  <!-- STYLES -->
                <Style TargetType="Label" ApplyToDerivedTypes="True" CanCascade="True">
                    <Setter Property="FontFamily" Value="{StaticResource RegularFontFamily}" />
                    <Setter Property="FontSize" Value="{ StaticResource BaseFontSize }" />
                    <Setter Property="TextColor" Value="{ StaticResource LabelColor }" />
                </Style>
    

    but it does not show .

    selected the cairo.ttf file and set the build mode as content, and always copy.

    it throws error "Java.Lang.RuntimeException: native typeface cannot be made "

    but i loaded the same font in paint or word it works fine so the .ttf file is not corrupt, also i tried various combinations of file name in lowercase,uppercase with spaces but does not work.

    thanks Anwar

  • User Avatar
    0
    alper created
    Support Team

    hi,

    did you check this https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/fonts#using-a-custom-font