2014-10-11, 19:21
"Feature Request - ability for addons to ship their own fonts"
http://forum.xbmc.org/showthread.php?tid=195104
http://forum.xbmc.org/showthread.php?tid=195104
(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
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__ )
import xbmc
import xbmcgui
import xbmcvfs
import xbmcaddon
import sys
import os
import shutil
def getPlatform():
if 'win32' in sys.platform:
p = 'win32'
print "Windows operating system detected"
elif 'linux' in sys.platform:
p = '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',):
p = 'ios'
else:
p = '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)
p = '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(skinpath, dest2)
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(skinpath, dest2)
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
(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:
p = 'win32'
print "Windows operating system detected"
elif 'linux' in sys.platform:
p = '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',):
p = 'ios'
else:
p = '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)
p = '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(skinpath, dest2)
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(skinpath, dest2)
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