reportlab/demos/stdfonts/stdfonts.py
author rgbecker
Thu, 17 Feb 2000 02:09:05 +0000
changeset 16 f9c7525619fb
parent 10 0cb88428a663
child 181 62d7a443cbc4
permissions -rw-r--r--
Docstring & other fixes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
5e321293413b Initial revision
rgbecker
parents:
diff changeset
     1
###############################################################################
5e321293413b Initial revision
rgbecker
parents:
diff changeset
     2
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
     3
#	ReportLab Public License Version 1.0
5e321293413b Initial revision
rgbecker
parents:
diff changeset
     4
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
     5
#   Except for the change of names the spirit and intention of this
5e321293413b Initial revision
rgbecker
parents:
diff changeset
     6
#   license is the same as that of Python
5e321293413b Initial revision
rgbecker
parents:
diff changeset
     7
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
     8
#	(C) Copyright ReportLab Inc. 1998-2000.
5e321293413b Initial revision
rgbecker
parents:
diff changeset
     9
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    10
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    11
# All Rights Reserved
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    12
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    13
# Permission to use, copy, modify, and distribute this software and its
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    14
# documentation for any purpose and without fee is hereby granted, provided
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    15
# that the above copyright notice appear in all copies and that both that
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    16
# copyright notice and this permission notice appear in supporting
7
ca9eb4f68eab License text fixes
rgbecker
parents: 5
diff changeset
    17
# documentation, and that the name of ReportLab not be used
5
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    18
# in advertising or publicity pertaining to distribution of the software
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    19
# without specific, written prior permission. 
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    20
# 
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    21
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    22
# Disclaimer
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    23
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    24
# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    25
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    26
# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    27
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    28
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    29
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    30
# PERFORMANCE OF THIS SOFTWARE. 
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    31
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    32
###############################################################################
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    33
#	$Log: stdfonts.py,v $
16
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    34
#	Revision 1.4  2000/02/17 02:06:28  rgbecker
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    35
#	Docstring & other fixes
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    36
#
10
0cb88428a663 Conversion to reportlab package
rgbecker
parents: 7
diff changeset
    37
#	Revision 1.3  2000/02/16 09:42:50  rgbecker
0cb88428a663 Conversion to reportlab package
rgbecker
parents: 7
diff changeset
    38
#	Conversion to reportlab package
16
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    39
#	
7
ca9eb4f68eab License text fixes
rgbecker
parents: 5
diff changeset
    40
#	Revision 1.2  2000/02/15 17:55:59  rgbecker
ca9eb4f68eab License text fixes
rgbecker
parents: 5
diff changeset
    41
#	License text fixes
10
0cb88428a663 Conversion to reportlab package
rgbecker
parents: 7
diff changeset
    42
#	
7
ca9eb4f68eab License text fixes
rgbecker
parents: 5
diff changeset
    43
#	Revision 1.1.1.1  2000/02/15 15:15:57  rgbecker
ca9eb4f68eab License text fixes
rgbecker
parents: 5
diff changeset
    44
#	Initial setup of demos directory and contents.
ca9eb4f68eab License text fixes
rgbecker
parents: 5
diff changeset
    45
#	
16
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    46
__version__=''' $Id: stdfonts.py,v 1.4 2000/02/17 02:06:28 rgbecker Exp $ '''
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    47
__doc__="""
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    48
standardfonts.py
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    49
shows the 14 standard fonts in our encoding
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    50
"""
5
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    51
10
0cb88428a663 Conversion to reportlab package
rgbecker
parents: 7
diff changeset
    52
from reportlab.pdfbase import pdfmetrics
0cb88428a663 Conversion to reportlab package
rgbecker
parents: 7
diff changeset
    53
from reportlab.pdfgen import canvas
5
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    54
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    55
def run():
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    56
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    57
    canv = canvas.Canvas('standardfonts.pdf')
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    58
    canv.setPageCompression(0)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    59
    
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    60
    for fontname in pdfmetrics.StandardEnglishFonts:
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    61
        canv.setFont('Times-Bold', 18)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    62
        canv.drawString(80, 744, fontname)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    63
        
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    64
        #for dingbats, we need to use another font for the numbers.
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    65
        #do two parallel text objects.
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    66
        if fontname == 'ZapfDingbats':
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    67
            labelfont = 'Helvetica'
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    68
        else:
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    69
            labelfont = fontname
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    70
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    71
        for byt in range(32, 256):
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    72
            col, row = divmod(byt - 32, 32)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    73
            x = 72 + (66*col)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    74
            y = 720 - (18*row)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    75
            canv.setFont(labelfont, 14)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    76
            canv.drawString(x, y, '%d =' % byt)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    77
            canv.setFont(fontname, 14)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    78
            canv.drawString(x + 44, y , chr(byt))
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    79
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    80
        canv.showPage()            
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    81
            
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    82
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    83
    canv.save()
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    84
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    85
if __name__ == '__main__':
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    86
    run()