wpf - How to load a font file and use its font style in C#? -


i can load font file using this:

privatefontcollection _fonts = new privatefontcollection(); _fonts.addfontfile ( filepath ); font customfont = new font(_fonts.families[0], 6.0f); 

but, problem facing cannot load font style (bold/italics etc) font file. need font file user, because going save font file , use opengl render it. but, before actual rendering, need show preview using wpf.

all fonts can assumed system fonts. but, need find out font style ttf file show on wpf canvas. can can ask user load font file specify style drop down, defeats purpose, because if user specifies wrong style, show differently on emulator , during rendering.

so, should do?

i'm not sure understand problem, if want display text in particular font, can this. first, add font file folder in project... let's it's called resources. next, set build action content. can use font in xaml this:

<textblock fontfamily="/resources/#some font name" text="some font name" /> 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -