Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(10)  |  Call(5)  |  Derive(0)  |  Import(5)
return a list of (font,string) pairs representing the unicode text

        def _py_unicode2T1(utext,fonts):
    '''return a list of (font,string) pairs representing the unicode text'''
    #print 'unicode2t1(%s, %s): %s' % (utext, fonts, type(utext))
    #if type(utext)
    R = []
    font, fonts = fonts[0], fonts[1:]
    enc = font.encName
    if 'UCS-2' in enc:
        enc = 'UTF16'
    while utext:
        try:
            R.append((font,utext.encode(enc)))
            break
        except UnicodeEncodeError, e:
            i0, il = e.args[2:4]
            if i0:
                R.append((font,utext[:i0].encode(enc)))
            if fonts:
                R.extend(_py_unicode2T1(utext[i0:il],fonts))
            else:
                R.append((_notdefFont,_notdefChar*(il-i0)))
            utext = utext[il:]
    return R
        


src/m/w/mwlib.ext-0.13.2/upstream-src/tests/test_rl_accel.py   mwlib.ext(Download)
    def test_unicode2T1(self):
        from reportlab.pdfbase.pdfmetrics import _py_unicode2T1, getFont, _fonts
        from _rl_accel import unicode2T1
        t1fn = 'Times-Roman'
        t1f = getFont(t1fn)
        def tfunc(f,ts):
            w1 = unicode2T1(ts,[f]+f.substitutionFonts)
            w2 = _py_unicode2T1(ts,[f]+f.substitutionFonts)
            assert w1==w2,"%r != %r" % (w1,w2)
        defns="t1fn t1f testCp1252 enc senc utext t1f.widths t1f.encName t1f.substitutionFonts _fonts"

src/r/e/ReportLab-HEAD/tests/test_rl_accel.py   ReportLab(Download)
    def test_unicode2T1(self):
        from reportlab.pdfbase.pdfmetrics import _py_unicode2T1, getFont, _fonts
        from _rl_accel import unicode2T1
        t1fn = 'Times-Roman'
        t1f = getFont(t1fn)
        def tfunc(f,ts):
            w1 = unicode2T1(ts,[f]+f.substitutionFonts)
            w2 = _py_unicode2T1(ts,[f]+f.substitutionFonts)
            assert w1==w2,"%r != %r" % (w1,w2)
        defns="t1fn t1f testCp1252 enc senc utext t1f.widths t1f.encName t1f.substitutionFonts _fonts"

src/m/w/mwlib.ext-0.13.2/upstream-src/src/rl_addons/rl_accel/tests/t0.py   mwlib.ext(Download)
import os, time, sys
from reportlab.pdfbase.pdfmetrics import _py_getFont, _py_unicode2T1
from _rl_accel import unicode2T1
from getrc import getrc, checkrc
utext = 'ABCDEF \xce\x91BCDEF\xce\x91'.decode('utf8')
 
font = _py_getFont(fontName)
assert unicode2T1(utext,[font]+font.substitutionFonts)==_py_unicode2T1(utext,[font]+font.substitutionFonts)
#print unicode2T1(u'ABCDEF',[font]+font.substitutionFonts)
#print _py_unicode2T1(u'ABCDEF',[font]+font.substitutionFonts)

src/r/e/reportlab-3.1.8/src/rl_addons/rl_accel/tests/t0.py   reportlab(Download)
import os, time, sys
from reportlab.pdfbase.pdfmetrics import _py_getFont, _py_unicode2T1
from _rl_accel import unicode2T1
from getrc import getrc, checkrc
utext = 'ABCDEF \xce\x91BCDEF\xce\x91'.decode('utf8')
 
font = _py_getFont(fontName)
assert unicode2T1(utext,[font]+font.substitutionFonts)==_py_unicode2T1(utext,[font]+font.substitutionFonts)
#print unicode2T1(u'ABCDEF',[font]+font.substitutionFonts)
#print _py_unicode2T1(u'ABCDEF',[font]+font.substitutionFonts)

src/r/e/ReportLab-HEAD/src/rl_addons/rl_accel/tests/t0.py   ReportLab(Download)
import os, time, sys
from reportlab.pdfbase.pdfmetrics import _py_getFont, _py_unicode2T1
from _rl_accel import unicode2T1
from getrc import getrc, checkrc
utext = 'ABCDEF \xce\x91BCDEF\xce\x91'.decode('utf8')
 
font = _py_getFont(fontName)
assert unicode2T1(utext,[font]+font.substitutionFonts)==_py_unicode2T1(utext,[font]+font.substitutionFonts)
#print unicode2T1(u'ABCDEF',[font]+font.substitutionFonts)
#print _py_unicode2T1(u'ABCDEF',[font]+font.substitutionFonts)