wpf - How to use font in the references library? -


i have dll custom control. need use font in dll resources app.

i wrote code working if font installed on pc.

new typeface(new fontfamily(new uri("pack://application:,,,/astro;component/fonts")

how solve problem? need use font without install on pc.

if encapsulate custom control inside it's own assembly, shouldn't have reference applications assembly there. embed font files resources inside custom control project or define distinct styling project referenced custom control , application well.

project

you can define , use xaml font families resources shown below. xaml placed inside fonts.xaml located in same folder font files:

<fontfamily x:key="colaboratethin">./#colaborate thin</fontfamily> <fontfamily x:key="colaborateregular">./#colaborate regular</fontfamily> <fontfamily x:key="colaboratebold">./#colaborate bold</fontfamily> <fontfamily x:key="droidsansregular">./#droid sans regular</fontfamily> <fontfamily x:key="segoeregular">segoe</fontfamily>  <style x:key="h1">     <setter property="textelement.fontfamily" value="{staticresource colaboratethin}" />     <setter property="textelement.fontsize" value="21px" />     <setter property ="textelement.foreground" value="{staticresource primarybrush}" /> </style> 

Comments