I have a class that renders text to an image. It was working fine until I tried to use the Calibri font. Calibri is rendered without any font smoothing. After some research I determined that the cause is that Graphics.DrawString()
uses GDI+
, and I need to use GDI
. The solution presented is to use TextRenderer.DrawText()
instead. But, TextRenderer
is in the System.Windows.Forms
namespace, and mine is not a Windows Forms app.
Should I just reference the System.Windows.Forms.dll in my project? This class should be considered middle-tier. It doesn't care if the application is web-based, windows forms, WPF, or whatever. The output is an Image
. In my specific case, I am using it on the web. And I don't like the idea of referencing System.Windows.Forms
from an ASP.Net application. Several comments and answers on StackOverflow suggest that ASP.Net applications should not reference windows forms dlls.
So, is there a non-windows-forms way of rendering text via GDI? Or is this case an exception to the rule of not referencing windows forms dlls from ASP.Net?