user3651656
user3651656

Reputation: 185

Defining a custom FontFamily with several font files in XAML/C#

I'm trying to define a custom font in a C# WinRT app. I can define a single-file font in XAML like so:

<Page.Resources>
    <FontFamily x:Key="Cousine">/Fonts/Cousine-Regular.ttf#Cousine</FontFamily>
</Page.Resources>

But I have several other font files that I would like to be used where appropriate:

How do I define a font family that uses the different fonts for the different font weights/variants?

Upvotes: 3

Views: 711

Answers (1)

bsant
bsant

Reputation: 11

They should all be in the same ttf file and you reference them like:

/Fonts/Cousine-Regular.ttf#Cousine
/Fonts/Cousine-Regular.ttf#Cousine Bold
/Fonts/Cousine-Regular.ttf#Cousine Italic
/Fonts/Cousine-Regular.ttf#Cousine Bold Italic

I don't know if the last one is right. I came here looking for the answer to that question. It might be BoldItalic. Whatever it is, I believe you create that name when you create the ttf file so you would be able to figure it out.

Upvotes: 1

Related Questions