Asher
Asher

Reputation: 1867

Use custom font with a COM Object in .NET

I am trying o load a custom font in C#, so it is usable by COM libraries (like ESRI) and by GDI+.

I want to load the font from disk and don't want to install the font on the system.

COM font is of type stdole.IFontDisp.

EDIT: using in AddFontResourceEx combination with the PrivateFontCollection solves the issue.

Upvotes: 1

Views: 445

Answers (1)

RS Conley
RS Conley

Reputation: 7194

There are two GDI functions you can use

AddFontResource RemoveFontResoure

Detailed here

Understand that while you have this loaded other applications will be able to see and use the font. There is no other way around this if you want to use the APIs. Once you added the Font then you can setup a IFontDisp (for COM) and a CFont (for GDI+) and use it.

Note that IFontDisp is found by making a reference to Standard OLE Types

Upvotes: 1

Related Questions