reportlab/pdfbase/pdfmetrics.py
author rgbecker
Wed, 25 Oct 2000 08:57:46 +0000
changeset 494 54257447cfe9
parent 474 5c5a9505fba1
child 502 3a9547186146
permissions -rwxr-xr-x
Changed to indirect copyright
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
494
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 474
diff changeset
     1
#copyright ReportLab Inc. 2000
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 474
diff changeset
     2
#see license.txt for license details
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 474
diff changeset
     3
#history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/pdfbase/pdfmetrics.py?cvsroot=reportlab
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 474
diff changeset
     4
#$Header: /tmp/reportlab/reportlab/pdfbase/pdfmetrics.py,v 1.14 2000/10/25 08:57:45 rgbecker Exp $
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 474
diff changeset
     5
__version__=''' $Id: pdfmetrics.py,v 1.14 2000/10/25 08:57:45 rgbecker Exp $ '''
16
f9c7525619fb Docstring & other fixes
rgbecker
parents: 7
diff changeset
     6
__doc__="""This contains pre-canned text metrics for the PDFgen package, and may also
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
     7
be used for any other PIDDLE back ends or packages which use the standard
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
     8
Type 1 postscript fonts.
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
     9
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    10
Its main function is to let you work out the width of strings; it exposes a 
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
    11
single function, stringWidth(text, fontName, fontSize), which works out the width of a 
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 16
diff changeset
    12
string in the given font in points.
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    13
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    14
The AFM loading stuff worked for me but is not being heavily tested, as pre-canning
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    15
the widths for the standard 14 fonts in Acrobat Reader is so much more useful. One
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    16
could easily extend it to get the exact bounding box for each characterm useful for 
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    17
kerning.
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    18
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    19
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    20
The ascent_descent attribute of the module is a dictionary mapping font names
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    21
(with the proper Postscript capitalisation) to ascents and descents.  I ought
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    22
to sort out the fontname case issue and the resolution of PIDDLE fonts to 
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    23
Postscript font names within this module, but have not yet done so.
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    24
"""
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    25
import string
462
b816adb0fd70 Begun work on loading new AFM files
andy_robinson
parents: 432
diff changeset
    26
import os
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
    27
from reportlab.lib.logger import warnOnce, infoOnce
305
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    28
DEFAULT_ENCODING='WinAnsiEncoding'
462
b816adb0fd70 Begun work on loading new AFM files
andy_robinson
parents: 432
diff changeset
    29
AFMDIR = 'C:\\code\\users\\andy\\fontembed'
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    30
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    31
StandardEnglishFonts = [
305
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    32
	'Courier', 'Courier-Bold', 'Courier-Oblique', 'Courier-BoldOblique',  
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    33
	'Helvetica', 'Helvetica-Bold', 'Helvetica-Oblique', 
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    34
	'Helvetica-BoldOblique',
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    35
	'Times-Roman', 'Times-Bold', 'Times-Italic', 'Times-BoldItalic',
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    36
	'Symbol','ZapfDingbats']
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    37
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    38
##############################################################
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    39
#
305
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    40
#			PDF Metrics
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    41
# This is a preamble to give us a stringWidth function.
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    42
# loads and caches AFM files, but won't need to as the
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    43
# standard fonts are there already
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    44
##############################################################
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    45
305
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    46
widths={
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    47
	'MacRomanEncoding': {
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    48
		'courier': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 0, 600, 0, 0, 600, 600, 0, 0, 0, 0, 0, 600, 600, 0, 600, 600, 600, 600, 600, 0, 600, 0, 0, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    49
		'courier-bold': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 0, 600, 0, 0, 600, 600, 0, 0, 0, 0, 0, 600, 600, 0, 600, 600, 600, 600, 600, 0, 600, 0, 0, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    50
		'courier-boldoblique': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 0, 600, 0, 0, 600, 600, 0, 0, 0, 0, 0, 600, 600, 0, 600, 600, 600, 600, 600, 0, 600, 0, 0, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    51
		'courier-oblique': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 0, 600, 0, 0, 600, 600, 0, 0, 0, 0, 0, 600, 600, 0, 600, 600, 600, 600, 600, 0, 600, 0, 0, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    52
		'helvetica': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 0, 667, 667, 722, 667, 722, 778, 722, 556, 556, 556, 556, 556, 556, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 400, 556, 556, 556, 350, 537, 611, 737, 737, 1000, 333, 333, 0, 1000, 778, 0, 584, 0, 0, 556, 556, 0, 0, 0, 0, 0, 370, 365, 0, 889, 611, 611, 333, 584, 0, 556, 0, 0, 556, 556, 1000, 0, 667, 667, 778, 1000, 944, 556, 1000, 333, 333, 222, 222, 584, 0, 500, 667, 167, 556, 333, 333, 500, 500, 556, 278, 222, 333, 1000, 667, 667, 667, 667, 667, 278, 278, 278, 278, 778, 778, 0, 778, 722, 722, 722, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 667],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    53
		'helvetica-bold': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 0, 722, 722, 722, 667, 722, 778, 722, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 611, 611, 611, 556, 400, 556, 556, 556, 350, 556, 611, 737, 737, 1000, 333, 333, 0, 1000, 778, 0, 584, 0, 0, 556, 611, 0, 0, 0, 0, 0, 370, 365, 0, 889, 611, 611, 333, 584, 0, 556, 0, 0, 556, 556, 1000, 0, 722, 722, 778, 1000, 944, 556, 1000, 500, 500, 278, 278, 584, 0, 556, 667, 167, 556, 333, 333, 611, 611, 556, 278, 278, 500, 1000, 722, 667, 722, 667, 667, 278, 278, 278, 278, 778, 778, 0, 778, 722, 722, 722, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 667],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    54
		'helvetica-boldoblique': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 0, 722, 722, 722, 667, 722, 778, 722, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 611, 611, 611, 556, 400, 556, 556, 556, 350, 556, 611, 737, 737, 1000, 333, 333, 0, 1000, 778, 0, 584, 0, 0, 556, 611, 0, 0, 0, 0, 0, 370, 365, 0, 889, 611, 611, 333, 584, 0, 556, 0, 0, 556, 556, 1000, 0, 722, 722, 778, 1000, 944, 556, 1000, 500, 500, 278, 278, 584, 0, 556, 667, 167, 556, 333, 333, 611, 611, 556, 278, 278, 500, 1000, 722, 667, 722, 667, 667, 278, 278, 278, 278, 778, 778, 0, 778, 722, 722, 722, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 667],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    55
		'helvetica-oblique': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 0, 667, 667, 722, 667, 722, 778, 722, 556, 556, 556, 556, 556, 556, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 400, 556, 556, 556, 350, 537, 611, 737, 737, 1000, 333, 333, 0, 1000, 778, 0, 584, 0, 0, 556, 556, 0, 0, 0, 0, 0, 370, 365, 0, 889, 611, 611, 333, 584, 0, 556, 0, 0, 556, 556, 1000, 0, 667, 667, 778, 1000, 944, 556, 1000, 333, 333, 222, 222, 584, 0, 500, 667, 167, 556, 333, 333, 500, 500, 556, 278, 222, 333, 1000, 667, 667, 667, 667, 667, 278, 278, 278, 278, 778, 778, 0, 778, 722, 722, 722, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 667],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    56
		'symbol': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 0, 500, 0, 833, 778, 0, 333, 333, 0, 549, 250, 0, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278, 549, 549, 549, 444, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 333, 0, 333, 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 480, 200, 480, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 400, 0, 0, 0, 460, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 549, 0, 0, 0, 576, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 713, 0, 500, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 549, 0, 0, 0, 167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 790],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    57
		'times-bold': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 555, 500, 500, 1000, 833, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 930, 722, 667, 722, 722, 667, 611, 778, 778, 389, 500, 778, 667, 944, 722, 778, 611, 778, 722, 556, 667, 722, 722, 1000, 722, 722, 667, 333, 278, 333, 581, 500, 333, 500, 556, 444, 556, 444, 333, 500, 556, 278, 333, 556, 278, 833, 556, 500, 556, 556, 444, 389, 333, 556, 500, 722, 500, 500, 444, 394, 220, 394, 520, 0, 722, 722, 722, 667, 722, 778, 722, 500, 500, 500, 500, 500, 500, 444, 444, 444, 444, 444, 278, 278, 278, 278, 556, 500, 500, 500, 500, 500, 556, 556, 556, 556, 500, 400, 500, 500, 500, 350, 540, 556, 747, 747, 1000, 333, 333, 0, 1000, 778, 0, 570, 0, 0, 500, 556, 0, 0, 0, 0, 0, 300, 330, 0, 722, 500, 500, 333, 570, 0, 500, 0, 0, 500, 500, 1000, 0, 722, 722, 778, 1000, 722, 500, 1000, 500, 500, 333, 333, 570, 0, 500, 722, 167, 500, 333, 333, 556, 556, 500, 250, 333, 500, 1000, 722, 667, 722, 667, 667, 389, 389, 389, 389, 778, 778, 0, 778, 722, 722, 722, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 611],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    58
		'times-bolditalic': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 389, 555, 500, 500, 833, 778, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 832, 667, 667, 667, 722, 667, 667, 722, 778, 389, 500, 667, 611, 889, 722, 722, 611, 722, 667, 556, 611, 722, 667, 889, 667, 611, 611, 333, 278, 333, 570, 500, 333, 500, 500, 444, 500, 444, 333, 500, 556, 278, 278, 500, 278, 778, 556, 500, 500, 500, 389, 389, 278, 556, 444, 667, 500, 444, 389, 348, 220, 348, 570, 0, 667, 667, 667, 667, 722, 722, 722, 500, 500, 500, 500, 500, 500, 444, 444, 444, 444, 444, 278, 278, 278, 278, 556, 500, 500, 500, 500, 500, 556, 556, 556, 556, 500, 400, 500, 500, 500, 350, 500, 500, 747, 747, 1000, 333, 333, 0, 944, 722, 0, 570, 0, 0, 500, 576, 0, 0, 0, 0, 0, 266, 300, 0, 722, 500, 500, 389, 606, 0, 500, 0, 0, 500, 500, 1000, 0, 667, 667, 722, 944, 722, 500, 1000, 500, 500, 333, 333, 570, 0, 444, 611, 167, 500, 333, 333, 556, 556, 500, 250, 333, 500, 1000, 667, 667, 667, 667, 667, 389, 389, 389, 389, 722, 722, 0, 722, 722, 722, 722, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 611],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    59
		'times-italic': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 420, 500, 500, 833, 778, 214, 333, 333, 500, 675, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 675, 675, 675, 500, 920, 611, 611, 667, 722, 611, 611, 722, 722, 333, 444, 667, 556, 833, 667, 722, 611, 722, 611, 500, 556, 722, 611, 833, 611, 556, 556, 389, 278, 389, 422, 500, 333, 500, 500, 444, 500, 444, 278, 500, 500, 278, 278, 444, 278, 722, 500, 500, 500, 500, 389, 389, 278, 500, 444, 667, 444, 444, 389, 400, 275, 400, 541, 0, 611, 611, 667, 611, 667, 722, 722, 500, 500, 500, 500, 500, 500, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 400, 500, 500, 500, 350, 523, 500, 760, 760, 980, 333, 333, 0, 889, 722, 0, 675, 0, 0, 500, 500, 0, 0, 0, 0, 0, 276, 310, 0, 667, 500, 500, 389, 675, 0, 500, 0, 0, 500, 500, 889, 0, 611, 611, 722, 944, 667, 500, 889, 556, 556, 333, 333, 675, 0, 444, 556, 167, 500, 333, 333, 500, 500, 500, 250, 333, 556, 1000, 611, 611, 611, 611, 611, 333, 333, 333, 333, 722, 722, 0, 722, 722, 722, 722, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 611],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    60
		'times-roman': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 408, 500, 500, 833, 778, 180, 333, 333, 500, 564, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278, 564, 564, 564, 444, 921, 722, 667, 667, 722, 611, 556, 722, 722, 333, 389, 722, 611, 889, 722, 722, 556, 722, 667, 556, 611, 722, 722, 944, 722, 722, 611, 333, 278, 333, 469, 500, 333, 444, 500, 444, 500, 444, 333, 500, 500, 278, 278, 500, 278, 778, 500, 500, 500, 500, 333, 389, 278, 500, 500, 722, 500, 500, 444, 480, 200, 480, 541, 0, 722, 722, 667, 611, 722, 722, 722, 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 400, 500, 500, 500, 350, 453, 500, 760, 760, 980, 333, 333, 0, 889, 722, 0, 564, 0, 0, 500, 500, 0, 0, 0, 0, 0, 276, 310, 0, 667, 500, 444, 333, 564, 0, 500, 0, 0, 500, 500, 1000, 0, 722, 722, 722, 889, 722, 500, 1000, 444, 444, 333, 333, 564, 0, 500, 722, 167, 500, 333, 333, 556, 556, 500, 250, 333, 444, 1000, 722, 611, 722, 611, 611, 333, 333, 333, 333, 722, 722, 0, 722, 722, 722, 722, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 556],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    61
		'zapfdingbats': [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,278,974,961,974,980,719,789,790,791,690,960,939,549,855,911,933,911,945,974,755,846,762,761,571,677,763,760,759,754,494,552,537,577,692,786,788,788,790,793,794,816,823,789,841,823,833,816,831,923,744,723,749,790,792,695,776,768,792,759,707,708,682,701,826,815,789,789,707,687,696,689,786,787,713,791,785,791,873,761,762,762,759,759,892,892,788,784,438,138,277,415,392,392,668,668,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,732,544,544,910,667,760,760,776,595,694,626,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,894,838,1016,458,748,924,748,918,927,928,928,834,873,828,924,924,917,930,931,463,883,836,836,867,867,696,696,874,0,874,760,946,771,865,771,888,967,888,831,873,927,970,234,0]
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    62
		},
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    63
	'WinAnsiEncoding': {
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    64
		'courier': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    65
		'courier-bold': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    66
		'courier-boldoblique': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    67
		'courier-oblique': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    68
		'helvetica': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 0, 0, 0, 222, 556, 333, 1000, 556, 556, 333, 1000, 667, 333, 1000, 0, 611, 0, 0, 222, 222, 333, 333, 350, 556, 1000, 333, 1000, 500, 333, 944, 0, 500, 667, 0, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 0, 737, 333, 400, 584, 333, 333, 333, 556, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 584, 611, 556, 556, 556, 556, 500, 556, 500],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    69
		'helvetica-bold': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 0, 0, 0, 278, 556, 500, 1000, 556, 556, 333, 1000, 667, 333, 1000, 0, 611, 0, 0, 278, 278, 500, 500, 350, 556, 1000, 333, 1000, 556, 333, 944, 0, 500, 667, 0, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 0, 737, 333, 400, 584, 333, 333, 333, 611, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 584, 611, 611, 611, 611, 611, 556, 611, 556],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    70
		'helvetica-boldoblique': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 0, 0, 0, 278, 556, 500, 1000, 556, 556, 333, 1000, 667, 333, 1000, 0, 611, 0, 0, 278, 278, 500, 500, 350, 556, 1000, 333, 1000, 556, 333, 944, 0, 500, 667, 0, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 0, 737, 333, 400, 584, 333, 333, 333, 611, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 584, 611, 611, 611, 611, 611, 556, 611, 556],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    71
		'helvetica-oblique': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 0, 0, 0, 222, 556, 333, 1000, 556, 556, 333, 1000, 667, 333, 1000, 0, 611, 0, 0, 222, 222, 333, 333, 350, 556, 1000, 333, 1000, 500, 333, 944, 0, 500, 667, 0, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 0, 737, 333, 400, 584, 333, 333, 333, 556, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 584, 611, 556, 556, 556, 556, 500, 556, 500],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    72
		'symbol': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 0, 500, 0, 833, 778, 0, 333, 333, 0, 549, 250, 0, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278, 549, 549, 549, 444, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 333, 0, 333, 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 480, 200, 480, 0, 0, 750, 0, 0, 500, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 460, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 713, 0, 0, 0, 400, 549, 0, 0, 0, 576, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 549, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 549, 0, 0, 0, 0, 0, 0, 0, 790],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    73
		'times-bold': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 555, 500, 500, 1000, 833, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 930, 722, 667, 722, 722, 667, 611, 778, 778, 389, 500, 778, 667, 944, 722, 778, 611, 778, 722, 556, 667, 722, 722, 1000, 722, 722, 667, 333, 278, 333, 581, 500, 333, 500, 556, 444, 556, 444, 333, 500, 556, 278, 333, 556, 278, 833, 556, 500, 556, 556, 444, 389, 333, 556, 500, 722, 500, 500, 444, 394, 220, 394, 520, 0, 0, 0, 333, 500, 500, 1000, 500, 500, 333, 1000, 556, 333, 1000, 0, 667, 0, 0, 333, 333, 500, 500, 350, 500, 1000, 333, 1000, 389, 333, 722, 0, 444, 722, 0, 333, 500, 500, 500, 500, 220, 500, 333, 747, 300, 500, 570, 0, 747, 333, 400, 570, 300, 300, 333, 556, 540, 250, 333, 300, 330, 500, 750, 750, 750, 500, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 389, 389, 389, 389, 722, 722, 778, 778, 778, 778, 778, 570, 778, 722, 722, 722, 722, 722, 611, 556, 500, 500, 500, 500, 500, 500, 722, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 556, 500, 500, 500, 500, 500, 570, 500, 556, 556, 556, 556, 500, 556, 500],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    74
		'times-bolditalic': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 389, 555, 500, 500, 833, 778, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 832, 667, 667, 667, 722, 667, 667, 722, 778, 389, 500, 667, 611, 889, 722, 722, 611, 722, 667, 556, 611, 722, 667, 889, 667, 611, 611, 333, 278, 333, 570, 500, 333, 500, 500, 444, 500, 444, 333, 500, 556, 278, 278, 500, 278, 778, 556, 500, 500, 500, 389, 389, 278, 556, 444, 667, 500, 444, 389, 348, 220, 348, 570, 0, 0, 0, 333, 500, 500, 1000, 500, 500, 333, 1000, 556, 333, 944, 0, 611, 0, 0, 333, 333, 500, 500, 350, 500, 1000, 333, 1000, 389, 333, 722, 0, 389, 611, 0, 389, 500, 500, 500, 500, 220, 500, 333, 747, 266, 500, 606, 0, 747, 333, 400, 570, 300, 300, 333, 576, 500, 250, 333, 300, 300, 500, 750, 750, 750, 500, 667, 667, 667, 667, 667, 667, 944, 667, 667, 667, 667, 667, 389, 389, 389, 389, 722, 722, 722, 722, 722, 722, 722, 570, 722, 722, 722, 722, 722, 611, 611, 500, 500, 500, 500, 500, 500, 500, 722, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 556, 500, 500, 500, 500, 500, 570, 500, 556, 556, 556, 556, 444, 500, 444],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    75
		'times-italic': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 420, 500, 500, 833, 778, 214, 333, 333, 500, 675, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 675, 675, 675, 500, 920, 611, 611, 667, 722, 611, 611, 722, 722, 333, 444, 667, 556, 833, 667, 722, 611, 722, 611, 500, 556, 722, 611, 833, 611, 556, 556, 389, 278, 389, 422, 500, 333, 500, 500, 444, 500, 444, 278, 500, 500, 278, 278, 444, 278, 722, 500, 500, 500, 500, 389, 389, 278, 500, 444, 667, 444, 444, 389, 400, 275, 400, 541, 0, 0, 0, 333, 500, 556, 889, 500, 500, 333, 1000, 500, 333, 944, 0, 556, 0, 0, 333, 333, 556, 556, 350, 500, 889, 333, 980, 389, 333, 667, 0, 389, 556, 0, 389, 500, 500, 500, 500, 275, 500, 333, 760, 276, 500, 675, 0, 760, 333, 400, 675, 300, 300, 333, 500, 523, 250, 333, 300, 310, 500, 750, 750, 750, 500, 611, 611, 611, 611, 611, 611, 889, 667, 611, 611, 611, 611, 333, 333, 333, 333, 722, 667, 722, 722, 722, 722, 722, 675, 722, 722, 722, 722, 722, 556, 611, 500, 500, 500, 500, 500, 500, 500, 667, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500, 500, 500, 675, 500, 500, 500, 500, 500, 444, 500, 444],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    76
		'times-roman': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 408, 500, 500, 833, 778, 180, 333, 333, 500, 564, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278, 564, 564, 564, 444, 921, 722, 667, 667, 722, 611, 556, 722, 722, 333, 389, 722, 611, 889, 722, 722, 556, 722, 667, 556, 611, 722, 722, 944, 722, 722, 611, 333, 278, 333, 469, 500, 333, 444, 500, 444, 500, 444, 333, 500, 500, 278, 278, 500, 278, 778, 500, 500, 500, 500, 333, 389, 278, 500, 500, 722, 500, 500, 444, 480, 200, 480, 541, 0, 0, 0, 333, 500, 444, 1000, 500, 500, 333, 1000, 556, 333, 889, 0, 611, 0, 0, 333, 333, 444, 444, 350, 500, 1000, 333, 980, 389, 333, 722, 0, 444, 722, 0, 333, 500, 500, 500, 500, 200, 500, 333, 760, 276, 500, 564, 0, 760, 333, 400, 564, 300, 300, 333, 500, 453, 250, 333, 300, 310, 500, 750, 750, 750, 444, 722, 722, 722, 722, 722, 722, 889, 667, 611, 611, 611, 611, 333, 333, 333, 333, 722, 722, 722, 722, 722, 722, 722, 564, 722, 722, 722, 722, 722, 722, 556, 500, 444, 444, 444, 444, 444, 444, 667, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500, 500, 500, 564, 500, 500, 500, 500, 500, 500, 500, 500],
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    77
		'zapfdingbats': [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,278,974,961,974,980,719,789,790,791,690,960,939,549,855,911,933,911,945,974,755,846,762,761,571,677,763,760,759,754,494,552,537,577,692,786,788,788,790,793,794,816,823,789,841,823,833,816,831,923,744,723,749,790,792,695,776,768,792,759,707,708,682,701,826,815,789,789,707,687,696,689,786,787,713,791,785,791,873,761,762,762,759,759,892,892,788,784,438,138,277,415,392,392,668,668,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,732,544,544,910,667,760,760,776,595,694,626,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,894,838,1016,458,748,924,748,918,927,928,928,834,873,828,924,924,917,930,931,463,883,836,836,867,867,696,696,874,0,874,760,946,771,865,771,888,967,888,831,873,927,970,234,0]
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    78
		}
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
    79
	}
402
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
    80
ascent_descent = {'courier': (629, -157), 'courier-bold': (626, -142), 'courier-boldoblique': (626, -142), 'courier-oblique': (629, -157), 'helvetica': (718, -207), 'helvetica-bold': (718, -207), 'helvetica-boldoblique': (718, -207), 'helvetica-oblique': (718, -207), 'symbol': (0, 0), 'times-bold': (676, -205), 'times-bolditalic': (699, -205), 'times-italic': (683, -205), 'times-roman': (683, -217), 'zapfdingbats': (0, 0)}
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
    81
try:
474
5c5a9505fba1 Changes to make freezing easier
rgbecker
parents: 463
diff changeset
    82
	try:
5c5a9505fba1 Changes to make freezing easier
rgbecker
parents: 463
diff changeset
    83
		from reportlab.lib import _rl_accel		# works if we built it
5c5a9505fba1 Changes to make freezing easier
rgbecker
parents: 463
diff changeset
    84
	except ImportError:
5c5a9505fba1 Changes to make freezing easier
rgbecker
parents: 463
diff changeset
    85
		import _rl_accel						# works if builtin or on the path?
432
53237922b3e7 Start using _rl_accel
rgbecker
parents: 414
diff changeset
    86
	_stringWidth = _rl_accel.stringWidth
402
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
    87
except ImportError:
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
    88
	_stringWidth = None
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    89
463
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
    90
	####################################################################################
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
    91
	#
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
    92
	#  Everything below here is concerned with parsing AFM files and adding metrics
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
    93
	#  for new fonts at runtime.
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
    94
	#
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
    95
	####################################################################################
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
    96
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
    97
WinAnsiNames = [None, None, None, None, None, None, None, None, None, None, None, None,
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
    98
				None, None, None, None, None, None, None, None, None, None, None, None,
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
    99
				None, None, None, None, None, None, None, None, 'space', 'exclam',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   100
				'quotedbl', 'numbersign', 'dollar', 'percent', 'ampersand',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   101
				'quotesingle', 'parenleft', 'parenright', 'asterisk', 'plus', 'comma',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   102
				'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   103
				'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   104
				'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   105
				'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   106
				'U', 'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   107
				'asciicircum', 'underscore', 'grave', 'a', 'b', 'c', 'd', 'e', 'f',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   108
				'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   109
				'u', 'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   110
				'asciitilde', 'bullet', 'Euro', 'bullet', 'quotesinglbase', 'florin',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   111
				'quotedblbase', 'ellipsis', 'dagger', 'daggerdbl', 'circumflex',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   112
				'perthousand', 'Scaron', 'guilsinglleft', 'OE', 'bullet', 'Zcaron',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   113
				'bullet', 'bullet', 'quoteleft', 'quoteright', 'quotedblleft',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   114
				'quotedblright', 'bullet', 'endash', 'emdash', 'tilde', 'trademark',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   115
				'scaron', 'guilsinglright', 'oe', 'bullet', 'zcaron', 'Ydieresis',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   116
				'space', 'exclamdown', 'cent', 'sterling', 'currency', 'yen', 'brokenbar',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   117
				'section', 'dieresis', 'copyright', 'ordfeminine', 'guillemotleft',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   118
				'logicalnot', 'hyphen', 'registered', 'macron', 'degree', 'plusminus',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   119
				'twosuperior', 'threesuperior', 'acute', 'mu', 'paragraph', 'periodcentered',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   120
				'cedilla', 'onesuperior', 'ordmasculine', 'guillemotright', 'onequarter',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   121
				'onehalf', 'threequarters', 'questiondown', 'Agrave', 'Aacute',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   122
				'Acircumflex', 'Atilde', 'Adieresis', 'Aring', 'AE', 'Ccedilla',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   123
				'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis', 'Igrave', 'Iacute',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   124
				'Icircumflex', 'Idieresis', 'Eth', 'Ntilde', 'Ograve', 'Oacute',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   125
				'Ocircumflex', 'Otilde', 'Odieresis', 'multiply', 'Oslash', 'Ugrave',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   126
				'Uacute', 'Ucircumflex', 'Udieresis', 'Yacute', 'Thorn', 'germandbls',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   127
				'agrave', 'aacute', 'acircumflex', 'atilde', 'adieresis', 'aring', 'ae',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   128
				'ccedilla', 'egrave', 'eacute', 'ecircumflex', 'edieresis', 'igrave',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   129
				'iacute', 'icircumflex', 'idieresis', 'eth', 'ntilde', 'ograve', 'oacute',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   130
				'ocircumflex', 'otilde', 'odieresis', 'divide', 'oslash', 'ugrave', 'uacute',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   131
				'ucircumflex', 'udieresis', 'yacute', 'thorn', 'ydieresis']
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   132
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   133
MacRomanNames = [None, None, None, None, None, None, None, None, None, None, None, None,
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   134
				 None, None, None, None, None, None, None, None, None, None, None, None,
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   135
				 None, None, None, None, None, None, None, None, 'space', 'exclam',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   136
				 'quotedbl', 'numbersign', 'dollar', 'percent', 'ampersand',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   137
				 'quotesingle', 'parenleft', 'parenright', 'asterisk', 'plus', 'comma',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   138
				 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   139
				 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   140
				 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   141
				 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   142
				 'U', 'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   143
				 'asciicircum', 'underscore', 'grave', 'a', 'b', 'c', 'd', 'e', 'f',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   144
				 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   145
				 'u', 'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   146
				 'asciitilde', None, 'Adieresis', 'Aring', 'Ccedilla', 'Eacute',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   147
				 'Ntilde', 'Odieresis', 'Udieresis', 'aacute', 'agrave', 'acircumflex',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   148
				 'adieresis', 'atilde', 'aring', 'ccedilla', 'eacute', 'egrave',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   149
				 'ecircumflex', 'edieresis', 'iacute', 'igrave', 'icircumflex',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   150
				 'idieresis', 'ntilde', 'oacute', 'ograve', 'ocircumflex', 'odieresis',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   151
				 'otilde', 'uacute', 'ugrave', 'ucircumflex', 'udieresis', 'dagger',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   152
				 'degree', 'cent', 'sterling', 'section', 'bullet', 'paragraph',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   153
				 'germandbls', 'registered', 'copyright', 'trademark', 'acute',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   154
				 'dieresis', None, 'AE', 'Oslash', None, 'plusminus', None, None, 'yen',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   155
				 'mu', None, None, None, None, None, 'ordfeminine', 'ordmasculine', None,
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   156
				 'ae', 'oslash', 'questiondown', 'exclamdown', 'logicalnot', None, 'florin',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   157
				 None, None, 'guillemotleft', 'guillemotright', 'ellipsis', 'space', 'Agrave',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   158
				 'Atilde', 'Otilde', 'OE', 'oe', 'endash', 'emdash', 'quotedblleft',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   159
				 'quotedblright', 'quoteleft', 'quoteright', 'divide', None, 'ydieresis',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   160
				 'Ydieresis', 'fraction', 'currency', 'guilsinglleft', 'guilsinglright',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   161
				 'fi', 'fl', 'daggerdbl', 'periodcentered', 'quotesinglbase',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   162
				 'quotedblbase', 'perthousand', 'Acircumflex', 'Ecircumflex', 'Aacute',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   163
				 'Edieresis', 'Egrave', 'Iacute', 'Icircumflex', 'Idieresis', 'Igrave',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   164
				 'Oacute', 'Ocircumflex', None, 'Ograve', 'Uacute', 'Ucircumflex',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   165
				 'Ugrave', 'dotlessi', 'circumflex', 'tilde', 'macron', 'breve',
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   166
				 'dotaccent', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron']
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   167
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   168
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   169
class FontMetrics:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   170
	"""This is an object which parses AFM files and holds all the
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   171
	data they contain."""
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   172
	def __init__(self, afmFileName):
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   173
		self.fontName = None
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   174
		self.widthsByPosition = []
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   175
		self.parseAFMFile(afmFileName)
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   176
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   177
	def parseAFMFile(self, filename):
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   178
		"""Returns an array holding the widths of all characters in the font.
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   179
		Ultra-crude parser"""
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   180
		alllines = open(filename, 'r').readlines()
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   181
		# get stuff between StartCharMetrics and EndCharMetrics
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   182
		metriclines = []
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   183
		between = 0
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   184
		for line in alllines:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   185
			lline = string.lower(line)
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   186
			i = string.find(lline,'fontName')
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   187
			if i>=0:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   188
				fontName = string.strip(line[i+9:])
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   189
				self.fontName = fontName
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   190
			if string.find(lline, 'endcharmetrics') > -1:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   191
				between = 0
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   192
				break
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   193
			if between:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   194
				metriclines.append(line)
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   195
			if string.find(lline, 'startcharmetrics') > -1:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   196
				between = 1
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   197
				
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   198
		# break up - very shaky assumption about array size
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   199
		widths = [0] * 256
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   200
		widthsByName = {}
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   201
		for line in metriclines:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   202
			chunks = string.split(line, ';')
305
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
   203
			
463
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   204
			(c, cid) = string.split(chunks[0])
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   205
			(wx, width) = string.split(chunks[1])
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   206
			(n, name) = string.split(chunks[2])
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   207
			#(b, x1, y1, x2, y2) = string.split(chunks[3])
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   208
			widths[string.atoi(cid)] = string.atoi(width)
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   209
			widthsByName[name] = string.atoi(width)
305
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
   210
		
463
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   211
		# by default, any empties should get the width of a space
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   212
		for i in range(len(widths)):
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   213
			if widths[i] == 0:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   214
				widths[i] == widths[32]
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   215
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   216
		self.widthsByPosition = widths
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   217
		self.widthsByName = widthsByName
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   218
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   219
	def getWinAnsiWidths(self):
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   220
		#derive a WinAnsi encoding vector
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   221
		winAnsiWidths = [0] * 256
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   222
		for i in range(255):
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   223
			name = WinAnsiNames[i]
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   224
			try:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   225
				width = self.widthsByName[name]
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   226
			except:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   227
				width = 0
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   228
			winAnsiWidths[i] = width
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   229
		return winAnsiWidths
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   230
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   231
	def getMacRomanWidths(self):
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   232
		#derive a MacRoman encoding vector
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   233
		MacRomanWidths = [0] * 256
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   234
		for i in range(255):
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   235
			name = MacRomanNames[i]
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   236
			try:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   237
				width = self.widthsByName[name]
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   238
			except:
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   239
				width = 0
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   240
			MacRomanWidths[i] = width
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   241
		return MacRomanWidths
305
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
   242
	
463
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   243
		
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   244
		
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   245
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   246
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   247
if _stringWidth:
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   248
	for e, F in widths.items():
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   249
		for f, W in  F.items():
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   250
			ad = ascent_descent[f]
432
53237922b3e7 Start using _rl_accel
rgbecker
parents: 414
diff changeset
   251
			_rl_accel.setFontInfo(f,e,ad[0],ad[1],W)
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   252
463
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   253
	def _loadfont(fontName, filename):
462
b816adb0fd70 Begun work on loading new AFM files
andy_robinson
parents: 432
diff changeset
   254
		infoOnce('cache loading %s' % filename)
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   255
		assert os.path.exists(filename)
463
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   256
##		W = parseAFMfile(filename)
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   257
##		ad = (0,0)	# TODO don't have this yet?
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   258
##		_rl_accel.setFontInfo(fontName,encoding,ad[0],ad[1],W)
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   259
		fm = FontMetrics(filename)
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   260
		_rl_accel.setFontInfo(string.lower(fontName), 'WinAnsiEncoding', ad[0], ad[1], fm.getWinAnsiWidths())
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   261
		_rl_accel.setFontInfo(string.lower(fontName), 'MacRomanEncoding', ad[0], ad[1], fm.getMacRomanWidths())
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   262
		
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   263
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   264
	def _SWRecover(text, font, fontSize, encoding):
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   265
		#infoOnce('_SWRecover('...',%s,%s,%s')%(font,str(fontSize),encoding))
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   266
		try:
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   267
			_loadFont(font,encoding)
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   268
			return _stringWidth(text,font,fontSize,encoding)
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   269
		except:
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   270
			warnOnce('Font %s:%s not found - using Courier:%s for widths'%(font,encoding,encoding))
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   271
			return _stringWidth(text,'courier',fontSize,encoding)
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   272
432
53237922b3e7 Start using _rl_accel
rgbecker
parents: 414
diff changeset
   273
	_rl_accel.defaultEncoding(DEFAULT_ENCODING)
53237922b3e7 Start using _rl_accel
rgbecker
parents: 414
diff changeset
   274
	_rl_accel._SWRecover(_SWRecover)
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   275
	stringWidth = _stringWidth
462
b816adb0fd70 Begun work on loading new AFM files
andy_robinson
parents: 432
diff changeset
   276
	loadFont = _loadfont
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   277
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   278
else:
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   279
	class FontCache:
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   280
		"""Loads and caches font width information on demand.  Font names
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   281
		converted to lower case for indexing.  Public interface is stringWidth"""
402
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
   282
		def __init__(self):
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
   283
			global widths
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
   284
			self.__widtharrays = widths
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   285
			
463
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   286
		def loadFont(self, fontName, filename):
462
b816adb0fd70 Begun work on loading new AFM files
andy_robinson
parents: 432
diff changeset
   287
			infoOnce('Info: cache loading%s' % filename)
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   288
			assert os.path.exists(filename)
463
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   289
			fm = FontMetrics(filename)
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   290
			self.__widtharrays['WinAnsiEncoding'][string.lower(fontName)] = fm.getWinAnsiWidths()
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   291
			self.__widtharrays['MacRomanEncoding'][string.lower(fontName)] = fm.getMacRomanWidths()
0a1cea1a306c more work on metrics and encodings for custom fonts
andy_robinson
parents: 462
diff changeset
   292
			
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   293
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   294
		def getfont(self, fontName, encoding):
305
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
   295
			try:
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   296
				return self.__widtharrays[encoding][fontName]
305
f93b4c94a91e Simple fix to widths problem
rgbecker
parents: 117
diff changeset
   297
			except:
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   298
				try:
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   299
					self.loadfont(fontName,encoding)
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   300
					return self.__widtharrays[encoding][fontName]
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   301
				except:
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   302
					# font not found, use Courier
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   303
					warnOnce('Font %s:%s not found - using Courier:%s for widths'%(fontName,encoding,encoding))
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   304
					return self.getfont('courier',encoding)
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   305
		
402
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
   306
		def stringWidth(self, text, font, fontSize, encoding=DEFAULT_ENCODING):
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
   307
			widths = self.getfont(string.lower(font),encoding)
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
   308
			w = 0
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
   309
			for char in text:
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
   310
				w = w + widths[ord(char)]
634cf8de261d Added _pdfmetrics.c
rgbecker
parents: 305
diff changeset
   311
			return w*fontSize*0.001
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   312
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   313
		def status(self):
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   314
			#returns loaded fonts
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   315
			return self.__widtharrays.keys()
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   316
			
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   317
	TheFontCache = FontCache()
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   318
408
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   319
	#expose the singleton as a single function
9aaee62afc31 Accelerator rearrangements
rgbecker
parents: 402
diff changeset
   320
	stringWidth = TheFontCache.stringWidth
462
b816adb0fd70 Begun work on loading new AFM files
andy_robinson
parents: 432
diff changeset
   321
	loadFont = TheFontCache.loadFont