Commit ce3fc2d4 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX] - fixed problem of font path propagation

parent f5d89d9f
......@@ -34,15 +34,7 @@ boost::shared_ptr< WGEResourceManager > WGEResourceManager::m_instance = boost::
WGEResourceManager::WGEResourceManager()
{
// NOTE: the osgViewer::StatsHandler uses a hard coded font filename. :-(. To keep the look equal we use the same font as
// default font. Since Arial is underlying some weird licence we simply link/copy a font from the liberation package
// (https://fedorahosted.org/liberation-fonts/) to "arial.ttf"
namespace fs = boost::filesystem;
fs::path fontPath = WGraphicsEngine::getGraphicsEngine()->getFontPath();
m_regularFont = fs::path( fontPath / "LiberationMono-Regular.ttf" ).file_string();
m_boldFont = fs::path( fontPath / "LiberationMono-Bold.ttf" ).file_string();
m_italicFont = fs::path( fontPath / "LiberationMono-Italic.ttf" ).file_string();
// initialize
}
WGEResourceManager::~WGEResourceManager()
......@@ -80,3 +72,16 @@ std::string WGEResourceManager::getBoldFont()
return m_boldFont;
}
void WGEResourceManager::setFontPath( std::string path )
{
// NOTE: the osgViewer::StatsHandler uses a hard coded font filename. :-(. To keep the look equal we use the same font as
// default font. Since Arial is underlying some weird licence we simply link/copy a font from the liberation package
// (https://fedorahosted.org/liberation-fonts/) to "arial.ttf"
namespace fs = boost::filesystem;
fs::path fontPath = path;
m_regularFont = fs::path( fontPath / "LiberationMono-Regular.ttf" ).file_string();
m_boldFont = fs::path( fontPath / "LiberationMono-Bold.ttf" ).file_string();
m_italicFont = fs::path( fontPath / "LiberationMono-Italic.ttf" ).file_string();
}
......@@ -85,6 +85,13 @@ public:
*/
std::string getBoldFont();
/**
* Updates the internal font paths according to the specified one.
*
* \param path the new path.
*/
void setFontPath( std::string path );
protected:
/**
......
......@@ -117,6 +117,9 @@ std::string WGraphicsEngine::getFontPath() const
void WGraphicsEngine::setFontPath( std::string path )
{
m_fontPath = path;
// we need to propagate the change to the resource manager
WGEResourceManager::getResourceManager()->setFontPath( path );
}
boost::shared_ptr<WGEViewer> WGraphicsEngine::createViewer( std::string name, osg::ref_ptr<WindowData> wdata, int x, int y,
......
......@@ -67,6 +67,11 @@ std::string WKernel::m_shaderPath = std::string();
*/
std::string WKernel::m_appPath = std::string();
/**
* Define font path.
*/
std::string WKernel::m_fontPath = std::string();
WKernel::WKernel( boost::shared_ptr< WGraphicsEngine > ge, boost::shared_ptr< WGUI > gui ):
WThreadedRunner()
{
......@@ -103,7 +108,7 @@ void WKernel::init()
// initialize graphics engine, or, at least set some stuff
m_graphicsEngine->setShaderPath( m_shaderPath );
m_graphicsEngine->setShaderPath( m_appPath + "/fonts/" );
m_graphicsEngine->setFontPath( m_fontPath );
// load all modules
m_moduleFactory->load();
......@@ -196,10 +201,13 @@ void WKernel::findAppPath()
fs::path currentDir( fs::initial_path<fs::path>() );
m_appPath = currentDir.file_string();
// std::cout << "Set app path to " << m_appPath << std::endl;
WLogger::getLogger()->addLogMessage( "Application path: " + m_appPath, "Kernel", LL_DEBUG );
m_shaderPath = fs::path( currentDir / "shaders" ).file_string();
// std::cout << "Set shader path to " << m_shaderPath << std::endl;
WLogger::getLogger()->addLogMessage( "Shader path: " + m_shaderPath, "Kernel", LL_DEBUG );
m_fontPath = fs::path( currentDir / "fonts" ).file_string();
WLogger::getLogger()->addLogMessage( "Font path: " + m_fontPath, "Kernel", LL_DEBUG );
}
const WBoolFlag& WKernel::isFinishRequested() const
......@@ -233,3 +241,10 @@ std::string WKernel::getShaderPath()
findAppPath();
return WKernel::m_shaderPath;
}
std::string WKernel::getFontPath()
{
findAppPath();
return WKernel::m_fontPath;
}
......@@ -148,6 +148,11 @@ public:
*/
static std::string getShaderPath();
/**
* getter for font path
*/
static std::string getFontPath();
protected:
/**
......@@ -192,14 +197,19 @@ private:
static void findAppPath();
/**
* the location of the openwalnut executable
* The location of the openwalnut executable.
*/
static std::string m_appPath;
/**
* the location of the openwalnut executable
* The location of the shaders.
*/
static std::string m_shaderPath;
/**
* The location of the font files.
*/
static std::string m_fontPath;
};
#endif // WKERNEL_H
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment