Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# PrivateFontCollection给了我符号_C#_Winforms - Fatal编程技术网

C# PrivateFontCollection给了我符号

C# PrivateFontCollection给了我符号,c#,winforms,C#,Winforms,我正在使用添加字体 GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr pointer = pinnedArray.AddrOfPinnedObject(); CustomFonts.Fonts.AddMemoryFont(pointer, data.Length); pinnedArray.Free(); GCHandle pinnedaray=GCHandle.Alloc(数据,GCHandleTy

我正在使用添加字体

GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr pointer = pinnedArray.AddrOfPinnedObject(); CustomFonts.Fonts.AddMemoryFont(pointer, data.Length); pinnedArray.Free(); GCHandle pinnedaray=GCHandle.Alloc(数据,GCHandleType.Pinned); IntPtr pointer=pinnedArray.AddrOfPinnedObject(); CustomFonts.Fonts.AddMemoryFont(指针、数据、长度); pinnedaray.Free(); 但当我把它用作标签时,它只是显示为一堆字母(运行时)。我已打开CompatibleTextRendering。我正在尝试嵌入“访问者”。当我使用它而不嵌入它时,它工作得很好。但我想嵌入它,因为它不是标准字体

编辑:


刚刚尝试使用AddFile,效果不错。不知道为什么从内存添加会失败。

显然,AddMemoryFont不会进行它应该进行的额外api调用

[DllImport("gdi32.dll")] private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts); GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr pointer = pinnedArray.AddrOfPinnedObject(); CustomFonts.Fonts.AddMemoryFont(pointer, data.Length); uint dummy = 0; AddFontMemResourceEx((IntPtr)pointer, (uint)data.Length, IntPtr.Zero, ref dummy); pinnedArray.Free(); [DllImport(“gdi32.dll”)] 私有静态外部IntPtr AddFontMemResourceEx(IntPtr pbFont、uint cbFont、IntPtr pdv,[In]参考uint pcFonts); GCHandle pinnedaray=GCHandle.Alloc(数据,GCHandleType.Pinned); IntPtr pointer=pinnedArray.AddrOfPinnedObject(); CustomFonts.Fonts.AddMemoryFont(指针、数据、长度); uint虚拟=0; AddFontMemResourceEx((IntPtr)指针,(uint)data.Length,IntPtr.Zero,ref dummy); pinnedaray.Free();