C#代码更改文本块的字体系列以嵌入Windows Phone 8中的字体

时间:2013-07-17 05:30:02

标签: windows-phone-7 windows-phone-8 true-type-fonts

我的Windows phone 8应用程序应该使用英语和阿拉伯语两种语言。 我已将自定义字体嵌入到我的应用程序中,并将内容类型设置为始终复制。 嵌入字体为 nazli.ttf

默认情况下,应用程序的语言为Engilsh,默认字体系列为 Segoe WP 。 每当用户将应用程序的语言更改为阿拉伯语时,我想将字体系列更改为嵌入字体,即 nazli.ttf

if (Constants.selectedLanguage.Equals("English"))
        {
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            this.FlowDirection = FlowDirection.LeftToRight;

            //Setting the Default Font Family for English
            title.FontFamily = new FontFamily("Segoe WP");
        }
        else
        {
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ar");
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar");
            this.FlowDirection = FlowDirection.RightToLeft;

            //Have to set the embed Font Family.
            title.FontFamily = //How should i mention the embed font here
        }

感谢。

1 个答案:

答案 0 :(得分:2)

根据此博客条目,我将其调整为后面的代码:

http://www.jeffblankenburg.com/2010/10/24/31-days-of-windows-phone-day-24-embedding-fonts/

现在我在资产/字体中有这个字体,传递路径和名称的语法与博客文章中描述的相同。

title.FontFamily = new FontFamily("Assets/Fonts/CFLifeIsADream-Regular.ttf#CF Life Is A Dream");

HTH