StelFontMgr.cpp   StelFontMgr.cpp 
skipping to change at line 25 skipping to change at line 25
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include <cmath> #include <cmath>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QRegExp> #include <QRegExp>
#include "StelFontMgr.hpp" #include "StelFontMgr.hpp"
#include "SFont.hpp" #include "StelFont.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
/************************************************************************* /*************************************************************************
Constructor for the StelFontMgr class Constructor for the StelFontMgr class
*************************************************************************/ *************************************************************************/
StelFontMgr::StelFontMgr() StelFontMgr::StelFontMgr()
{ {
QString fontMapFile(""); QString fontMapFile("");
try try
skipping to change at line 51 skipping to change at line 51
qWarning() << "ERROR when locating font map file: " << e.wha t(); qWarning() << "ERROR when locating font map file: " << e.wha t();
} }
loadFontForLanguage(fontMapFile); loadFontForLanguage(fontMapFile);
} }
/************************************************************************* /*************************************************************************
Dealloc memory for all loaded fonts Dealloc memory for all loaded fonts
*************************************************************************/ *************************************************************************/
StelFontMgr::~StelFontMgr() StelFontMgr::~StelFontMgr()
{ {
std::map<LoadedFont, SFont*, ltLoadedFont>::iterator iter; std::map<LoadedFont, StelFont*, ltLoadedFont>::iterator iter;
for (iter=loadedFonts.begin();iter!=loadedFonts.end();++iter) for (iter=loadedFonts.begin();iter!=loadedFonts.end();++iter)
{ {
if (iter->second) delete iter->second; if (iter->second) delete iter->second;
iter->second = NULL; iter->second = NULL;
} }
} }
/************************************************************************* /*************************************************************************
Equality operator for the FontForLanguage class Equality operator for the FontForLanguage class
*************************************************************************/ *************************************************************************/
skipping to change at line 81 skipping to change at line 81
Constructor for the LoadedFont class Constructor for the LoadedFont class
*************************************************************************/ *************************************************************************/
StelFontMgr::LoadedFont::LoadedFont(const QString& afileName, int asize) StelFontMgr::LoadedFont::LoadedFont(const QString& afileName, int asize)
: fileName(afileName), size(asize) : fileName(afileName), size(asize)
{ {
} }
/************************************************************************* /*************************************************************************
Get the standard font associated to the given language ISO code. Get the standard font associated to the given language ISO code.
*************************************************************************/ *************************************************************************/
SFont& StelFontMgr::getStandardFont(const QString& langageName, double size ) StelFont& StelFontMgr::getStandardFont(const QString& langageName, double s ize)
{ {
FontForLanguage ffl = getFontForLanguage(langageName); FontForLanguage ffl = getFontForLanguage(langageName);
LoadedFont lf(ffl.fontFileName, (int)(ffl.fontScale*size*10)); LoadedFont lf(ffl.fontFileName, (int)(ffl.fontScale*size*10));
if (loadedFonts.find(lf)!=loadedFonts.end()) if (loadedFonts.find(lf)!=loadedFonts.end())
{ {
return *(loadedFonts[lf]); return *(loadedFonts[lf]);
} }
else else
{ {
try try
{ {
SFont* font = new SFont((double)lf.size/10, StelApp: :getInstance().getFileMgr().findFile("data/"+lf.fileName)); StelFont* font = new StelFont((double)lf.size/10, St elApp::getInstance().getFileMgr().findFile("data/"+lf.fileName));
loadedFonts[lf]=font; loadedFonts[lf]=font;
return *font; return *font;
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "ERROR while trying to load fonts: " < < e.what(); qWarning() << "ERROR while trying to load fonts: " < < e.what();
SFont* dummy=NULL; StelFont* dummy=NULL;
return *dummy; return *dummy;
} }
} }
} }
/************************************************************************* /*************************************************************************
Get the fixed font associated to the given language ISO code. Get the fixed font associated to the given language ISO code.
*************************************************************************/ *************************************************************************/
SFont& StelFontMgr::getFixedFont(const QString &langageName, double size) StelFont& StelFontMgr::getFixedFont(const QString &langageName, double size )
{ {
FontForLanguage ffl = getFontForLanguage(langageName); FontForLanguage ffl = getFontForLanguage(langageName);
LoadedFont lf(ffl.fixedFontFileName, (int)(ffl.fixedFontScale*size*1 0)); LoadedFont lf(ffl.fixedFontFileName, (int)(ffl.fixedFontScale*size*1 0));
if (loadedFonts.find(lf)!=loadedFonts.end()) if (loadedFonts.find(lf)!=loadedFonts.end())
{ {
return *(loadedFonts[lf]); return *(loadedFonts[lf]);
} }
else else
{ {
try { try {
SFont* font = new SFont((double)lf.size/10, StelApp: :getInstance().getFileMgr().findFile("data/" + lf.fileName)); StelFont* font = new StelFont((double)lf.size/10, St elApp::getInstance().getFileMgr().findFile("data/" + lf.fileName));
loadedFonts[lf]=font; loadedFonts[lf]=font;
return *font; return *font;
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "ERROR loading font " << lf.fileName < < ": " << e.what(); qWarning() << "ERROR loading font " << lf.fileName < < ": " << e.what();
} }
} }
// Unreachable code // Unreachable code
assert(false); Q_ASSERT(false);
SFont* dummy=NULL; StelFont* dummy=NULL;
return *dummy; return *dummy;
} }
/************************************************************************* /*************************************************************************
Return the structure describing the fonts and scales to use for a given la nguage Return the structure describing the fonts and scales to use for a given la nguage
*************************************************************************/ *************************************************************************/
StelFontMgr::FontForLanguage& StelFontMgr::getFontForLanguage(const QString & langageName) StelFontMgr::FontForLanguage& StelFontMgr::getFontForLanguage(const QString & langageName)
{ {
if (fontMapping.find(langageName)==fontMapping.end()) if (fontMapping.find(langageName)==fontMapping.end())
return fontMapping["*"]; return fontMapping["*"];
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/