@@ -653,35 +653,13 @@ QStringList CEGUIManager::getAvailableFonts() const
653653
654654bool CEGUIManager::saveFont (CEGUI ::Font& font, bool addToSchemes) const
655655{
656- const QString fontName = CEGUIUtils::stringToQString (font.getName ());
657- const QString fontDescFileName = fontName + " .font" ;
656+ const QString fontDescFileName = CEGUIUtils::stringToQString (font.getName ()) + " .font" ;
658657
659658 // Save an XML font description to the project
660- // TODO: rewrite with FontManager::writeFontToStream!
661-
662- QDomDocument doc;
663- auto xmlHeader = doc.createProcessingInstruction (" xml" , " version=\" 1.0\" encoding=\" utf-8\" " );
664- doc.appendChild (xmlHeader);
665- auto xmlRoot = doc.createElement (" Font" );
666- xmlRoot.setAttribute (" version" , " 3" );
667- xmlRoot.setAttribute (" name" , fontName);
668- xmlRoot.setAttribute (" filename" , CEGUIUtils::stringToQString (font.getFileName ()));
669- xmlRoot.setAttribute (" type" , CEGUIUtils::stringToQString (font.getTypeName ()));
670- if (auto freeTypeFont = dynamic_cast <CEGUI ::FreeTypeFont*>(&font))
671- xmlRoot.setAttribute (" size" , QString::number (static_cast <int >(freeTypeFont->getSize ())));
672- xmlRoot.setAttribute (" nativeHorzRes" , QString::number (static_cast <int >(font.getNativeResolution ().d_width )));
673- xmlRoot.setAttribute (" nativeVertRes" , QString::number (static_cast <int >(font.getNativeResolution ().d_height )));
674- xmlRoot.setAttribute (" autoScaled" , CEGUIUtils::stringToQString (CEGUI ::PropertyHelper<CEGUI ::AutoScaledMode>::toString (font.getAutoScaled ())));
675- doc.appendChild (xmlRoot);
676-
677659 {
678660 const auto dstFontDescPath = currentProject->getResourceFilePath (fontDescFileName, " fonts" );
679- QFile file (dstFontDescPath);
680- if (!file.open (QIODevice::WriteOnly | QIODevice::Text)) return false ;
681-
682- QTextStream stream (&file);
683- doc.save (stream, 4 );
684- file.close ();
661+ std::ofstream stream (dstFontDescPath.toStdString (), std::ios_base::out | std::ios_base::trunc);
662+ CEGUI::FontManager::getSingleton ().writeFontToStream (font.getName (), stream);
685663 }
686664
687665 // Add a new font to all schemes
@@ -698,6 +676,8 @@ bool CEGUIManager::saveFont(CEGUI::Font& font, bool addToSchemes) const
698676 QFileInfo info = schemesIt.fileInfo ();
699677 if (info.isDir () || info.suffix () != " scheme" ) continue ;
700678
679+ QDomDocument doc;
680+
701681 // Open, read & close file. We will work with a DOM document.
702682 {
703683 QFile file (info.absoluteFilePath ());
0 commit comments