0

I write at the moment a programm that search all .ttf file's from the C:\Windows\WinSxS dictonary and copy them to another dictonary (I think I dont have to post some code here, because its working well).

Now the problem. As example the font arial is saved with the name arial.ttf, but this file exists more than 1 time with the same name. Now I found this link here: get font name of ttf file, but the output name is still the same (always arial). I think the difference between these file is the fontstyle (italic, bold, ...), but how can I get the fontstyle of each *.ttf file?

1 Answer 1

2

You need a reference to PresentationCore. With that you can use GlyphTypeface to check for Style and Weight: Example:

using System.Windows.Media;

GlyphTypeface ttf = new GlyphTypeface(new Uri(@"C:\Windows\Fonts\calibrii.ttf"));
Debug.Print(ttf.Style.ToString()); //=Italic or Normal
Debug.Print(ttf.Weight.ToString()); //=Bold or Normal

Will not work with Postscript OTF though.

Edit: Credits to C# lib for processing font files - TTF (TrueType), others

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.