I need to get the font family name from an uploaded font. The user uploads a .ttf file. When I try to deserialize the data I get the following error "The input stream is not a valid binary format." The font data is uploaded via a HTML5 FileReader using readAsDataURL().
Can anyone spot what I'm doing wrong? I suspect I'm using the wrong deserializer... but I'm not sure.
//clean the font data of encoding
var cleanFontData = brandingsFontAddViewModel.FontData.Split(',')[1];
var fontBytes = Convert.FromBase64String(cleanFontData);
using (Stream memStream = new MemoryStream(fontBytes, 0, fontBytes.Length))
{
var deserializer = new BinaryFormatter();
var font = (Font)deserializer.Deserialize(memStream);
}
Finally found the answer.