[vlc-commits] skins2: fix font path processing

Erwan Tulou git at videolan.org
Tue Mar 1 21:33:07 CET 2011


vlc/vlc-1.1 | branch: master | Erwan Tulou <erwan10 at videolan.org> | Tue Mar  1 21:27:06 2011 +0100| [e014ef738cbd49ba3a5df44a88b33ff1af80f1e6] | committer: Erwan Tulou

skins2: fix font path processing

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=e014ef738cbd49ba3a5df44a88b33ff1af80f1e6
---

 modules/gui/skins2/parser/builder.cpp |   51 +++++++++++++++------------------
 1 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp
index ff9d445..f2b2e15 100644
--- a/modules/gui/skins2/parser/builder.cpp
+++ b/modules/gui/skins2/parser/builder.cpp
@@ -277,41 +277,36 @@ void Builder::addBitmapFont( const BuilderData::BitmapFont &rData )
 
 void Builder::addFont( const BuilderData::Font &rData )
 {
-    string full_path = getFilePath( rData.m_fontFile );
-    if( !full_path.size() )
-        return;
-
     // Try to load the font from the theme directory
-    GenericFont *pFont = new FT2Font( getIntf(), full_path, rData.m_size );
-    if( pFont->init() )
-    {
-        m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
-    }
-    else
+    string full_path = getFilePath( rData.m_fontFile );
+    if( full_path.size() )
     {
+        GenericFont *pFont = new FT2Font( getIntf(), full_path, rData.m_size );
+        if( pFont->init() )
+        {
+            m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
+            return;
+        }
         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();
+    // 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++ )
+    list<string>::const_iterator it;
+    for( it = resPath.begin(); it != resPath.end(); ++it )
+    {
+        string path = (*it) + sep + "fonts" + sep + rData.m_fontFile;
+        GenericFont *pFont = new FT2Font( getIntf(), path, rData.m_size );
+        if( pFont->init() )
         {
-            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;
-            }
+            // Font loaded successfully
+            m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
+            return;
         }
+        delete pFont;
     }
 }
 



More information about the vlc-commits mailing list