reportlab/demos/stdfonts/stdfonts.py
author rgbecker
Tue, 15 Feb 2000 15:15:37 +0000
changeset 5 5e321293413b
child 7 ca9eb4f68eab
permissions -rw-r--r--
Initial revision
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
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    17
# documentation, and that the name of Robinson Analytics not be used
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 $
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    34
#	Revision 1.1  2000/02/15 15:15:57  rgbecker
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    35
#	Initial revision
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    36
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    37
__version__=''' $Id: stdfonts.py,v 1.1 2000/02/15 15:15:57 rgbecker Exp $ '''
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    38
# standardfonts.py
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    39
#
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    40
# shows the 14 standard fonts in our encoding
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    41
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    42
from pdfbase import pdfmetrics
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    43
from pdfgen import canvas
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    44
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    45
def run():
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    46
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    47
    canv = canvas.Canvas('standardfonts.pdf')
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    48
    canv.setPageCompression(0)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    49
    
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    50
    for fontname in pdfmetrics.StandardEnglishFonts:
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    51
        canv.setFont('Times-Bold', 18)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    52
        canv.drawString(80, 744, fontname)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    53
        
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    54
        #for dingbats, we need to use another font for the numbers.
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    55
        #do two parallel text objects.
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    56
        if fontname == 'ZapfDingbats':
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    57
            labelfont = 'Helvetica'
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    58
        else:
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    59
            labelfont = fontname
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    60
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    61
        for byt in range(32, 256):
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    62
            col, row = divmod(byt - 32, 32)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    63
            x = 72 + (66*col)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    64
            y = 720 - (18*row)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    65
            canv.setFont(labelfont, 14)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    66
            canv.drawString(x, y, '%d =' % byt)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    67
            canv.setFont(fontname, 14)
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    68
            canv.drawString(x + 44, y , chr(byt))
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    69
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    70
        canv.showPage()            
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    71
            
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    72
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    73
    canv.save()
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    74
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    75
if __name__ == '__main__':
5e321293413b Initial revision
rgbecker
parents:
diff changeset
    76
    run()