{"id":479,"date":"2014-01-03T11:37:25","date_gmt":"2014-01-03T11:37:25","guid":{"rendered":"http:\/\/www.blogs.abeazam.com\/dev\/?p=479"},"modified":"2014-01-03T14:56:37","modified_gmt":"2014-01-03T14:56:37","slug":"embedding-otf-fonts-in-windows-phone-8","status":"publish","type":"post","link":"http:\/\/www.blogs.abeazam.com\/dev\/2014\/01\/embedding-otf-fonts-in-windows-phone-8\/","title":{"rendered":"Embedding OTF Fonts in Windows Phone 8"},"content":{"rendered":"<p>Now I don&#8217;t think there is a difference between between TTF and OTF fonts when it comes to Windows Dev. I do how ever think that the way the fonts them selves are set up, are different.<\/p>\n<p>A lot of people as well as my self have had trouble with embedding OTF fonts. The problem ended up being the name of the font inside the font file. The Windows OS font does not show you all of the variations on the name.<\/p>\n<p>How to embed a font you are having trouble with:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"xaml\" title=\"XAML\">\r\n<!-- XAML Example -->\r\n<TextBlock FontFamily=\"Assets\/fonts\/MyFontFileNameExtraBold.otf#My Font Name\"\/>\r\n\r\n<\/pre>\n<\/p>\n<pre class=\"c#\" title=\"C#\">\r\n\/\/C# example\r\nmyText.FontFamily = new FontFamily(\"Assets\/fonts\/MyFontFileNameExtraBold.otf#My Font Name\");\r\n\r\n<\/pre>\n<p><strong>Settings:<\/strong><\/p>\n<p>MyFontFileNameExtraBold.otf needs to have 2 properties set the \u201cBuild Action\u201d which should be resource for WinPhone 8 and the \u201cCopy to Output Directory\u201d which should be Copy if newer. See image bellow.<\/p>\n<p><a href=\"http:\/\/www.blogs.abeazam.com\/dev\/wp-content\/uploads\/2014\/01\/vsProperties.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-482\" alt=\"vsProperties\" src=\"http:\/\/www.blogs.abeazam.com\/dev\/wp-content\/uploads\/2014\/01\/vsProperties.jpg\" width=\"345\" height=\"126\" srcset=\"http:\/\/www.blogs.abeazam.com\/dev\/wp-content\/uploads\/2014\/01\/vsProperties.jpg 345w, http:\/\/www.blogs.abeazam.com\/dev\/wp-content\/uploads\/2014\/01\/vsProperties-300x109.jpg 300w\" sizes=\"(max-width: 345px) 100vw, 345px\" \/><\/a><\/p>\n<p><strong>The font name problem<\/strong><\/p>\n<p>As you can see in the above FontFamily prams for custom fonts its made up of the path to the font followed by a hash then the font name. Now for some reason it is not the font name that creates the problem. first you need a font viewer that\u00a0 shows all the names.<\/p>\n<p>I use: <a title=\"http:\/\/us.fontviewer.de\/download.html\" href=\"http:\/\/us.fontviewer.de\/download.html\">http:\/\/us.fontviewer.de\/download.html<\/a><\/p>\n<p>Open up your font in this program. You will see lots of info for the font. In my case I needed to use the \u201cPreferred Family\u201d name to replace the \u201cMy Font Name\u201d in the path above. but if that does not work for you try one of the others. See image bellow:<\/p>\n<p><a href=\"http:\/\/www.blogs.abeazam.com\/dev\/wp-content\/uploads\/2014\/01\/font_tool.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-484\" alt=\"font_tool\" src=\"http:\/\/www.blogs.abeazam.com\/dev\/wp-content\/uploads\/2014\/01\/font_tool.jpg\" width=\"627\" height=\"617\" srcset=\"http:\/\/www.blogs.abeazam.com\/dev\/wp-content\/uploads\/2014\/01\/font_tool.jpg 627w, http:\/\/www.blogs.abeazam.com\/dev\/wp-content\/uploads\/2014\/01\/font_tool-300x295.jpg 300w\" sizes=\"(max-width: 627px) 100vw, 627px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now I don&#8217;t think there is a difference between between TTF and OTF fonts when it comes to Windows Dev. I do how ever think that the way the fonts them selves are set up, are different. A lot of people as well as my self have had trouble with embedding OTF fonts. The problem [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10,29,30,51,92,93,91],"tags":[],"_links":{"self":[{"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/posts\/479"}],"collection":[{"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/comments?post=479"}],"version-history":[{"count":6,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/posts\/479\/revisions"}],"predecessor-version":[{"id":488,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/posts\/479\/revisions\/488"}],"wp:attachment":[{"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/media?parent=479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/categories?post=479"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/tags?post=479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}