PrivateFontCollection给我符号
我正在使用添加字体
GCHandle pinnedArray = GCHandle.Alloc(data,GCHandleType.Pinned); IntPtr pointer = pinnedArray.AddrOfPinnedObject(); CustomFonts.Fonts.AddMemoryFont(pointer,data.Length); pinnedArray.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)指针,(uint)data.Length,IntPtr.Zero,ref dummy); pinnedArray.Free();