-
Notifications
You must be signed in to change notification settings - Fork 11
/
devede_fonts.py
executable file
·89 lines (77 loc) · 2.62 KB
/
devede_fonts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Copyright 2006-2009 (C) Raster Software Vigo (Sergio Costas)
# Copyright 2006-2007 (C) Peter Gill - win32 parts
# This file is part of DeVeDe
#
# DeVeDe is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# DeVeDe is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
import sys
def prepare_devede_font(home,font_path):
""" This function copies the default font for subtitles into $HOME/.spumux
It's made this way because Red Hat package mandates removing font files
from RPM files, so DeVeDe must search in several directories """
path_list=[font_path,"/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf","/usr/share/fonts/truetype/ttf-dejavu/dejavusans.ttf"]
#if our font for subtitles isn't installed, we install it
exists=True
try:
if (sys.platform!="win32") and (sys.platform!="win64"):
fichero=open(home+".spumux/devedesans.ttf")
fichero.close()
else: # get home
t=os.path.join(os.environ["WINDIR"], "Fonts", "devedesans.ttf")
fichero=open(t)
fichero.close()
return True
except:
exists=False
if exists:
return
if (sys.platform!="win32") and (sys.platform!="win64"):
try:
t=os.path.join(home,".spumux")
print "Creating spumux directory"+str(t)
os.mkdir(t)
except:
print "Already existed"
pass
for element in path_list:
print element
try:
if (sys.platform=="win32") or (sys.platform=="win64"):
print "win32"
t=os.path.join(os.environ["WINDIR"], "Fonts" )#=r'C:\WINDOWS\Fonts\\'
t2=os.path.join(t,"devedesans.ttf")
# spummux needs font in the windows font directory
print "\n\nFont Path: " , element
print "\n\nT: " , t
shutil.copyfile(element,t2)
else:
print "Hago"
t=os.path.join(home,".spumux")
t2=os.path.join(t,"devedesans.ttf")
print t2
shutil.copyfile(element,t2)
print "hecho"
#handle=subprocess.Popen("mkdir "+home+".spumux",bufsize=8192,shell=True)
#handle.wait()
#handle=subprocess.Popen("cp "+font_path+" "+home+".spumux/",bufsize=8192,shell=True)
#handle.wait()
print "retorno"
return True
except:
print "fallo"
pass
return False