[PythonReports-checkins] PythonReports/PythonReports fonts.py, 1.3, 1.4
Brought to you by:
a1s
From: alexander s. <a1...@us...> - 2011-01-26 07:43:48
|
Update of /cvsroot/pythonreports/PythonReports/PythonReports In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv906 Modified Files: fonts.py Log Message: more well-known font file names; add Mac OS X font paths Index: fonts.py =================================================================== RCS file: /cvsroot/pythonreports/PythonReports/PythonReports/fonts.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fonts.py 22 Dec 2007 17:54:15 -0000 1.3 --- fonts.py 26 Jan 2011 07:43:39 -0000 1.4 *************** *** 1,4 **** --- 1,6 ---- """Fonts registry""" """History (most recent first): + 26-jan-2011 [als] more well-known font file names; + add Mac OS X font paths 22-dec-2007 [als] add Ubuntu fonts location to SYSFONTPATHS (sf bug 1856408) 27-sep-2006 [als] support different system font path variants *************** *** 11,27 **** __all__ = ["fontfile", "register"] ! import os ! ! # paths to look for TrueType fonts ! if os.name == "nt": ! # MS Windows ! SYSFONTPATHS = [os.path.join(os.getenv("windir"), "Fonts")] ! elif os.name == "posix": ! # X windows ! SYSFONTPATHS = [ ! "/usr/X11R6/lib/X11/fonts/TrueType", ! "/usr/share/fonts/corefonts", # Gentoo Linux (TM) ! "/usr/share/fonts/truetype/msttcorefonts", # Ubuntu (Feisty) ! ] # well-known font files --- 13,18 ---- __all__ = ["fontfile", "register"] ! from operator import itemgetter ! import os, sys # well-known font files *************** *** 35,46 **** --- 26,75 ---- ("Comic Sans MS", True, False): "comicbd.ttf", ("Comic Sans MS", True, True): "comicbd.ttf", + ("Consolas", False, False): "consola.ttf", + ("Consolas", False, True): "consolai.ttf", + ("Consolas", True, False): "consolab.ttf", + ("Consolas", True, True): "consolaz.ttf", ("Courier New", False, False): "cour.ttf", ("Courier New", False, True): "couri.ttf", ("Courier New", True, False): "courbd.ttf", ("Courier New", True, True): "courbi.ttf", + ("DejaVu Sans", False, False): "DejaVuSans.ttf", + ("DejaVu Sans", False, True): "DejaVuSans-Oblique.ttf", + ("DejaVu Sans", True, False): "DejaVuSans-Bold.ttf", + ("DejaVu Sans", True, True): "DejaVuSans-BoldOblique.ttf", + ("DejaVu Sans Condensed", False, False): "DejaVuSansCondensed.ttf", + ("DejaVu Sans Condensed", False, True): "DejaVuSansCondensed-Oblique.ttf", + ("DejaVu Sans Condensed", True, False): "DejaVuSansCondensed-Bold.ttf", + ("DejaVu Sans Condensed", True, True): + "DejaVuSansCondensed-BoldOblique.ttf", + ("DejaVu Sans Mono", False, False): "DejaVuSansMono.ttf", + ("DejaVu Sans Mono", False, True): "DejaVuSansMono-Oblique.ttf", + ("DejaVu Sans Mono", True, False): "DejaVuSansMono-Bold.ttf", + ("DejaVu Sans Mono", True, True): "DejaVuSansMono-BoldOblique.ttf", + ("DejaVu Serif", False, False): "DejaVuSerif.ttf", + ("DejaVu Serif", False, True): "DejaVuSerif-Italic.ttf", + ("DejaVu Serif", True, False): "DejaVuSerif-Bold.ttf", + ("DejaVu Serif", True, True): "DejaVuSerif-BoldItalic.ttf", + ("DejaVu Serif Condensed", False, False): "DejaVuSerifCondensed.ttf", + ("DejaVu Serif Condensed", False, True): "DejaVuSerifCondensed-Italic.ttf", + ("DejaVu Serif Condensed", True, False): "DejaVuSerifCondensed-Bold.ttf", + ("DejaVu Serif Condensed", True, True): + "DejaVuSerifCondensed-BoldItalic.ttf", + ("Tahoma", False, False): "tahoma.ttf", + ("Tahoma", False, True): "tahoma.ttf", + ("Tahoma", True, False): "tahomabd.ttf", + ("Tahoma", True, True): "tahomabd.ttf", ("Times New Roman", False, False): "times.ttf", ("Times New Roman", False, True): "timesi.ttf", ("Times New Roman", True, False): "timesbd.ttf", ("Times New Roman", True, True): "timesbi.ttf", + ("Trebuchet MS", False, False): "trebuc.ttf", + ("Trebuchet MS", False, True): "trebucit.ttf", + ("Trebuchet MS", True, False): "trebucbd.ttf", + ("Trebuchet MS", True, True): "trebucbi.ttf", + ("Verdana", False, False): "verdana.ttf", + ("Verdana", False, True): "verdanai.ttf", + ("Verdana", True, False): "verdanab.ttf", + ("Verdana", True, True): "verdanaz.ttf", # if the font is not known to us, use monospaced font # for high estimate of the text width *************** *** 48,51 **** --- 77,96 ---- } + # paths to look for TrueType fonts + SYSFONTPATHS = [] + if os.name == "nt": + # MS Windows + SYSFONTPATHS.append(os.path.join(os.getenv("windir"), "Fonts")) + elif os.name == "posix": + # X windows + SYSFONTPATHS.extend([ + "/usr/X11R6/lib/X11/fonts/TrueType", + "/usr/share/fonts/corefonts", # Gentoo Linux (TM) + "/usr/share/fonts/truetype/msttcorefonts", # Ubuntu (Feisty) + ]) + if sys.platform == "darwin": + SYSFONTPATHS.extend(map(itemgetter(0), os.walk("/Library/Fonts"))) + FONTS[None] = "Courier New.ttf" + def fontfile(typeface, bold=False, italic=False): """Return TTF file name for a font |