   [C#] Problem with PrivateFontCollection
  Hello!I have some problems with the PrivateFontCollection. I have a .ttf-file which i added as a resource to my application. Then i use a PrivateFontCollection to load it from memory. Sadly the font i create from that family (which has the correct name) doesnt look how it should. If i create the font using AddFontFile everything works. Here some code:   private void Form1_Load(object sender, EventArgs e)   {  byte[] data = Content.space_age;  IntPtr hGlob = Marshal.AllocCoTaskMem(data.Length);  Marshal.Copy(data, 0, hGlob, data.Length);  PrivateFontCollection coll = new PrivateFontCollection();  //coll.AddFontFile("C:\\Users\\Admin\\Downloads\\space_age\\space_age.ttf");  coll.AddMemoryFont(hGlob, data.Length);  FontFamily fam = coll.Families[0];  Font curFnt = label1.Font;  Font fnt = new Font(fam, 18, curFnt.Style, curFnt.Unit, curFnt.GdiCharSet, curFnt.GdiVerticalFont);  label1.Font = fnt;  Marshal.FreeCoTaskMem(hGlob);   }The commented version works, the uncommented doesnt. What is the reason for that beahaviour?GreetingsPlerion   
  Define "doesn't work."Does it throw an exception? Draw incorrectly? Summon demon monkeys from the netherworld to attack your toes?   ;Quote:Original post by ApochPiQSummon demon monkeys from the netherworld to attack your toes?Thats what it does! Really!Its drawing it in Arial.   ;  My first guess would be that you already have the file open someplace else, so the font system can't load it. (Edit: that should throw an exception according to MSDN. So probably not.)Failing that, try new Font(fam.Name, ...); to see if something is going oddly wrong with the family name string conversion.   ;  Ive changed it to the following:   private void Form1_Load(object sender, EventArgs e)   {  byte[] data = Content.space_age;  IntPtr hGlob = Marshal.AllocCoTaskMem(data.Length);  Marshal.Copy(data, 0, hGlob, data.Length);  PrivateFontCollection coll = new PrivateFontCollection();  coll.AddMemoryFont(hGlob, data.Length);  FontFamily fam = coll.Families[0];  Font curFnt = label1.Font;    MessageBox.Show(fam.Name);    Font fnt = new Font(fam.Name, 18, curFnt.Style, curFnt.Unit, curFnt.GdiCharSet, curFnt.GdiVerticalFont);  label1.Font = fnt;  Marshal.FreeCoTaskMem(hGlob);   }It correctly displays "Space Age" but still renders as arial...   ;  Argh, shit. I totally misread your first post and thought the problem was with AddFontFile(), not AddMemoryFont(). Sorry for the wild goose chase.Do you call SetCompatibleTextRenderingDefault or use the UseCompatibleTextRendering property? According to the AddMemoryFont documentation you need to do one or the other to use a memory font.   ;  Oh, that was my bad, i read that i need to set the TextRendering, but i wrote Application.SetCompatibleTextRenderingDefault(false); instead of true... Its definitely to hot (>35°) :D   