Tamam, interweb ve Google sayesinde bunu anladım. kimse bu sorunu varsa İleride
, düzeltmedir: bir akışı olarak gömülü yazı aldıktan sonra ve AddMemoryFont, sen AddFontMemResourceEx aramak zorunda çağırmadan önce! Sonra
[DllImport("gdi32.dll")]
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
ve:. Bunu ithal etmek zorunda C# kullanılamaz (
//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);
Ve presto, yazı kullanmak mümkün olacak AddFontMemResourceEx olmadan işe alışkanlık
+1 faydalı olduğunu bildiğiniz için teşekkürler, Led – BillW
Kutsal Yengeç Saatlerce duvara başımı çarptım Teşekkür ederim! – Mike
Buradan "fontStream" nereden geliyor? –