lboldt
Topic Author
Posts: 14
Joined: 13 Aug 2013, 04:03

Fonts

15 Aug 2013, 05:39

I imported an OTF and an TTF font file into Unity, when referencing these from XAML I get an error saying it can't fint fontname.font in the database... how do I create a .font version of the otf/ttf file?
 
User avatar
jsantos
Site Admin
Posts: 2906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Fonts

15 Aug 2013, 11:10

Hi,

A font resource is a text file with a list of file font references, one item per line. For example, Roboto.font contains:
Roboto-Regular.ttf
Roboto-Italic.ttf
Roboto-Bold.ttf
Roboto-BoldItalic.ttf
Note that referenced .ttf files must be found next to the .font file. The .font file can contain as many references as you wish, even a single one, but it is recommended that all the referenced files belongs to the same font family being that family the name of the .font file.

The above .font could be used this way:
<Grid>
    <Button Content="Click Me!" FontFamily="Fonts/#Roboto" />
    <Button Content="Click Me!" FontFamily="Fonts/#Roboto" FontWeight="Bold" />
</Grid>
Note that the reference to the font is relative to the location of the .xaml file. Here we are supposing that Roboto.font is located in the subfolder Fonts/ relative to the .xaml.

Referenced fonts must always be inside the project folder. Operating system fonts are not supported for example.
 
lboldt
Topic Author
Posts: 14
Joined: 13 Aug 2013, 04:03

Re: Fonts

15 Aug 2013, 21:02

Ah, that easy. You should copy what you wrote here and paste it into the tutorial about text which has a section on font-family in the documentation :-)

Thanks!
 
User avatar
jsantos
Site Admin
Posts: 2906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Fonts

16 Aug 2013, 04:04

:D the text is already copied from one tutorial (unity) and yes, I did what you say: adding this info to the text tutorial.

Who is online

Users browsing this forum: No registered users and 0 guests