void cFontLoader:: ExportDFFToFile(tDistanceFontHandle font, const Twine& in_path /*= ""*/) { auto& dff = DistanceFont(font); size_t face_size = cSerialization::SerializedSize(dff.Face()); cDFFFile pair(dff, face_size); AlignedBuffer<16> buffer; cSerialization::SerializeLZMA(pair,buffer); cStringRef file_data(buffer.ptr<char>(), buffer.size()); try{ if (sys::path::has_filename(in_path)) { WriteFileToDisk(file_data, in_path); } else { cSmallVector<char, 256> path_buf; cStringRef temp_path = in_path.toNullTerminatedStringRef(path_buf); sys::path::append(path_buf, in_path, dff.FontName() + ".dff"); cStringRef full_path(path_buf.data(), path_buf.size()); WriteFileToDisk(file_data, full_path); } } catch (const Exception& e) { Log::Warn("Swallowed exception while trying to write dff file: %s", e.what()); } }
/************************************************************************** * * Name : FileSave(mp2) * * Description: Processes the File menu's Save item * * Concepts: Called whenever SAVE from the FILE menu is selected * * Routine opens the file for output, calls the * application's save routine, and closes the file. * * API's : DosOpen * DosClose * * Parameters : mp2 = second message parameter * * Return : [none] * *************************************************************************/ VOID FileSave(MPARAM mp2) { HFILE hf; ULONG ulAction; /* * If the file currently is untitled, we will need to get a file * name from the user before we can open the file. Getting a * file name is normally done during the FileSaveAs operation * so we will treat this save as a SaveAs and call FileSaveAs(). * If the file is titled, then we save the file. * * NOTE: This routine will be called by FileSaveAs(), but only * after a valid file name has been obtained. So, FileSaveAs() * will not be called again from this routine. */ if(szFullPath[0] == '\0') { FileSaveAs(mp2); return; } /* open the file */ if( DosOpen(szFullPath, /* file name of current document */ &hf, /* file handle of output file */ &ulAction, 0L, FILE_NORMAL, FILE_OPEN | FILE_CREATE, OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE, (PEAOP2)NULL)) { MessageBox(hwndMain, IDMSG_CANNOTOPENOUTPUTFILE, MB_OK | MB_ERROR, FALSE); return; } WriteFileToDisk(hf); DosClose(hf); /* This routine currently doesn't use the mp2 parameter but *\ * it is referenced here to prevent an 'Unreferenced Parameter' \* warning at compile time. */ mp2; } /* End of FileSave */