问题
I'm trying to draw text over a bitmap image and I've done some research and found that .NET/GDI+ doesn't support OTF fonts. I read somewhere that you could use TextRenderer.DrawText
to render OTF fonts with GDI, but I can't seem to figure out how, nor does the quality compare to Graphics.DrawString
in the least bit.
First of all, is it possible to use OTF fonts at all in VS or did I read something incorrectly?
Second, If the answer is TextRenderer.DrawText, how do I use the OTF fonts? It looks like I have to use the
System.Drawing.Font
class, but I don't think those support the fonts and that's the issue, correct?How do I get the fonts to render clearly like the TTF fonts using GDI+ (
Graphics.DrawString
)Using
Graphics.DrawString
I was able to use aRectangleF
(with specified width, 0 height) as a boundary for my text, and the text wrapped correctly. WithTextRenderer.DrawText
, the ability to useRectangleF
disappears and only allowsRectangle
which doesn't seem to allow 0 height, while still allowing text to display (ie. text must be within the rectangle, and text wrapping does not work). Am I doing it wrong?
Any help would be greatly appreciated. If this cannot be done, is there a way to convert the OTF fonts, or find the Gotham font family online in TTF version? I really need these fonts!
来源:https://stackoverflow.com/questions/6766670/textrenderer-drawtext-using-gdi-to-render-otf-fonts