Discussion on Windows Phone 7 development on the 31st day-24th: embedded font

Source: Internet
Author: User
Tags visual studio 2010

This article is the 24th day of the "Windows Phone 7 development on the 31st day" series.

Yesterday, I told you howProgramAdd a trial version. This is a very valuable feature that allows you to sell more programs. Today, I want to talk about how to embed fonts in a program.

First, small enough

For all applications built for mobile devices, remember that data must not be "free. Your user has a data plan that can only transmit 5 GB per month. Second, there is a limit, that is, the size of the application that can be obtained through the data plan: 20 mb. If your application is larger than 20 mb, you will have to use Wi-Fi or use your computer for synchronization. These will be detrimental to selling more copies of the program.

Do not fill your applications with the data, fonts, images, videos, and other content you may need. Reduce them to the minimum value, and if you can get these additional content online in the future, consider doing so.

Embed fonts in Windows Phone 7

One of the most frequently asked questions is how to use custom fonts in the WP7 program instead of existing ones. The following is a list of existing fonts. If you do not specify fontfamily, the default value is segoe WP:

Adding another font to your application is simple but not obvious. First, you need to find a font to use. I suggest using dafont.com or 1001freefonts.com, but there are many other addresses that provide free and reusable fonts.

This is a very important word. Redistributable ). Make sure that you only contain fonts that allow redistribution. In many cases, you may need to pay for copyright. Make sure that you have checked the font before adding the font to the program.

Now we have a font that can be packaged and distributed. Here is how to embed it into our program. First, add it to the project. I usually like to create a "fonts" folder to store my fonts, but this is not necessary. The following is my solution manager's:

To properly use this file, you must note that we should assign values to the build action of this file. If you are not familiar with build action, click your font in solution manager and view the properties panel.

We need to manually modify two values, otherwise the font cannot work. The first is build action. You need to change it to "content ". The second is copy to output directory, which is changed to "copy If newer ". Now my property panel looks like this:

Now, I really want to use this font, right? To do this, you need to use a simple XAML syntax on the fontfamily attribute. Like this:

< Textblock Text = "12:02 am" Fontfamily = "Fonts/digitaldream. TTF # digital dream" Fontsize = "60" />

As you can see, I need to specify the font file and follow it with a # symbol and the real name of the font. In my example, they are the same. If you want to confirm that you are right, open the font file on your computer and you should be able to see the following form:

The font name is listed on the top. If your syntax is correct, you will see the effect, because the design interface of Visual Studio 2010 can be changed immediately.

Download exampleCode

If you want to see an example of the font embedding function, download it and open the solution. It is very simple, but this is a good way for your program to have another sense.

Address: http://www.jeffblankenburg.com/post/31-Days-of-Windows-Phone-7c-Day-24-Embedding-Fonts.aspx

 

If you like myArticle, Please click "recommended ", Thank you!

 

 

Related Article

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.