Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Custom font not displayed in native form
Started by ubj3d.android Jan 06 2016 08:33 AM

4 replies to this topic

Best Answer ubj3d.android , 06 January 2016 - 02:55 PM

Solved!

 

The path that was automatically created in Visual Studio designer was:

"/Fun Football Europe 2016;component/Assets/Corona/DESIB___.ttf#Designer Block"

 

After a bit of trial, I found the path that works on the phone:

"/Assets/Corona/DESIB___.ttf#Designer Block"

 

As you can see, I just removed the bold part.

 

Thank you for indicating where the problem was.

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

With help from this great tutorial https://coronalabs.com/blog/2015/02/24/tutorial-inputting-text-on-windows-phone-8/ I managed to make a login input form and it works great.

 

The only thing that is not working are custom fonts on the native form.

 

Does Corona not support this or is it a bug?

 

Please take a look at the screenshot.

 

The same custom font works in other parts of the app.

 

And here is the InputForm.xaml (it is the same as from your example, only tried to change the font).

<UserControl x:Class="Fun_Football_Europe_2016.InputForm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="/Fun Football Europe 2016;component/Assets/Corona/DESIB___.ttf#Designer Block"
    FontSize="36"
    Foreground="{StaticResource PhoneForegroundBrush}"
	d:DesignWidth="488.955" Height="364.418">

    <StackPanel Margin="0,-100,0,71">
        <StackPanel.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Black" Offset="1"/>
                <GradientStop Color="#FF28439C"/>
            </LinearGradientBrush>
        </StackPanel.Background>
        <StackPanel Margin="10,10,10,10" Height="381">
            <TextBlock x:Name="fUsernameLabel" TextWrapping="Wrap" Text="Username" FontFamily="/Fun Football Europe 2016;component/Assets/Corona/DESIB___.ttf#Designer Block" FontSize="36"/>
            <TextBox x:Name="fUsernameTextBox" InputScope="Default" FontSize="36"/>
            <TextBlock x:Name="fPasswordLabel" TextWrapping="Wrap" Text="Password" FontFamily="/Fun Football Europe 2016;component/Assets/Corona/DESIB___.ttf#Designer Block" FontSize="36"/>
            <PasswordBox x:Name="fPasswordTextBox" FontSize="36"/>
            <StackPanel VerticalAlignment="Top" Orientation="Horizontal" HorizontalAlignment="Center">
                <Button x:Name="fOkayButton" Content="Okay" Click="OkayButton_Click" FontFamily="/Fun Football Europe 2016;component/Assets/Corona/DESIB___.ttf#Designer Block" FontSize="36"/>
                <Button x:Name="fCancelButton" Content="Cancel" Click="CancelButton_Click" FontFamily="/Fun Football Europe 2016;component/Assets/Corona/DESIB___.ttf#Designer Block" FontSize="36"/>
            </StackPanel>
        </StackPanel>
    </StackPanel>

</UserControl>

On the phone:

10372341_933757480045908_365155504826584

 

In Visual Studio design the font is OK:

 

943821_933768193378170_64844380540014810



[TOPIC: post.html]
#2

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

I'm thinking that you forgot to flag your *.ttf font files' "Build Action" as "Content" in Visual Studio.  This tells Visual Studio's build system to bundle those files within the *.xap application bundle.  Have a look at the link below for instructions on how to do this...

   https://docs.coronalabs.com/daily/coronacards/wp8/portapp.html#copying-project-files



[TOPIC: post.html]
#3

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

Thank you for trying to help.

 

Unfortunately, that is not the cause. I have checked and the build action for the font file (DESIB___.ttf) is set to "Content".

I then tried to change the setting to "None" to see what happens.

 

The font "disappear" from all the Corona screens.

 

Just to be clear, the font does not show only on the native form -> <UserControl>



[TOPIC: post.html]
#4

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

It's probably a directory path issue to your font file then.  If you can't figure out how to set a relative path to your font files under the assets directory via XAML, then you may want to set an absolute path to them dynamically on the .NET at runtime.

 

Just so you know, this isn't actually a Corona issue.  This is a problem that you're having with Microsoft's XAML.  The Corona SDK has no control over this.  So, you may want to search Microsoft's forums or stackoverflow for a solution.



[TOPIC: post.html]
#5

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

  Best Answer

Solved!

 

The path that was automatically created in Visual Studio designer was:

"/Fun Football Europe 2016;component/Assets/Corona/DESIB___.ttf#Designer Block"

 

After a bit of trial, I found the path that works on the phone:

"/Assets/Corona/DESIB___.ttf#Designer Block"

 

As you can see, I just removed the bold part.

 

Thank you for indicating where the problem was.




[topic_controls]
[/topic_controls]