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 

Parents
No Data
Reply
  • 467410
    Suggested Answer
    Offline posted

    Hi Mike,

    I'm not really all that familiar with embedding fonts, but I can't see any reason the grid would be any different than any other control in this regard. In fact, the Font property is not a property on the grid, it's a property on Control.

    Does you font work with any other controls?

Children
No Data