enbdding Fonts for wp from:http://www.jeffblankenburg.com/2010/10/24/31-days-of-windows-phone-day-24-embedding-fonts/
2882 단어 windows
To add another font to your application, it’s pretty simple, but not terribly obvious. The first thing you need to do is find a font you want to use. I recommend DaFont.com or 1001FreeFonts.com , but there are plenty of places that offer free, re-distributable fonts.
That’s an important key word, however. REDISTRIBUTABLE. Please make sure that you are only including fonts that are allowed to be redistributed. In some cases, you might need to pay for these rights. Make sure you’re covering yourself before you just start adding fonts to your application.
OK, so now that we HAVE a font we can package up and distribute, here’s how we get it embedded in our application. The first step is to add it to our project. I generally like to create a “fonts” folder that I keep my fonts in, but it’s not required. Here’s a screenshot of my Solution Explorer.
The catchy part to using this file appropriately is the Build Action we assign to this file. If you’re not familiar with Build Actions, click on your font in Solution Explorer, and look at the Properties pane.
There are two values we need to change manually, or we’ll never see any success with our font. The first is the Build Action. You want to change that to be “Content.” The second is Copy To Output Directory. That needs to be “Copy if newer.” Now my properties look like this:
Now, to actually USE the font, right? There’s some simple XAML syntax to make this happen on the FontFamily property. Here’s what it looks like:
<TextBlock Text="12:02 AM" FontFamily="fonts/DigitalDream.ttf#Digital Dream" FontSize="60"/>
As you can see, I need to specify the font file itself, and following a pound sign/hash mark (#), the actual name of the font. In my example, they’re the same. If you want to be sure you’re right, open the font file on your computer, and you should see a window that looks like this:
The actual font name is listed right at the top. You’ll know when you get the syntax right, because the font will immediately change on your design surface in Visual Studio 2010.
If you’d like to see a working example of embedded fonts, download this solution and open it up for yourself. It’s amazingly simple, but also a great way to give your application a distinct look.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
제한된 크기의 디렉토리를 만드는 방법오늘 저는 장치에 공간이 없을 때 백업 중에 응용 프로그램이 어떻게 작동하는지 테스트(및 수정)하는 작업이 있습니다. 결과적으로 "남은 공간 없음"오류로 백업이 실패하면 새 파일이 없어야 합니다. 지금까지 문제를 재...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.