]> git.sesse.net Git - vlc/commitdiff
* moved the default font in share/skins2/fonts
authorCyril Deguet <asmax@videolan.org>
Sun, 21 Mar 2004 20:39:43 +0000 (20:39 +0000)
committerCyril Deguet <asmax@videolan.org>
Sun, 21 Mar 2004 20:39:43 +0000 (20:39 +0000)
  * parser/builder.cpp: a font with ID "defaultfont" is loaded from
  the common font directory

modules/gui/skins2/parser/builder.cpp
modules/gui/skins2/parser/builder.hpp
share/skins2/fonts/FreeSans.ttf [moved from share/skins2/FreeSans.ttf with 100% similarity]

index 3002e9086740e96e88f16bb96e2447af211575f3..c3dfa384f03c5159cbcceee2468e11dc97874805 100755 (executable)
@@ -116,8 +116,16 @@ void Builder::addTheme( const BuilderData::Theme &rData )
     rManager.setMagnetValue( rData.m_magnet );
     rManager.setAlphaValue( rData.m_alpha );
     rManager.setMoveAlphaValue( rData.m_moveAlpha );
-    GenericFont *pFont = new FT2Font( getIntf(), "FreeSans.ttf", 12 );
-    pFont->init();
+    GenericFont *pFont = getFont( rData.m_tooltipfont );
+    if( pFont )
+    {
+        rManager.createTooltip( *pFont );
+    }
+    else
+    {
+        msg_Warn( getIntf(), "Invalid tooltip font: %s",
+                  rData.m_tooltipfont.c_str() );
+    }
 }
 
 
@@ -381,7 +389,7 @@ void Builder::addText( const BuilderData::Text &rData )
         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() );
@@ -524,7 +532,7 @@ void Builder::addList( const BuilderData::List &rData )
         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() );
@@ -651,6 +659,32 @@ const Position Builder::makePosition( const string &rLeftTop,
 }
 
 
+GenericFont *Builder::getFont( const string &fontId )
+{
+    GenericFont *pFont = m_pTheme->m_fonts[fontId].get();
+    if( !pFont && fontId == "defaultfont" )
+    {
+#ifdef WIN32_SKINS
+        string defaultFont = (string)getIntf()->p_libvlc->psz_vlcpath +
+                             "\\skins2\\fonts\\FreeSans.ttf";
+#else
+        string defaultFont = (string)DATA_PATH + "/skins2/fonts/FreeSans.ttf";
+#endif
+        pFont = new FT2Font( getIntf(), defaultFont, 12 );
+        if( pFont->init() )
+        {
+            m_pTheme->m_fonts["defaultfont"] = GenericFontPtr( pFont );
+        }
+        else
+        {
+            delete pFont;
+            pFont = NULL;
+        }
+    }
+    return pFont;
+}
+
+
 Bezier *Builder::getPoints( const char *pTag ) const
 {
     vector<float> xBez, yBez;
index 41658dfdc363392c967ccb1627f98b69bd3adcdb..6194a3474087de57204de80b46d4a432bcf38619 100644 (file)
@@ -84,6 +84,9 @@ class Builder: public SkinObject
                                      int xPos, int yPos, int width, int height,
                                      const Box &rBox ) const;
 
+        /// Get a font from its id
+        GenericFont *getFont( const string &fontId );
+
         /// Function to parse "points" tags
         Bezier *getPoints( const char *pTag ) const;
 };