Is this possible yet?
#1
"Feature Request - ability for addons to ship their own fonts"

http://forum.xbmc.org/showthread.php?tid=195104
Reply
#2
No built in support for it yet. Here's a link on the current workaround for skinned plugins.
http://forum.xbmc.org/showthread.php?tid...=myfont.py
Reply
#3
(2014-10-12, 01:53)jerimiah797 Wrote: No built in support for it yet. Here's a link on the current workaround for skinned plugins.
http://forum.xbmc.org/showthread.php?tid...=myfont.py

Yeah I played around with Myfont... sort of... but couldn't ever get it to actually install the font file. I could get it to add the text to the font.xml definitions file but couldn't ever get it to copy over the actual .ttf file itself to the fonts directory. I gave up after a few hours of messing with it. Was hoping that the ability for addons to use their own fonts would soon be possible. Actually I would even be happy for just the possibility to use different size text with the standard font, but even that doesn't seem possible unless I am missing something.
I really don't care much about the font itself, just the ability to have different sized text in labels.
Reply
#4
Here's the code in my plugin. The trick is that you can only do this with a writeable copy of confluence, so you need to copy it to the user addon folder if necessary. Here's my code for all that:

PHP Code:
def init_fonts(self):
        print 
"Installing fonts"
        
MyFont.addFont"rhapsody_font8" "segoeuisl.ttf" "10"self.__addon_path__ )
        
MyFont.addFont"rhapsody_font9" "segoeuisl.ttf" "12"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font10" "segoeuisl.ttf" "14"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font12" "segoeuisl.ttf" "17"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font13" "segoeuisl.ttf" "20"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font14" "segoeuisl.ttf" "22"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font16" "segoeuisl.ttf" "25"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font30" "segoeuisl.ttf" "30"self.__addon_path__  )
        
MyFont.addFont"rhapsody_fontContextMenu" "segoeuisl.ttf" "18"self.__addon_path__  )

        
MyFont.addFont"rhapsody_font10_title" "seguisb.ttf" "12"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font12_title" "seguisb.ttf" "17"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font13_title" "seguisb.ttf" "20"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font24_title" "seguisb.ttf" "24"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font28_title" "seguisb.ttf" "28"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font30_title" "seguisb.ttf" "30"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font35_title" "seguisb.ttf" "35"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font45caps_title" "seguisb.ttf" "45"self.__addon_path__  )
        
MyFont.addFont"rhapsody_WeatherTemp" "seguisb.ttf" "80"self.__addon_path__  )

        
MyFont.addFont"rhapsody_symbol72" "RhapsodySymbol.ttf" "72"self.__addon_path__  )
        
MyFont.addFont"rhapsody_symbol96" "RhapsodySymbol.ttf" "96"self.__addon_path__  )
        
MyFont.addFont"rhapsody_symbol144" "RhapsodySymbol.ttf" "144"self.__addon_path__  


skincheck.py
PHP Code:
import xbmc
import xbmcgui
import xbmcvfs
import xbmcaddon
import sys
import os
import shutil




def getPlatform
():
    
    if 
'win32' in sys.platform:
        
'win32'
        
print "Windows operating system detected"
    
elif 'linux' in sys.platform:
        
'linux'
        
print "Linux operating system detected"
    
elif 'darwin' in sys.platform:
        
# gotta be a better way to detect ipad/iphone/atv2
        
if 'USER' in os.environ and os.environ['USER'in ('mobile','frontrow',):
            
'ios'
        
else: 
            
'mac'
            
print "MacOS operating system detected"
    
else:
        
log.error('ERROR: Platform check did not match win32, linux, darwin, or iOS. Was %s instead' sys.platform)
        
'linux'
    
return p


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?""Rhapsody needs to restart XBMC and install fonts to proceed. Is this okay?"):
                
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(skinpathdest2)
                print 
"Finished copy. retarting app"
                
xbmc.executebuiltin"XBMC.RestartApp()" )
                exit()
            else:
                print 
'Font install declined. Aborting Rhapsody launch'
                
exit()

        
elif platform == 'linux' and "share" in skinpath:
            print 
"Non-writeable confluence skin in use. Need to make a copy in the userdata folder so we can install fonts."
            
dialog xbmcgui.Dialog()
            if 
dialog.yesno("Install Fonts?""Rhapsody needs to restart XBMC and install fonts to proceed. Is this okay?"):
                
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(skinpathdest2)
                print 
"Finished copy. retarting app"
                
xbmc.executebuiltin"XBMC.RestartApp()" )
                exit()
            else:
                print 
'Font install declined. Aborting Rhapsody launch'
                
exit()
            
        else:
            
pass
            
#print "All is okay. Confluence in use is a writeable copy"

    
return 
Reply
#5
(2014-12-04, 21:47)jerimiah797 Wrote: Here's the code in my plugin. The trick is that you can only do this with a writeable copy of confluence, so you need to copy it to the user addon folder if necessary. Here's my code for all that:

PHP Code:
def init_fonts(self):
        print 
"Installing fonts"
        
MyFont.addFont"rhapsody_font8" "segoeuisl.ttf" "10"self.__addon_path__ )
        
MyFont.addFont"rhapsody_font9" "segoeuisl.ttf" "12"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font10" "segoeuisl.ttf" "14"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font12" "segoeuisl.ttf" "17"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font13" "segoeuisl.ttf" "20"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font14" "segoeuisl.ttf" "22"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font16" "segoeuisl.ttf" "25"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font30" "segoeuisl.ttf" "30"self.__addon_path__  )
        
MyFont.addFont"rhapsody_fontContextMenu" "segoeuisl.ttf" "18"self.__addon_path__  )

        
MyFont.addFont"rhapsody_font10_title" "seguisb.ttf" "12"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font12_title" "seguisb.ttf" "17"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font13_title" "seguisb.ttf" "20"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font24_title" "seguisb.ttf" "24"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font28_title" "seguisb.ttf" "28"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font30_title" "seguisb.ttf" "30"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font35_title" "seguisb.ttf" "35"self.__addon_path__  )
        
MyFont.addFont"rhapsody_font45caps_title" "seguisb.ttf" "45"self.__addon_path__  )
        
MyFont.addFont"rhapsody_WeatherTemp" "seguisb.ttf" "80"self.__addon_path__  )

        
MyFont.addFont"rhapsody_symbol72" "RhapsodySymbol.ttf" "72"self.__addon_path__  )
        
MyFont.addFont"rhapsody_symbol96" "RhapsodySymbol.ttf" "96"self.__addon_path__  )
        
MyFont.addFont"rhapsody_symbol144" "RhapsodySymbol.ttf" "144"self.__addon_path__  


skincheck.py
PHP Code:
import xbmc
import xbmcgui
import xbmcvfs
import xbmcaddon
import sys
import os
import shutil




def getPlatform
():
    
    if 
'win32' in sys.platform:
        
'win32'
        
print "Windows operating system detected"
    
elif 'linux' in sys.platform:
        
'linux'
        
print "Linux operating system detected"
    
elif 'darwin' in sys.platform:
        
# gotta be a better way to detect ipad/iphone/atv2
        
if 'USER' in os.environ and os.environ['USER'in ('mobile','frontrow',):
            
'ios'
        
else: 
            
'mac'
            
print "MacOS operating system detected"
    
else:
        
log.error('ERROR: Platform check did not match win32, linux, darwin, or iOS. Was %s instead' sys.platform)
        
'linux'
    
return p


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?""Rhapsody needs to restart XBMC and install fonts to proceed. Is this okay?"):
                
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(skinpathdest2)
                print 
"Finished copy. retarting app"
                
xbmc.executebuiltin"XBMC.RestartApp()" )
                exit()
            else:
                print 
'Font install declined. Aborting Rhapsody launch'
                
exit()

        
elif platform == 'linux' and "share" in skinpath:
            print 
"Non-writeable confluence skin in use. Need to make a copy in the userdata folder so we can install fonts."
            
dialog xbmcgui.Dialog()
            if 
dialog.yesno("Install Fonts?""Rhapsody needs to restart XBMC and install fonts to proceed. Is this okay?"):
                
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(skinpathdest2)
                print 
"Finished copy. retarting app"
                
xbmc.executebuiltin"XBMC.RestartApp()" )
                exit()
            else:
                print 
'Font install declined. Aborting Rhapsody launch'
                
exit()
            
        else:
            
pass
            
#print "All is okay. Confluence in use is a writeable copy"

    
return 

Yeah, I finally got it to work but not with the Confluence fix as you have here. This is great!... I'll implement the changes you have here and update my code. thanks bro Wink

[EDIT] Do I need to change anything in MyFont.py?
Reply
#6
Sorry, I missed your followup question. As far as I recall, I didn't need to modify MyFont.py. I have found, however, found a bug in the skincheck file that I haven't fixed yet where it is sometimes possible to get in a situation where the writeable copy of confluence is older than the system copy, and doesn't get used. I need to add version checking into skincheck to mitigate this scenario. Cheers!

-Jerimiah
Reply

Logout Mark Read Team Forum Stats Members Help
Is this possible yet?0