Example #1
0
def _setFont(gs,fontName,fontSize):
    try:
        gs.setFont(fontName,fontSize)
    except _renderPM.Error, errMsg:
        if errMsg.args[0]!="Can't find font!": raise
        #here's where we try to add a font to the canvas
        try:
            f = getFont(fontName)
            if _renderPM._version<='0.98':  #added reader arg in 0.99
                _renderPM.makeT1Font(fontName,f.face.findT1File(),f.encoding.vector)
            else:
                _renderPM.makeT1Font(fontName,f.face.findT1File(),f.encoding.vector,open_and_read)
        except:
            s1, s2 = map(str,sys.exc_info()[:2])
            raise RenderPMError, "Can't setFont(%s) missing the T1 files?\nOriginally %s: %s" % (fontName,s1,s2)
        gs.setFont(fontName,fontSize)
Example #2
0
def _setFont(gs,fontName,fontSize):
    try:
        gs.setFont(fontName,fontSize)
    except _renderPM.Error, errMsg:
        if errMsg.args[0]!="Can't find font!": raise
        #here's where we try to add a font to the canvas
        try:
            f = getFont(fontName)
            if _renderPM._version<='0.98':  #added reader arg in 0.99
                _renderPM.makeT1Font(fontName,f.face.findT1File(),f.encoding.vector)
            else:
                _renderPM.makeT1Font(fontName,f.face.findT1File(),f.encoding.vector,open_and_read)
        except:
            s1, s2 = map(str,sys.exc_info()[:2])
            raise RenderPMError, "Can't setFont(%s) missing the T1 files?\nOriginally %s: %s" % (fontName,s1,s2)
        gs.setFont(fontName,fontSize)
Example #3
0
from reportlab.rl_config import T1SearchPath
T1SearchPath.insert(0,'C:\\Python\\PyArt\\pdffonts')
import _renderPM
from time import time
from reportlab.pdfbase.pdfmetrics import getFont
from reportlab.pdfbase._fontdata import standardFonts
g = _renderPM.gstate(200,200)
g.ctm = (1,0,0,1,0,0)

N=20
t0 = time()
for i in xrange(N):
	for k in standardFonts:
		f = getFont(k)
		print k, f.face.findT1File()
		_renderPM.makeT1Font(k,f.face.findT1File(),f.encoding.vector)

	_renderPM.delCache()
print 'Reading %d standard fonts %d times took %.2f seconds' % (len(standardFonts),N,time()-t0)
Example #4
0
from reportlab.rl_config import T1SearchPath
T1SearchPath.insert(0, 'C:\\Python\\PyArt\\pdffonts')
import _renderPM
from time import time
from reportlab.pdfbase.pdfmetrics import getFont
from reportlab.pdfbase._fontdata import standardFonts
g = _renderPM.gstate(200, 200)
g.ctm = (1, 0, 0, 1, 0, 0)

N = 20
t0 = time()
for i in range(N):
    for k in standardFonts:
        f = getFont(k)
        print k, f.face.findT1File()
        _renderPM.makeT1Font(k, f.face.findT1File(), f.encoding.vector)

    _renderPM.delCache()
print 'Reading %d standard fonts %d times took %.2f seconds' % (
    len(standardFonts), N, time() - t0)