How to extract embedded font from PDF file?

Q: How to extract embedded font from PDF file?
size_t datasize = font.GetEmbeddedFont().GetRawStreamLength();
Filters::Filter filter = font.GetEmbeddedFont().GetRawStream(true);
std::ofstream f(\"../../TestFiles/Output/file.dat\",
size_t size=0;
            UChar* from = filter.Begin();
            size = filter.Size();
            f.write((const char*)from, size);
}while(size !=0 );

I rename the saved file with a lots of extension name (ttf, otf) that
windows API AddFontResource() support. Could somebody help me out?
A: It seems that there are some error in how you are using the API to
extract the font:

You can use the following code instead:

In C#:

if (stm != null) {
  FilterReader reader = new
  StdFile f = new StdFile(output_path, StdFile.OpenMode.e_write_mode);
  FilterWriter writer = new FilterWriter(f);

In C++:

Filter stm(font.GetEmbeddedFont().GetRawStream(true));
if (stm) {
  FilterReader reader(stm);
  StdFile f(fname, StdFile::e_write_mode);
  FilterWriter writer(f);

StdFile interface has been removed. Here is the updated code.

if (font.IsEmbedded()) { Filter filter = font.GetEmbeddedFont().GetRawStream(true); filter.WriteToFile(output_path, false); }