#include "vlc_image.h"
-Builder::Builder( intf_thread_t *pIntf, const BuilderData &rData ):
- SkinObject( pIntf ), m_rData( rData ), m_pTheme( NULL )
+Builder::Builder( intf_thread_t *pIntf, const BuilderData &rData,
+ const string &rPath ):
+ SkinObject( pIntf ), m_rData( rData ), m_path( rPath ), m_pTheme( NULL )
{
m_pImageHandler = image_HandlerCreate( pIntf );
}
{
GenericBitmap *pBmp =
new FileBitmap( getIntf(), m_pImageHandler,
- rData.m_fileName, rData.m_alphaColor );
+ getFilePath( rData.m_fileName ), rData.m_alphaColor );
if( !pBmp->getData() )
{
// Invalid bitmap
void Builder::addBitmapFont( const BuilderData::BitmapFont &rData )
{
GenericBitmap *pBmp =
- new FileBitmap( getIntf(), m_pImageHandler, rData.m_file, 0 );
+ new FileBitmap( getIntf(), m_pImageHandler,
+ getFilePath( rData.m_file ), 0 );
if( !pBmp->getData() )
{
// Invalid bitmap
void Builder::addFont( const BuilderData::Font &rData )
{
- GenericFont *pFont = new FT2Font( getIntf(), rData.m_fontFile,
+ // Try to load the font from the theme directory
+ GenericFont *pFont = new FT2Font( getIntf(),
+ getFilePath( rData.m_fontFile ),
rData.m_size );
if( pFont->init() )
{
else
{
delete pFont;
+
+ // Font not found; try in the resource path
+ OSFactory *pOSFactory = OSFactory::instance( getIntf() );
+ const list<string> &resPath = pOSFactory->getResourcePath();
+ const string &sep = pOSFactory->getDirSeparator();
+
+ list<string>::const_iterator it;
+ for( it = resPath.begin(); it != resPath.end(); it++ )
+ {
+ string path = (*it) + sep + "fonts" + sep + rData.m_fontFile;
+ pFont = new FT2Font( getIntf(), path, rData.m_size );
+ if( pFont->init() )
+ {
+ // Font loaded successfully
+ m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
+ break;
+ }
+ else
+ {
+ delete pFont;
+ }
+ }
}
}
}
+string Builder::getFilePath( const string &rFileName ) const
+{
+ OSFactory *pFactory = OSFactory::instance( getIntf() );
+ return m_path + pFactory->getDirSeparator() + rFileName;
+}
+
+
+
Bezier *Builder::getPoints( const char *pTag ) const
{
vector<float> xBez, yBez;