找传奇、传世资源到传世资源站!

C# Winform 读取显示ttc,otf,ttf字体

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

直接读取ttc、oft、ttf格式的字库,显示出来。本例字库在bin文件夹里面,字库网上很多,自行下载。C# Winform 读取显示ttc,otf,ttf字体 C#语言基础-第1张
static class NativeMethods{const string GDI32 = "gdi32.dll";const string USER32 = "user32.dll";struct Rect{public long Left, Top, Right, Bottom;public Rect (Rectangle rect) {this.Left = rect.Left;this.Top = rect.Top;this.Right = rect.Right;this.Bottom = rect.Bottom;}}static uint ToGdiColor (Color color) {return (uint)(color.R | color.G << 8 | color.B << 16);}[DllImport (GDI32)]internal static extern IntPtr CreateFont (int nHeight,int nWidth,int nEscapement,int nOrientation,int fnWeight,uint fdwItalic,uint fdwUnderline,uint fdwStrikeOut,uint fdwCharSet,uint fdwOutputPrecision,uint fdwClipPrecision,uint fdwQuality,uint fdwPitchAndFamily,string lpszFace);[DllImport (GDI32)]internal static extern IntPtr SelectObject (HandleRef hdc, IntPtr obj);[DllImport (GDI32)]internal static extern bool DeleteObject (HandleRef obj);[DllImport (USER32, CharSet = CharSet.Auto)]static extern int DrawText (HandleRef hDC, string lpchText, int nCount, ref Rect lpRect, uint uFormat);internal static int DrawText (HandleRef hDC, string text, Rectangle rect, uint format) {var r = new Rect (rect);return DrawText (hDC, text, text.Length, ref r, format);}[DllImport (GDI32)]static extern uint SetTextColor (HandleRef hdc, uint crColor);internal static uint SetTextColor (HandleRef hdc, Color color) {return SetTextColor (hdc, ToGdiColor (color));}[DllImport (GDI32)]internal static extern uint SetBkMode (HandleRef hdc, int mode);}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复