define fonts in skinfile
authorFelix Domke <tmbinc@elitedvb.net>
Wed, 10 May 2006 23:21:37 +0000 (23:21 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Wed, 10 May 2006 23:21:37 +0000 (23:21 +0000)
data/skin.xml
lib/python/enigma_python.i
main/enigma.cpp
skin.py

index 995c51a7b60cd1f0ea013607f7556112fbc09eab..fa6cadebe3e98f22bedb35a466a92201bcddb2f3 100644 (file)
                </borderset>
        </windowstyle>
 
                </borderset>
        </windowstyle>
 
+       <fonts>
+               <font filename="md_khmurabi_10.ttf" name="Regular" scale="100" />
+               <font filename="ae_AlMateen.ttf" name="Replacement" scale="90" is_replacement="1" />
+       </fonts>
+
                <screen name="InfoBar" flags="wfNoBorder" position="0,380" size="720,148" title="InfoBar">
                        <ePixmap position="0,0" zPosition="-1" size="720,148" pixmap="info-bg.png" />
 
                <screen name="InfoBar" flags="wfNoBorder" position="0,380" size="720,148" title="InfoBar">
                        <ePixmap position="0,0" zPosition="-1" size="720,148" pixmap="info-bg.png" />
 
index 04134636ca9d27d1edbef0d4643ff05ae71a5422..eee5ef0001920ee8a3adf6d5178330bb958bd2f2 100644 (file)
@@ -242,6 +242,14 @@ public:
        PyObject *get();
 };
 
        PyObject *get();
 };
 
+/************** temp *****************/
+
+       /* need a better place for this, i agree. */
+%{
+void addFont(const char *filename, const char *alias, int scale_factor, int is_replacement); 
+%}
+void addFont(const char *filename, const char *alias, int scale_factor, int is_replacement);
+
 /**************  debug  **************/
 
 void runMainloop();
 /**************  debug  **************/
 
 void runMainloop();
index 31b81a3f0b98988f444b36d82e5200ba7928854c..f9b88e7f0e1e4892427d81faed16532fdf7dc80a 100644 (file)
@@ -140,10 +140,8 @@ int main(int argc, char **argv)
        ePtr<gLCDDC> my_lcd_dc;
        gLCDDC::getInstance(my_lcd_dc);
 
        ePtr<gLCDDC> my_lcd_dc;
        gLCDDC::getInstance(my_lcd_dc);
 
-       fontRenderClass::getInstance()->AddFont(FONTDIR "/md_khmurabi_10.ttf", "Regular", 100);
-       fontRenderClass::getInstance()->AddFont(FONTDIR "/ae_AlMateen.ttf", "Replacement", 90);
-       eTextPara::setReplacementFont("Replacement");
-       
+
+               /* ok, this is currently hardcoded for arabic. */
                        /* some characters are wrong in the regular font, force them to use the replacement font */
        for (int i = 0x60c; i <= 0x66d; ++i)
                eTextPara::forceReplacementGlyph(i);
                        /* some characters are wrong in the regular font, force them to use the replacement font */
        for (int i = 0x60c; i <= 0x66d; ++i)
                eTextPara::forceReplacementGlyph(i);
@@ -226,3 +224,10 @@ void quitMainloop(int exitCode)
        exit_code = exitCode;
        eApp->quit(0);
 }
        exit_code = exitCode;
        eApp->quit(0);
 }
+
+void addFont(const char *filename, const char *alias, int scale_factor, int is_replacement)
+{
+       fontRenderClass::getInstance()->AddFont(filename, alias, scale_factor);
+       if (is_replacement)
+               eTextPara::setReplacementFont(alias);
+}
diff --git a/skin.py b/skin.py
index fbc5bcd8d843c25f8b439d6eb7cd3d38c887948b..f8fcb1224cf0bca30709a671ea33dea03941215b 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -14,7 +14,7 @@ def dump(x, i=0):
        except:
                None
 
        except:
                None
 
-from Tools.Directories import resolveFilename, SCOPE_SKIN, SCOPE_SKIN_IMAGE
+from Tools.Directories import resolveFilename, SCOPE_SKIN, SCOPE_SKIN_IMAGE, SCOPE_FONTS
 
 dom_skins = [ ]
 
 
 dom_skins = [ ]
 
@@ -84,7 +84,7 @@ def applySingleAttribute(guiObject, desktop, attrib, value):
                elif attrib == "pixmap":
                        ptr = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, value))
                        # that __deref__ still scares me!
                elif attrib == "pixmap":
                        ptr = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, value))
                        # that __deref__ still scares me!
-#                      desktop.makeCompatiblePixmap(ptr.__deref__())
+                       desktop.makeCompatiblePixmap(ptr.__deref__())
                        guiObject.setPixmap(ptr.__deref__())
                        # guiObject.setPixmapFromFile(value)
                elif attrib == "alphatest": # used by ePixmap
                        guiObject.setPixmap(ptr.__deref__())
                        # guiObject.setPixmapFromFile(value)
                elif attrib == "alphatest": # used by ePixmap
@@ -159,7 +159,6 @@ def applySingleAttribute(guiObject, desktop, attrib, value):
                        guiObject.setShadowOffset(parsePosition(value))
                elif attrib != 'name':
                        print "unsupported attribute " + attrib + "=" + value
                        guiObject.setShadowOffset(parsePosition(value))
                elif attrib != 'name':
                        print "unsupported attribute " + attrib + "=" + value
-
        except int:
 # AttributeError:
                print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib)
        except int:
 # AttributeError:
                print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib)
@@ -184,6 +183,14 @@ def loadSingleSkinData(desktop, dom_skin):
                                
                        colorNames[name] = parseColor(color)
        
                                
                        colorNames[name] = parseColor(color)
        
+       for c in elementsWithTag(skin.childNodes, "fonts"):
+               for font in elementsWithTag(c.childNodes, "font"):
+                       filename = str(font.getAttribute("filename") or "<NONAME>")
+                       name = str(font.getAttribute("name") or "Regular")
+                       scale = int(font.getAttribute("scale") or "100")
+                       is_replacement = font.getAttribute("replacement") != ""
+                       addFont(resolveFilename(SCOPE_FONTS, filename), name, scale, is_replacement)
+       
        for windowstyle in elementsWithTag(skin.childNodes, "windowstyle"):
                style = eWindowStyleSkinned()
                
        for windowstyle in elementsWithTag(skin.childNodes, "windowstyle"):
                style = eWindowStyleSkinned()