PrivateFontCollection giving me symbols
I am adding the font using
GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr pointer = pinnedArray.AddrOfPinnedObject(); CustomFonts.Fonts.AddMemoryFont(pointer, data.Length); pinnedArray.Free();
But when I use it for a label, it 开发者_如何学JAVAjust shows up as a bunch of letters(when running). I have turned on CompatibleTextRendering. I am trying to embed "Visitor". When I use it without embedding it, it works fine. But I want to embed it as it is not a standard font.
Edit:
Just tried using AddFile and that works. No idea why adding it from memory is failing.
Apparently AddMemoryFont does not make an additional api call that it should.
[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();
精彩评论