基本信息
源码名称:C# Winform 读取显示ttc,otf,ttf字体
源码大小:9.87M
文件格式:.rar
开发语言:C#
更新时间:2017-05-03
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 1 元×
微信扫码支付:1 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
直接读取ttc、oft、ttf格式的字库,显示出来。
本例字库在bin文件夹里面,字库网上很多,自行下载。
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);
}