Using fonts in addons/programs
#1
Is there any way for an addon (other than a skin) to have it's own fonts?
Can it only use Arial (font13) in XBMC/Media/Fonts/ or the fonts in the skin the user has loaded each time?
It's a question of design and a unified interface, only being able to use one font seems kind of silly.

If anyone has any information or input on this it would be greatly appreciated and would save me a lot of time and frustration Confused
Reply
#2
Currently, no. There is no support for fonts other than those that come with the skin. That being said, the basic solution is to install the fonts into the skin and restart xbmc. This can be done manually by the user, or with some python code. This works for all skins except the built in confluence, but there is even a workaround for that. Just copy the confluence skin folder into the user addons folder along with the other skins, and xbmc will load that copy of confluence first.

The most important thing is that the fonts you install, and the way you refer to them in your addon, must be properly namespaced. That is, the names of your fonts as defined in the font.xml should be unique. Instead of using generic names like 'font13', you should use your addons name as a prefix, such as 'addon_myplugin_font13'. That way the fonts you install in the skin won't have any side affects on the skin itself, but will be available to your (or any) addon that explicitly uses them.

There is a script out there somewhere that does the font installation called MyFont. It copies the .ttfs, and appends the new font definitions to the skin's Font.xml file. As long as your fonts are namespaced like I mentioned, there isn't really any reason to have to uninstall them from the skin.

None of this is officially stated anywhere in the docs, but it is the way to deal with the font problem right now.
Reply
#3
Thanks for the answer jerimiah797 Smile
Reply
#4
No problem. Good luck!
Reply
#5
Font modern antique with original Xbmc 12-13 fonts
Reply
#6
Hey, just to close the loop on this... I successfully am using the 'MyFont' package to install the fonts needed for my script. There is some work to do, however, because of the problem that fonts can't be installed to the built-in confluence skin, which many, many people use. It has to be a writable copy of confluence in your userdata folder. Even if that copy exists, it may not be in use if the skin has been revised by an XBMC update. So here's my little routine to check all that and take care of what needs to be taken care of. I've only completed the Windows routine so far, but this should help someone, I would think.

Code:
def skinfix():
    
    
    if xbmc.getSkinDir() == "skin.confluence":
        sk = xbmcaddon.Addon(id="skin.confluence")
        skinpath = sk.getAddonInfo("path")
        #print "skin path: "+skinpath
        platform = getPlatform()
        #print "platform: "+platform

        if platform == 'win32' and "Program" in skinpath:
            print "Non-writeable confluence skin in use. Need to make a copy in userdata folder so we can install fonts."
            dialog = xbmcgui.Dialog()
            if dialog.yesno("Install Fonts?", "script needs to restart XBMC to install fonts. Cool?"):
                dest = xbmc.translatePath("special://home/")
                dest2 = os.path.join(dest, 'addons', 'skin.confluence')
                print "checking for obsolete confluence copy"
                if xbmcvfs.exists(dest2):
                    print "deleting obsolete confluence copy"
                    shutil.rmtree(dest2)
                print "making a writeable confluence copy"
                shutil.copytree(skinpath, dest2)
                print "Finished copy. retarting app"
                xbmc.executebuiltin( "XBMC.RestartApp()" )
                exit()
            else:
                print 'Font install declined. Aborting script launch'
                exit()
            
        else:
            print "All is okay. Confluence in use is a writeable copy"

    return
Reply

Logout Mark Read Team Forum Stats Members Help
Using fonts in addons/programs0