Font style is not affected in Mobile view in UWP

2019-07-30 16:45发布

I am working on windows universal platform app for windows-10.I designed my whole app and use a two font style in whole application. 1)Utsaah 2)Raavi

both font family properly working in desktop and tablate view.But when i run my app in emulator (Mobile view) that time both fonts are not affacted to my textblock means default font of mobile initialize so please suggest me a solution . I just attached screenshot also code.

Code:

    <Grid HorizontalAlignment="Stretch">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel x:Name="topbar" Background="#FFF4F4F4" Grid.Row="0" Grid.ColumnSpan="2">

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Button x:Name="back_deatil_button" Grid.Column="0" Click="back_deatil_button_Click" Background="Transparent" Style="{StaticResource ButtonStyle1}">
                    <Image Source="Images/bback_icon@2x.png"  Height="25"  Stretch="Fill"></Image>
                </Button>
                <TextBlock x:Name="product_details" Grid.Column="1"  FontSize="14"   Text="PRODUCT DETAILS"  Foreground="#FFF05929" FontFamily="Raavi" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" ></TextBlock>
            </Grid>
        </StackPanel>

        <StackPanel x:Name="product_detail" Grid.ColumnSpan="2" Margin="0,10,0,10" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBlock x:Name="ProductName"  FontSize="16" FontFamily="utsaah" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold"></TextBlock>
        </StackPanel>
        <Image Source="Images/top_large_shhadow.png" Grid.ColumnSpan="2" Grid.Row="2"  VerticalAlignment="Top"></Image>
        <StackPanel x:Name="product_img" Grid.ColumnSpan="2" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top"  Height="137" Margin="40,0,54,20" Width="239">

            <Image  x:Name="ProductImage" Source="{Binding image}"  Height="137" Width="239" Margin="5"></Image>

        </StackPanel>
        <Image Source="Images/Products/top_large_shadow.png" Grid.ColumnSpan="2" Grid.Row="2" VerticalAlignment="Bottom"></Image>


        <TextBlock Text="SKU                               :" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" FontWeight="Bold" FontFamily="Utsaah" FontSize="14"></TextBlock>
        <TextBlock x:Name="SKU"   Grid.Row="3" Grid.Column="1"  HorizontalAlignment="Left" FontFamily="Utsaah" FontSize="14"></TextBlock>
        <Image Source="Images/Products/top_large_shadow.png" Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="3" VerticalAlignment="Bottom"></Image>


        <TextBlock Text="Price                              :" Grid.Row="4" Grid.Column="0" HorizontalAlignment="Center" FontFamily="Utsaah" FontSize="14" FontWeight="Bold"></TextBlock>
        <TextBlock x:Name="Price"  Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" FontFamily="Utsaah" FontSize="14"></TextBlock>

        <Image Source="Images/Products/top_large_shadow.png"  Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="4" VerticalAlignment="Bottom"></Image>

        <TextBlock Text="Qty                                :" x:Name="RowTotalQty" FontFamily="Utsaah" FontSize="14" Grid.Row="5" Grid.Column="0" HorizontalAlignment="Center" FontWeight="Bold"></TextBlock>
        <TextBlock x:Name="TotalQty" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Left" FontFamily="Utsaah" FontSize="14"></TextBlock>


        <Image Source="Images/Products/top_large_shadow.png"   Margin="0,25,0,0"  Grid.ColumnSpan="2" Grid.Row="5" VerticalAlignment="Bottom"></Image>


        <TextBlock Text="Special Price                :" x:Name="RowSpecialPrice" Grid.Row="6" Grid.Column="0" HorizontalAlignment="Center" FontFamily="Utsaah" FontSize="11"></TextBlock>
        <TextBlock x:Name="SpecialPrice" Grid.Row="6" Grid.Column="1"   HorizontalAlignment="Left" FontFamily="Utsaah" FontSize="14"></TextBlock>
        <Image Source="Images/Products/top_large_shadow.png"  Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="6" VerticalAlignment="Bottom" ></Image>

        <TextBlock Text="Status                           :" x:Name="RowStatus" Grid.Row="7" FontFamily="Utsaah" FontSize="14" Grid.Column="0" HorizontalAlignment="Center" FontWeight="Bold"></TextBlock>
        <TextBlock x:Name="Status" Grid.Row="7" Grid.Column="1" FontFamily="Utsaah" FontSize="14" HorizontalAlignment="Left"></TextBlock>
        <Image Source="Images/ttop_large_shadow.png"  Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="7" VerticalAlignment="Bottom"></Image>



        <TextBlock Text="Type                              :" FontFamily="Utsaah" x:Name="row_type" FontSize="14" Grid.Row="8" Grid.Column="0" HorizontalAlignment="Center" FontWeight="Bold"></TextBlock>
        <TextBlock x:Name="ProductType" Grid.Row="8" FontFamily="Utsaah" FontSize="14" Grid.Column="1" HorizontalAlignment="Left"></TextBlock>

        <Image Source="Imagesttop_large_shadow.png"  Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="8" VerticalAlignment="Bottom"></Image>

        <TextBlock Text="Associated                   :" Grid.Row="10" FontFamily="Utsaah" FontSize="14" Grid.Column="0" FontWeight="Bold" HorizontalAlignment="Center" x:Name="associated_prpduct" Visibility="Collapsed"></TextBlock>
        <TextBlock x:Name="Associated" Grid.Row="10" FontFamily="Utsaah" FontSize="14" Grid.Column="1" HorizontalAlignment="Left" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.IsVerticalRailEnabled="True"></TextBlock>

        <Image Source="Images/Products/top_large_shadow.png" x:Name="row_total_qty_shadow" Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="9" VerticalAlignment="Bottom"></Image>

        <TextBlock Text="Description                   :" FontFamily="Utsaah" x:Name="row_description" FontSize="14" Grid.Row="9" Grid.Column="0" HorizontalAlignment="Center"   FontWeight="Bold"></TextBlock>
        <StackPanel Grid.Column="1" Grid.Row="9" x:Name="pnl_description" Height="auto">
            <ScrollViewer  HorizontalAlignment="Stretch"  VerticalAlignment="Bottom" Height="50"  VerticalScrollBarVisibility="Auto" Margin="0,0,0,6">
                <TextBlock x:Name="Description"  FontFamily="Utsaah" FontSize="14" Grid.Column="1" TextWrapping="Wrap"   HorizontalAlignment="Stretch" Margin="0,0,10,0"></TextBlock>
            </ScrollViewer>
        </StackPanel>


    </Grid>
    <ProgressBar Name="mobile_back_loader" Visibility="Collapsed" IsIndeterminate="True" Foreground="#FFF05A2A" HorizontalAlignment="Stretch" Height="40" VerticalAlignment="Top"  Margin="0,150,0,0"  Grid.RowSpan="2"/>
</Grid>

Image:

Font screen shot of both

1条回答
小情绪 Triste *
2楼-- · 2019-07-30 17:16

Here is a list of 'recommended' fonts for UWP apps.

Guidelines for fonts https://msdn.microsoft.com/windows/uwp/controls-and-patterns/fonts

These fonts are guaranteed to be available in all Win10 device families - desktop, mobile, iot, etc. But, Utsaah and Raavi are not listed in the list.

The doc says:

Note If you use a font that's not in this list, your app may trigger an automatic download of the font data from a Microsoft service.

and

UWP apps that will available on mobile devices should never use fonts for UI content other than fonts in this list.

It's not recommended. :(

查看更多
登录 后发表回答