File: 01_fonts.diff

package info (click to toggle)
python-gd 0.56%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 288 kB
  • sloc: ansic: 3,314; python: 278; makefile: 34
file content (41 lines) | stat: -rw-r--r-- 877 bytes parent folder | download
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
Description: Fix copyright font problem.
Forwarded: no
Author: Julián Moreno Patiño <darkjunix@gmail.com>
Last-Update: 2011-02-15
--- a/gddemo.py
+++ b/gddemo.py
@@ -2,9 +2,26 @@
 
 import gd, os, cStringIO, urllib2
 
-os.environ["GDFONTPATH"] = "."
-
-FONT = "adventure"
+fontlist = [
+    '/usr/share/fonts/truetype/freefont/FreeSerif.ttf',
+    '/usr/share/fonts/truetype/freefont/FreeSans.ttf',
+    '/usr/share/fonts/truetype/freefont/FreeMono.ttf'
+    ]
+
+fontpath = '.'
+for f in fontlist:
+    if os.path.exists(f):
+        fontpath = fontpath + ':' + os.path.dirname(f)
+        FONT = os.path.abspath(f)
+        break
+
+os.environ["GDFONTPATH"] = "fontpath"
+
+try:
+    FONT
+except NameError:
+    print "no fonts found"
+    sys.exit(1)
 
 def simple():
     im = gd.image((200, 200))
@@ -44,4 +61,3 @@
     print "GNU Image Size:", im.size()
 
 simple()
-