Win10 UWP Packaging Third-party fonts to apps

Source: Internet
Author: User
Tags creative commons attribution

Sometimes we will pack some special fonts into the software, because if we can't find our fonts will become the default, now many font icons we use well, sometimes our app will use a very beautiful font, we need to pack their own, because the user is generally no font.

UWP uses third-party fonts

First we need fonts, this font download, many online. http://font.chinaz.com/I download this website, if someone knows his website font is not fully licensed, please and I say, I will delete my app font.

In the Internet, things have to pay attention to copyright, there are many we can not directly use.

We simply write a TextBlock in the interface

        <TextBlock Margin="10,100,10,10"                       Text="Lov ms"></TextBlock>

And then we can run see a word "Lov ms" because my love for Microsoft didn't last

Why in margin write 10,100,10,10 because there is black will block.

We remove the black, delete the App.xaml.cs

#if DEBUG            if (System.Diagnostics.Debugger.IsAttached)            {                thistrue;            }#endif

We can see that our app doesn't have a special font, and then we write a font that doesn't exist in our system.And Love St.ttf

        <TextBlock Margin="10,100,10,10"                   FontFamily="And Love St.ttf"                   Text="Lov ms"></TextBlock>

It's almost impossible to see a change.

We add a folder

I'll call it font.

Put our fonts in, and drag them directly in, the UWP import font is the folder where the fonts are placed in the solution

In our font write we put in the font, path # font name

Our path Font/And Love St.ttf nameAnd Love st

        <TextBlock Margin="10,100,10,10"                   FontFamily="Font/And Love St.ttf#And Love st"                   Text="Lov ms" ></TextBlock>

See also: http://www.cnblogs.com/mycing/p/5658355.html

Of course, it can also be a resource

 <page > <fontfamily x : Key= "Font" 
       >font/and  love st  .ttf   #And love St</fontfamily>  </page< Span class= "Hljs-preprocessor". Resources ;  
        <TextBlock Margin="10,100,10,10"                   FontFamily="Font/And Love St.ttf#And Love st"                   Text="Lov ms" ></TextBlock>


This work is licensed under the Creative Commons Attribution-NonCommercial use-Share 4.0 International license agreement in the same way. Welcome to reprint, use, republish, but be sure to keep the article Attribution Lindesi (including Link: http://blog.csdn.net/lindexi_gd), not for commercial purposes, based on the modified works of this article must be issued with the same license. If you have any questions, please contact me.

Win10 UWP Packaging Third-party fonts to apps

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.