Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Apply Embedded Font to UltraWinGrid
posted

Is there any way to use an embedded font on the Grid?

I've tried loading up my own font using this method

 

=======================================================

 PrivateFontCollection pfc = new PrivateFontCollection();

      Assembly assembly = this.GetType().Assembly;

      using (Stream fontStream = assembly.GetManifestResourceStream("....font.ttf"))

      {

        if (null != fontStream)

        {

 

          int fontStreamLength = (int)fontStream.Length;

 

          IntPtr data = Marshal.AllocCoTaskMem(fontStreamLength);

 

          byte[] fontData = new byte[fontStreamLength];

          fontStream.Read(fontData, 0, fontStreamLength);

 

          Marshal.Copy(fontData, 0, data, fontStreamLength);

 

          pfc.AddMemoryFont(data, fontStreamLength);

 

          Marshal.FreeCoTaskMem(data);

 

          Font newFont = new Font(pfc.Families[0], 8, FontStyle.Regular);

 

          m_grid.Font = newFont;

        }

      }

 

=======================================================

And the grid eventually throws an error about GetName on the font family.  Any suggestions?

 

Thanks,
Mike