How can i reference a embbed font in my silverlight project, considering that there are multiple files for the same font?
I used the following tags in a Fonts.xaml file:
<FontFamily x:Key="MyFamily">../../Resources/Fonts/segoeui.ttf#Segoe UI</FontFamily>
In another file I have a tag to link this fontfamily to any TextBlock.
When I have a simple TextBlock it works fine:
<TextBlock Text="Simple" />
But when i want a bold text, it is not working;
<TextBlock Text="Simple" Font-Weight="Bold" />
I Know that the bold font is in another file (segoeuib.ttf), but since I refer to a specific file, and not the font name, its not finding. How can i refer to both file, without having to add FontFamily tag to all my TextBlock that needs to display Bold text?
PS: If I use the Font family name, without the file name, it will work, but if my user doesn't have the font in his/her computer it wont work.
I discovered how to do it, sharing in case someone has the same problems.
Instead of referring to the .ttf file, just put all font files in a zip and refer to the zip:
<FontFamily x:Key="MyFamily">../../Resources/Fonts/SegoeUI.zip#Segoe UI</FontFamily>
Related
I have installed some custom Asian fonts in the Windows/Fonts folder. I am writing a code that reads some item names (just a plain string, ABC, but in Japanese) from MS-Excel cells, then pastes them in a text box in a new MS-Word document. The problem is that I can't use my custom fonts (these are TTF files) to format the text in MS-Word.
I tried to name the font with .ttf in the end, besides simply referring to its name as it appears in the drop-down menu in MS-Word.
Wrd_Doc.Shapes("shpTwo").TextFrame.TextRange.Font.Name = "ShigotoMemogaki Regular"
It refers to a text box named shpTwo. I pasted some text there and I want it to look like this custom font, named ShigotoMemogaki Regular. This font is saved in my Fonts folder, it works in MS-Word when I use it, but somehow the code does not recognize it, and instead, it uses the default Office Asian font, which is MSMincho.
So the text is clearly copied from MS-Excel, it is in the newly created text box in a new Word document, but it's not in the font I need.
I've used both TTF and OTF custom fonts many times in UWP apps without issue, but in this case, I have an OTF font that will not work in my app.
I have a test app that has one page with only the text on it, like this:
<TextBlock Text="Testing" FontFamily="ms-appx:///Assets/Fonts/customfont.otf#font name" FontSize="30"/>
The font file is located at that location in my project and the #fontname is the same one that shows in Windows Font Viewer.
I've tried converting the OTF to TTF, but it didn't change anything.
I've installed the OTF font on my Windows System and I can use the font in MS Word and other programs and it looks correct.
This is a professional font provided by a company that sells high quality fonts.
I've run out of trouble shooting tactics on this. Anything else I should try?
What font are you using? Sometimes the #Font Name does not equal what is seen in the Windows Font Viewer. I have a database of the values that I use with my app Font Lounge. I'll try looking up the value.
--
Just saw that you figured it out - font weight is not part of the #Font Name as the #Font Name refers to the family only.
In Windows Phone 8.1 you can use different languages useing the property "x:Uid" of an element, if I do
<textblock x:Uid="string1"/>
and in a resource file I write
string1.Text: sentence in english
then "sentence in english" "is written" in the Text property of the textblock. For buttons would be string1.Content.
But I have a problem, I am using RichTextBlock, with a Paragraph and Hyperlink inside, I can use x:Uid but... which property to use? They don't have Text or Content property, so... how can I globalizate that elements?
Thank you.
The Paragraph and Hyperlink are collections. The actual text comes from a Run somewhere inside, and the Run has a Text property. If you set the run explicitly instead of implicitly then you can add x:Uid to its Text property:
Xaml:
<Hyperlink>
<Run x:Uid="hlink" Text="http://microsoft.com" />
</Hyperlink>
Resources.resw:
<data name="hlink.Text" xml:space="preserve">
<value>http://stackoverflow.com</value>
</data>
The displayed Hyperlink will pull the stackoverflow URL from the resource file.
I tried to add a custom font into my application. I need it for the page title. I copied the font to a folder named "Fonts" and changed the build action to Content. In the property panel the font shows up in the font list. But when i add the font the page title doesn't change. It changes a little bit but not like the font i'm using. The odd thing is when i double click on the page title the text gets highlighted in the textblock and then the highlighted text shows in the font i want. This is confusing. What should i do to correct this?
XAML for the page title
<TextBlock Text="page title" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" FontFamily="/AppName;component/Assets/Fonts/Dekers_Bold.ttf#Dekers_Bold" />
You have to add fonts as BlendEmbeddableFonts
Open your solution in blend, go to the font manager and in "Embedded Fonts", check your custom font.
Then create a resource called
<FontFamily
x:Key="CustomFont">/Wake Jake;component/Fonts/Fonts.zip#FontName</FontFamily>
and add it as
FontFamily="{StaticResource CustomFont}"
It will work that way.
Let me know if you need further help
If the font is located in your main WP8 project, you don't need to use the /AppName;component path. Also make sure the Dekers_Bold is actually name of the font, you should maybe try DekersBold or just Dekers:
FontFamily="/Assets/Fonts/Dekers_Bold.ttf#DekersBold"
If this is not working, try to add your font as resources first:
<FontFamily x:Key="Dekers">/Assets/Fonts/Dekers_Bold.ttf#DekersBold</FontFamily>
...
<TextBlock Text="page title" Margin="9,-7,0,0" FontFamily="{StaticResource Dekers}" />
Any Font works in windows 8, but after you add it to your project, right click on the font, choose properties and set "Build action" to "Content". Have a great day!
Unfortunately not all fonts work with Windows Phone 8. It tried your font (donwloaded from dafont) in a WP 7.1 project as described here and it works perfectly. Doing the same in a WP 8 project... the font won't load. So, you probably have to pick another font.
<TextBlock TextAlignment="Center" Text="தமிழ் எழுத்து" FontSize="60" Margin="-11,0,0,0" Foreground="#FF4D5331" FontFamily="fonts/TAU_REWN.TTF#TAU_Elango_Rewathy"/>
I have initialized my font family like above and I have pasted my ttf font in /fonts folder. This bit of code works perfectly in windows phone 8 apps development. But, not works in windows phone OS 7.1 English TTF fonts works well. Kindly note, This is a tamil font.
Whats wrong here ? Can anyone helps...
Windows Phone 7.5 has tamil font support. Here's the proof
Update with fonts
TTF Font is here : https://app.box.com/s/2ce5rvzfvfkm55d27196
TTF Font Name is here : TAU_Elango_Rewathy
Tamil text is also here: தமிழ் எழுத்து
Ensure that your font file's build action is set to "Content". Right click on the font, select properties and change the build action.
See tutorial over here that walks you through embedding a font.
Try this. TTF capitalization may solve you problem i think so.
FontFamily="fonts/TAU_REWN.ttf#TAU_Elango_Rewathy"
Put your ttf file in bellow path
/Assets/Fonts/Helvetica_.ttf
<TextBlock Name="tbSuggestionlst1" FontFamily="/Assets/Fonts/Helvetica_.ttf#Helvetica_ " Text="Hello World"/>
And Yes you have give your font name like below
<TextBlock Name="tbSuggestionlst1" FontFamily="/Assets/Fonts/Helvetica.ttf#Helvetica Bold " Text="Hello World"/>
If my ttf name is Helvetica but font name is Helvetica Bold so you have to write your font name after # like Helvetica.ttf#Helvetica Bold "
Edit: i tryed in windows phone 8 with below code and it will work fine
<TextBlock Name="tbHdrAboutsUs" Text="தமிழ் எழுத்து" FontFamily="/Assets/Fonts/TAU_REWN.TTF#TAU_Elango_Rewathy" ></TextBlock>
In windows phone 7 it will not work beacuse windows phone 7 does not supported tamil fonts
Hope it will help you.
Tamil Language support
It will work for me