Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Using Fonts

AssemAssem Member ✭✭

Good Day,
I am working on an application where at some point I want to display Greek words.
I downloaded a Greek true type font from Google, I placed it in the Assets folder under a folder I named “fonts”.
Then I try to use it in the page where I want to display the Greek words using Xamarin label command with Font Family and Text parameters.
The result is the word displays in English and not Greek.
I appreciate your help in this issue.
Thanks/Regards.

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    First of all, if we download the font and use it, we just change the display font style, it cannot achieve the translation function. for example, if we set the text content "hello" in the label, it cannot translate "hello" to "Γειά σου", it just change the display font style(such as Bold, tilt..)

    If you want to change the different language in your application, as GanesanVG's said, you should implemente Localization in xamarin forms.

    1.Add a resource for greek.

    2.Add the String Name and Value

    You can refer to this link to achieve it.
    https://www.c-sharpcorner.com/article/implemented-localization-in-a-xamarin-forms-app/

  • AssemAssem Member ✭✭

    Dear LeonLu,
    Thank you for your reply.
    I appreciate that you are trying to help. Please notice that I am not trying to translate words. I am just trying to display few words in the Greek language, even this is not working for me.
    Regards.

    ,

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Did you set the greek language of text in the label? Or English language?

  • AssemAssem Member ✭✭

    I did set the Font Family to the name and path of the Greek font and set the Text property to the word written in English letters, wishing they show up in Greek font.
    Regards

  • AssemAssem Member ✭✭

    But they appear in English letters.

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    If you set the text to the english letters and set a greek font, it cannot show Greek letters, you can test your english disappear with this font like this screenshot.

  • AssemAssem Member ✭✭

    Dear LeonLu,
    I understand, but when the application runs it should display the word in Greek, which does not happen.

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Did you add the a font in your project, then use this font in your PCL code like following code.

    <Application.Resources>
        <OnPlatform x:TypeArguments="x:String" x:Key="DancingScriptRegular">
             <On Platform="Android" Value="GFSNeohellenic-Regular.ttf#Regular"/>
        </OnPlatform>
    </Application.Resources>
    

    In the mainPage.

       <StackLayout>
        <!-- Place new controls here -->
        <Label  
            x:Name="myLabel"
            Text="Ελληνικά"
            FontFamily="{StaticResource DancingScriptRegular}"
            FontSize="Large"/>
       </StackLayout>
    

    Here id running screenshot. When I set the text to “Ελληνικά”, I got this result.

    When I set the text to “Hello”, I got this result.

  • AssemAssem Member ✭✭

    Hi,
    Thank you for your reply Luis.
    I will read through it.
    Regards

Sign In or Register to comment.