Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Font Import
- [DllImport("gdi32.dll")]
- private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
- FontFamily ff;
- Font Font9;
- Font Font7;
- Font DaFont;
- int Percent = 0;
- private void CargoPrivateFontCollection()
- {
- // Create the byte array and get its length
- byte[] fontArray = EEWorldViewer.Properties.Resources.nokiafc22;
- int dataLength = EEWorldViewer.Properties.Resources.nokiafc22.Length;
- // ASSIGN MEMORY AND COPY BYTE[] ON THAT MEMORY ADDRESS
- IntPtr ptrData = Marshal.AllocCoTaskMem(dataLength);
- Marshal.Copy(fontArray, 0, ptrData, dataLength);
- uint cFonts = 0;
- AddFontMemResourceEx(ptrData, (uint)fontArray.Length, IntPtr.Zero, ref cFonts);
- PrivateFontCollection pfc = new PrivateFontCollection();
- //PASS THE FONT TO THE PRIVATEFONTCOLLECTION OBJECT
- pfc.AddMemoryFont(ptrData, dataLength);
- //FREE THE "UNSAFE" MEMORY
- Marshal.FreeCoTaskMem(ptrData);
- ff = pfc.Families[0];
- Font9 = new Font(ff, 9);
- Font7 = new Font(ff, 7);
- DaFont = new Font(ff, 12);
- }
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement