Aug 31, 2010

Load And Use Custom Font Without Installing

How to load and use font, not installed in the system? Not always your application have enough rights to install custom font into system. For example in ClickOnce application.

RTFM? Bull Shit! When you need some functionality and look documentation anything looks so fine... before you start coding.

I wrote application for ClickOnce install. My application require custom font. How to use custom font whithout administrator privileges? I look MSDN documentation, find class PrivateFontCollection and see beautiful example. Three seconds and i have few lines code in my app. But nothing happens. Custom font doesn't appears!

Ok, i write test programm, and use complete example from MSDN. Same result! Looking example i see used font names - Arial, Courier New, Times New Roman... Why i not surprised this example works? Cause these fonts are preinstalled in system. Only complete idiot will delete these fonts!