]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/parser/builder.cpp
* skin.dtd: added an attribute "resize" in the "Image" element, to define
[vlc] / modules / gui / skins2 / parser / builder.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 4c98d40..12b0448
@@ -2,7 +2,7 @@
  * builder.cpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: builder.cpp,v 1.5 2004/02/01 16:15:40 asmax Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -29,8 +29,9 @@
 #include "../src/png_bitmap.hpp"
 #include "../src/os_factory.hpp"
 #include "../src/generic_bitmap.hpp"
-#include "../src/generic_window.hpp"
+#include "../src/top_window.hpp"
 #include "../src/anchor.hpp"
+#include "../src/bitmap_font.hpp"
 #include "../src/ft2_font.hpp"
 #include "../src/theme.hpp"
 #include "../controls/ctrl_button.hpp"
 #include "../controls/ctrl_slider.hpp"
 #include "../controls/ctrl_radialslider.hpp"
 #include "../controls/ctrl_text.hpp"
+#include "../controls/ctrl_video.hpp"
 #include "../utils/position.hpp"
 #include "../utils/var_bool.hpp"
 #include "../utils/var_text.hpp"
 
+#include "vlc_image.h"
 
-Builder::Builder( intf_thread_t *pIntf, const BuilderData &rData):
+
+Builder::Builder( intf_thread_t *pIntf, const BuilderData &rData ):
     SkinObject( pIntf ), m_rData( rData ), m_pTheme( NULL )
 {
+    m_pImageHandler = image_HandlerCreate( pIntf );
 }
 
+Builder::~Builder()
+{
+    if( m_pImageHandler ) image_HandlerDelete( m_pImageHandler );
+}
 
 CmdGeneric *Builder::parseAction( const string &rAction )
 {
@@ -80,6 +89,7 @@ Theme *Builder::build()
     // Create everything from the data in the XML
     ADD_OBJECTS( Theme );
     ADD_OBJECTS( Bitmap );
+    ADD_OBJECTS( BitmapFont );
     ADD_OBJECTS( Font );
     ADD_OBJECTS( Window );
     ADD_OBJECTS( Layout );
@@ -91,6 +101,7 @@ Theme *Builder::build()
     ADD_OBJECTS( RadialSlider );
     ADD_OBJECTS( Slider );
     ADD_OBJECTS( List );
+    ADD_OBJECTS( Video );
 
     return m_pTheme;
 }
@@ -100,7 +111,7 @@ Theme *Builder::build()
 #define GET_BMP( pBmp, id ) \
     if( id != "none" ) \
     { \
-        pBmp = m_pTheme->m_bitmaps[id].get(); \
+        pBmp = m_pTheme->getBitmapById(id); \
         if( pBmp == NULL ) \
         { \
             msg_Err( getIntf(), "unknown bitmap id: %s", id.c_str() ); \
@@ -110,46 +121,79 @@ Theme *Builder::build()
 
 void Builder::addTheme( const BuilderData::Theme &rData )
 {
-    m_pTheme->getWindowManager().setMagnetValue( rData.m_magnet );
-    m_pTheme->getWindowManager().setAlphaValue( rData.m_alpha );
-    m_pTheme->getWindowManager().setMoveAlphaValue( rData.m_moveAlpha );
+    WindowManager &rManager = m_pTheme->getWindowManager();
+    rManager.setMagnetValue( rData.m_magnet );
+    rManager.setAlphaValue( rData.m_alpha );
+    rManager.setMoveAlphaValue( rData.m_moveAlpha );
+    GenericFont *pFont = getFont( rData.m_tooltipfont );
+    if( pFont )
+    {
+        rManager.createTooltip( *pFont );
+    }
+    else
+    {
+        msg_Warn( getIntf(), "Invalid tooltip font: %s",
+                  rData.m_tooltipfont.c_str() );
+    }
 }
 
 
 void Builder::addBitmap( const BuilderData::Bitmap &rData )
 {
-    GenericBitmap *pBmp = new PngBitmap( getIntf(), rData.m_fileName,
-                                         rData.m_alphaColor );
+    GenericBitmap *pBmp =
+        new PngBitmap( getIntf(), m_pImageHandler,
+                       rData.m_fileName, rData.m_alphaColor );
     m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp );
 }
 
 
+void Builder::addBitmapFont( const BuilderData::BitmapFont &rData )
+{
+    GenericBitmap *pBmp =
+        new PngBitmap( getIntf(), m_pImageHandler, rData.m_file, 0 );
+    m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp );
+
+    GenericFont *pFont = new BitmapFont( getIntf(), *pBmp, rData.m_type );
+    if( pFont->init() )
+    {
+        m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
+    }
+    else
+    {
+        delete pFont;
+    }
+}
+
+
 void Builder::addFont( const BuilderData::Font &rData )
 {
-    GenericFont *pFont = new FT2Font( getIntf(), rData.m_fontName,
+    GenericFont *pFont = new FT2Font( getIntf(), rData.m_fontFile,
                                       rData.m_size );
-    pFont->init();
-    m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
+    if( pFont->init() )
+    {
+        m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
+    }
+    else
+    {
+        delete pFont;
+    }
 }
 
 
 void Builder::addWindow( const BuilderData::Window &rData )
 {
-    // XXX:  font to fix
-    GenericFont *pFont = new FT2Font( getIntf(), "FreeSans.ttf", 12 );
-    pFont->init();
-    GenericWindow *pWin =
-        new GenericWindow( getIntf(), rData.m_xPos, rData.m_yPos,
-                           m_pTheme->getWindowManager(), *pFont,
+    TopWindow *pWin =
+        new TopWindow( getIntf(), rData.m_xPos, rData.m_yPos,
+                           m_pTheme->getWindowManager(),
                            rData.m_dragDrop, rData.m_playOnDrop );
 
-    m_pTheme->m_windows[uniqueId( rData.m_id) ] = GenericWindowPtr( pWin );
+    m_pTheme->m_windows[rData.m_id] = TopWindowPtr( pWin );
 }
 
 
 void Builder::addLayout( const BuilderData::Layout &rData )
 {
-    GenericWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
+    TopWindow *pWin = m_pTheme->getWindowById(rData.m_windowId);
     if( pWin == NULL )
     {
         msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
@@ -166,25 +210,35 @@ void Builder::addLayout( const BuilderData::Layout &rData )
                                                 rData.m_height,
                                                 minWidth, maxWidth, minHeight,
                                                 maxHeight );
-    m_pTheme->m_layouts[uniqueId( rData.m_id) ] = GenericLayoutPtr( pLayout );
+    m_pTheme->m_layouts[rData.m_id] = GenericLayoutPtr( pLayout );
 
     // Attach the layout to its window
-    pWin->setActiveLayout( pLayout );
+    m_pTheme->getWindowManager().addLayout( *pWin, *pLayout );
 }
 
 
 void Builder::addAnchor( const BuilderData::Anchor &rData )
 {
-    GenericWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
-    if( pWin == NULL )
+    GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
+    if( pLayout == NULL )
     {
-        msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
+        msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
+        return;
+    }
+
+    Bezier *pCurve = getPoints( rData.m_points.c_str() );
+    if( pCurve == NULL )
+    {
+        msg_Err( getIntf(), "Invalid format in tag points=\"%s\"",
+                 rData.m_points.c_str() );
         return;
     }
+    m_pTheme->m_curves.push_back( BezierPtr( pCurve ) );
 
     Anchor *pAnc = new Anchor( getIntf(), rData.m_xPos, rData.m_yPos,
-                               rData.m_range, rData.m_priority, *pWin );
-    pWin->addAnchor( pAnc );
+                               rData.m_range, rData.m_priority,
+                               *pCurve, *pLayout );
+    pLayout->addAnchor( pAnc );
 }
 
 
@@ -200,7 +254,7 @@ void Builder::addButton( const BuilderData::Button &rData )
     GenericBitmap *pBmpOver = pBmpUp;
     GET_BMP( pBmpOver, rData.m_overId );
 
-    GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
+    GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
     if( pLayout == NULL )
     {
         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
@@ -214,9 +268,14 @@ void Builder::addButton( const BuilderData::Button &rData )
         return;
     }
 
+    // Get the visibility variable
+    // XXX check when it is null
+    Interpreter *pInterpreter = Interpreter::instance( getIntf() );
+    VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
+
     CtrlButton *pButton = new CtrlButton( getIntf(), *pBmpUp, *pBmpOver,
         *pBmpDown, *pCommand, UString( getIntf(), rData.m_tooltip.c_str() ),
-        UString( getIntf(), rData.m_help.c_str() ) );
+        UString( getIntf(), rData.m_help.c_str() ), pVisible );
 
     // Compute the position of the control
     // XXX (we suppose all the images have the same size...)
@@ -227,7 +286,7 @@ void Builder::addButton( const BuilderData::Button &rData )
 
     pLayout->addControl( pButton, pos, rData.m_layer );
 
-    m_pTheme->m_controls[uniqueId( rData.m_id) ] = CtrlGenericPtr( pButton );
+    m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pButton );
 }
 
 
@@ -252,7 +311,7 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData )
     GenericBitmap *pBmpOver2 = pBmpUp2;
     GET_BMP( pBmpOver2, rData.m_over2Id );
 
-    GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
+    GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
     if( pLayout == NULL )
     {
         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
@@ -282,12 +341,16 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData )
         return;
     }
 
+    // Get the visibility variable
+    // XXX check when it is null
+    VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
+
     // Create the control
     CtrlCheckbox *pCheckbox = new CtrlCheckbox( getIntf(), *pBmpUp1,
         *pBmpOver1, *pBmpDown1, *pBmpUp2, *pBmpOver2, *pBmpDown2, *pCommand1,
         *pCommand2, UString( getIntf(), rData.m_tooltip1.c_str() ),
         UString( getIntf(), rData.m_tooltip2.c_str() ), *pVar,
-        UString( getIntf(), rData.m_help.c_str() ) );
+        UString( getIntf(), rData.m_help.c_str() ), pVisible );
 
     // Compute the position of the control
     // XXX (we suppose all the images have the same size...)
@@ -298,7 +361,7 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData )
 
     pLayout->addControl( pCheckbox, pos, rData.m_layer );
 
-    m_pTheme->m_controls[uniqueId( rData.m_id) ] = CtrlGenericPtr( pCheckbox );
+    m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCheckbox );
 }
 
 
@@ -307,22 +370,29 @@ void Builder::addImage( const BuilderData::Image &rData )
     GenericBitmap *pBmp = NULL;
     GET_BMP( pBmp, rData.m_bmpId );
 
-    GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
+    GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
     if( pLayout == NULL )
     {
         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
         return;
     }
 
-    GenericWindow *pWindow = m_pTheme->m_windows[rData.m_windowId].get();
+    TopWindow *pWindow = m_pTheme->getWindowById(rData.m_windowId);
     if( pWindow == NULL )
     {
         msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
         return;
     }
 
-    CtrlImage *pImage = new CtrlImage( getIntf(), *pBmp,
-                                UString( getIntf(), rData.m_help.c_str() ) );
+    // Get the visibility variable
+    // XXX check when it is null
+    Interpreter *pInterpreter = Interpreter::instance( getIntf() );
+    VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
+
+    CtrlImage::resize_t resizeMethod =
+        (rData.m_resize == "scale" ? CtrlImage::kScale : CtrlImage::kMosaic);
+    CtrlImage *pImage = new CtrlImage( getIntf(), *pBmp, resizeMethod,
+        UString( getIntf(), rData.m_help.c_str() ), pVisible );
 
     // Compute the position of the control
     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
@@ -331,16 +401,17 @@ void Builder::addImage( const BuilderData::Image &rData )
                                        pBmp->getHeight(), *pLayout );
 
     // XXX: test to be changed! XXX
-    if( rData.m_onclickId == "move" )
+    if( rData.m_actionId == "move" )
     {
         CtrlMove *pMove = new CtrlMove( getIntf(), m_pTheme->getWindowManager(),
-             *pImage, *pWindow, UString( getIntf(), rData.m_help.c_str() ) );
+             *pImage, *pWindow, UString( getIntf(), rData.m_help.c_str() ),
+             NULL);
         pLayout->addControl( pMove, pos, rData.m_layer );
     }
-    else if( rData.m_onclickId == "resize" )
+    else if( rData.m_actionId == "resizeSE" )
     {
         CtrlResize *pResize = new CtrlResize( getIntf(), *pImage, *pLayout,
-                UString( getIntf(), rData.m_help.c_str() ) );
+                UString( getIntf(), rData.m_help.c_str() ), NULL );
         pLayout->addControl( pResize, pos, rData.m_layer );
     }
     else
@@ -348,20 +419,20 @@ void Builder::addImage( const BuilderData::Image &rData )
         pLayout->addControl( pImage, pos, rData.m_layer );
     }
 
-    m_pTheme->m_controls[uniqueId( rData.m_id) ] = CtrlGenericPtr( pImage );
+    m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pImage );
 }
 
 
 void Builder::addText( const BuilderData::Text &rData )
 {
-    GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
+    GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
     if( pLayout == NULL )
     {
         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
         return;
     }
 
-    GenericFont *pFont = m_pTheme->m_fonts[rData.m_fontId].get();
+    GenericFont *pFont = getFont( rData.m_fontId );
     if( pFont == NULL )
     {
         msg_Err( getIntf(), "Unknown font id: %s", rData.m_fontId.c_str() );
@@ -374,17 +445,25 @@ void Builder::addText( const BuilderData::Text &rData )
     pVar->set( msg );
     m_pTheme->m_vars.push_back( VariablePtr( pVar ) );
 
+    // Get the visibility variable
+    // XXX check when it is null
+    Interpreter *pInterpreter = Interpreter::instance( getIntf() );
+    VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
+
     CtrlText *pText = new CtrlText( getIntf(), *pVar, *pFont,
-            UString( getIntf(), rData.m_help.c_str() ) );
+        UString( getIntf(), rData.m_help.c_str() ), rData.m_color, pVisible );
 
     int height = pFont->getSize();
 
-    pLayout->addControl( pText, Position( rData.m_xPos, rData.m_yPos,
-                                          rData.m_xPos + rData.m_width,
-                                          rData.m_yPos + height, *pLayout ),
-                         rData.m_layer );
+    // Compute the position of the control
+    const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
+                                       rData.m_xPos, rData.m_yPos,
+                                       rData.m_width, height,
+                                       *pLayout );
+
+    pLayout->addControl( pText, pos, rData.m_layer );
 
-    m_pTheme->m_controls[uniqueId( rData.m_id) ] = CtrlGenericPtr( pText );
+    m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pText );
 }
 
 
@@ -394,7 +473,7 @@ void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
     GenericBitmap *pSeq = NULL;
     GET_BMP( pSeq, rData.m_sequence );
 
-    GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
+    GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
     if( pLayout == NULL )
     {
         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
@@ -410,11 +489,16 @@ void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
         return;
     }
 
+    // Get the visibility variable
+    // XXX check when it is null
+    VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
+
     // Create the control
     CtrlRadialSlider *pRadial =
         new CtrlRadialSlider( getIntf(), *pSeq, rData.m_nbImages, *pVar,
                               rData.m_minAngle, rData.m_maxAngle,
-                              UString( getIntf(), rData.m_help.c_str() ) );
+                              UString( getIntf(), rData.m_help.c_str() ),
+                              pVisible );
 
     // XXX: resizing is not supported
     // Compute the position of the control
@@ -425,7 +509,7 @@ void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
 
     pLayout->addControl( pRadial, pos, rData.m_layer );
 
-    m_pTheme->m_controls[uniqueId( rData.m_id) ] = CtrlGenericPtr( pRadial );
+    m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pRadial );
 }
 
 
@@ -441,7 +525,7 @@ void Builder::addSlider( const BuilderData::Slider &rData )
     GenericBitmap *pBmpOver = pBmpUp;
     GET_BMP( pBmpOver, rData.m_overId );
 
-    GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
+    GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
     if( pLayout == NULL )
     {
         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
@@ -489,22 +573,21 @@ void Builder::addSlider( const BuilderData::Slider &rData )
     pLayout->addControl( pBackground, pos, rData.m_layer );
     pLayout->addControl( pCursor, pos, rData.m_layer );
 
-    string newId = uniqueId( rData.m_id );
-    m_pTheme->m_controls[newId] = CtrlGenericPtr( pCursor );
-    m_pTheme->m_controls[newId + "_bg"] = CtrlGenericPtr( pBackground );
+    m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCursor );
+    m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground );
 }
 
 
 void Builder::addList( const BuilderData::List &rData )
 {
-    GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
+    GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
     if( pLayout == NULL )
     {
         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
         return;
     }
 
-    GenericFont *pFont = m_pTheme->m_fonts[rData.m_fontId].get();
+    GenericFont *pFont = getFont( rData.m_fontId );
     if( pFont == NULL )
     {
         msg_Err( getIntf(), "Unknown font id: %s", rData.m_fontId.c_str() );
@@ -520,11 +603,15 @@ void Builder::addList( const BuilderData::List &rData )
         return;
     }
 
+    // Get the visibility variable
+    // XXX check when it is null
+    VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
+
     // Create the list control
     CtrlList *pList = new CtrlList( getIntf(), *pVar, *pFont,
        rData.m_fgColor, rData.m_playColor, rData.m_bgColor1,
        rData.m_bgColor2, rData.m_selColor,
-       UString( getIntf(), rData.m_help.c_str() ) );
+       UString( getIntf(), rData.m_help.c_str() ), pVisible );
 
     // Compute the position of the control
     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
@@ -534,49 +621,39 @@ void Builder::addList( const BuilderData::List &rData )
 
     pLayout->addControl( pList, pos, rData.m_layer );
 
-    m_pTheme->m_controls[uniqueId( rData.m_id) ] = CtrlGenericPtr( pList );
+    m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pList );
 }
 
 
-const string Builder::generateId() const
+void Builder::addVideo( const BuilderData::Video &rData )
 {
-    static int i = 1;
-
-    const string base = "_ReservedId_";
-    char genId[base.size() + 4];
-    snprintf( genId, base.size() + 4, "%s%i", base.c_str(), i );
-    i++;
-    return genId;
-}
+    GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
+    if( pLayout == NULL )
+    {
+        msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
+        return;
+    }
 
+    // Get the visibility variable
+    // XXX check when it is null
+    Interpreter *pInterpreter = Interpreter::instance( getIntf() );
+    VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
 
-const string Builder::uniqueId( const string &id )
-{
-    string newId;
+    CtrlVideo *pVideo = new CtrlVideo( getIntf(),
+        UString( getIntf(), rData.m_help.c_str() ), pVisible );
 
-    if( m_idSet.find( id ) != m_idSet.end() )
-    {
-        // The id was already used
-        if( id != "none" )
-        {
-            msg_Warn( getIntf(), "Non unique id: %s", id.c_str() );
-        }
-        newId = generateId();
-    }
-    else
-    {
-        // OK, this is a new id
-        newId = id;
-    }
+    // Compute the position of the control
+    const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
+                                       rData.m_xPos, rData.m_yPos,
+                                       rData.m_width, rData.m_height,
+                                       *pLayout );
 
-    // Add the id to the set
-    m_idSet.insert( newId );
+    pLayout->addControl( pVideo, pos, rData.m_layer );
 
-    return newId;
+    m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pVideo );
 }
 
 
-
 const Position Builder::makePosition( const string &rLeftTop,
                                       const string &rRightBottom,
                                       int xPos, int yPos, int width,
@@ -646,22 +723,60 @@ const Position Builder::makePosition( const string &rLeftTop,
 }
 
 
+GenericFont *Builder::getFont( const string &fontId )
+{
+    GenericFont *pFont = m_pTheme->getFontById(fontId);
+    if( !pFont && fontId == "defaultfont" )
+    {
+        // Get the resource path and try to load the default font
+        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 + "FreeSans.ttf";
+            pFont = new FT2Font( getIntf(), path, 12 );
+            if( pFont->init() )
+            {
+                // Font loaded successfully
+                m_pTheme->m_fonts["defaultfont"] = GenericFontPtr( pFont );
+                break;
+            }
+            else
+            {
+                delete pFont;
+                pFont = NULL;
+            }
+        }
+        if( !pFont )
+        {
+            msg_Err( getIntf(), "Failed to open the default font" );
+        }
+    }
+    return pFont;
+}
+
+
 Bezier *Builder::getPoints( const char *pTag ) const
 {
     vector<float> xBez, yBez;
     int x, y, n;
     while( 1 )
     {
-        if( sscanf( pTag, "(%d,%d)%n", &x, &y, &n ) < 2 )
+        if( sscanf( pTag, "(%d,%d)%n", &x, &y, &n ) < 1 )
         {
             return NULL;
         }
+#if 0
         if( x < 0 || y < 0 )
         {
             msg_Err( getIntf(),
                      "Slider points cannot have negative coordinates!" );
             return NULL;
         }
+#endif
         xBez.push_back( x );
         yBez.push_back( y );
         pTag += n;