좋아, 나는 interwebs와 Google 덕택으로 그것을 이해했다. 사람이 문제가있는 경우 나중에 참조 할 수 있도록
은, 수정은 다음과 같습니다 스트림로 포함 된 글꼴을 받고 후, 그리고 AddMemoryFont, 당신이 AddFontMemResourceEx 전화를해야 를 호출하기 전에! 다음
[DllImport("gdi32.dll")]
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
과 :. 당신이 그것을 가져 그래서 C#에서 사용할 수 없습니다 (
//create an unsafe memory block for the data
System.IntPtr data = Marshal.AllocCoTaskMem((int)fontStream.Length);
//create a buffer to read in to
Byte[] fontData = new Byte[fontStream.Length];
//fetch the font program from the resource
fontStream.Read(fontData, 0, (int)fontStream.Length);
//copy the bytes to the unsafe memory block
Marshal.Copy(fontData, 0, data, (int)fontStream.Length);
// We HAVE to do this to register the font to the system (Weird .NET bug !)
uint cFonts = 0;
AddFontMemResourceEx(data, (uint)fontData.Length, IntPtr.Zero, ref cFonts);
//pass the font to the font collection
mFontCollection.AddMemoryFont(data, (int)fontStream.Length);
//close the resource stream
fontStream.Close();
//free the unsafe memory
Marshal.FreeCoTaskMem(data);
그리고 프레스토, 당신은 글꼴 를 사용 할 수 있습니다를 AddFontMemResourceEx없이 실 거예요 작업
출처
2009-12-24 00:10:21
Led
+1 덕분에 감사합니다. Led – BillW
거룩한 게 몇 시간 동안 벽에 머리를 두드 리고있었습니다! – Mike
여기에서 "fontStream"이 어디입니까? –