3 |
3 |
4 This test uses a sample font (Vera.ttf) taken from Bitstream which is called Vera |
4 This test uses a sample font (Vera.ttf) taken from Bitstream which is called Vera |
5 Serif Regular and is covered under the license in ../fonts/bitstream-vera-license.txt. |
5 Serif Regular and is covered under the license in ../fonts/bitstream-vera-license.txt. |
6 """ |
6 """ |
7 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation, NearTestCase |
7 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation, NearTestCase |
8 setOutDir(__name__) |
8 if __name__=='__main__': |
9 from io import StringIO |
9 setOutDir(__name__) |
10 import unittest |
10 import unittest |
11 from reportlab.pdfgen.canvas import Canvas |
11 from reportlab.pdfgen.canvas import Canvas |
12 from reportlab.pdfbase import pdfmetrics |
12 from reportlab.pdfbase import pdfmetrics |
13 from reportlab.pdfbase.pdfdoc import PDFDocument, PDFError |
13 from reportlab.pdfbase.pdfdoc import PDFDocument, PDFError |
14 from reportlab.pdfbase.ttfonts import TTFont, TTFontFace, TTFontFile, TTFOpenFile, \ |
14 from reportlab.pdfbase.ttfonts import TTFont, TTFontFace, TTFontFile, TTFOpenFile, \ |
15 TTFontParser, TTFontMaker, TTFError, \ |
15 TTFontParser, TTFontMaker, TTFError, \ |
16 parse_utf8, makeToUnicodeCMap, \ |
16 makeToUnicodeCMap, \ |
17 FF_SYMBOLIC, FF_NONSYMBOLIC, \ |
17 FF_SYMBOLIC, FF_NONSYMBOLIC, \ |
18 calcChecksum, add32 |
18 calcChecksum, add32 |
19 from reportlab import rl_config |
19 from reportlab import rl_config |
|
20 from reportlab.lib.utils import getBytesIO, isPy3, UniChr, int2Byte |
20 |
21 |
21 def utf8(code): |
22 def utf8(code): |
22 "Convert a given UCS character index into UTF-8" |
23 "Convert a given UCS character index into UTF-8" |
23 if code < 0 or code > 0x7FFFFFFF: |
24 return UniChr(code).encode('utf8') |
24 raise ValueError('Invalid UCS character 0x%x' % code) |
|
25 elif code < 0x00000080: |
|
26 return chr(code) |
|
27 elif code < 0x00000800: |
|
28 return '%c%c' % \ |
|
29 (0xC0 + (code >> 6), |
|
30 0x80 + (code & 0x3F)) |
|
31 elif code < 0x00010000: |
|
32 return '%c%c%c' % \ |
|
33 (0xE0 + (code >> 12), |
|
34 0x80 + ((code >> 6) & 0x3F), |
|
35 0x80 + (code & 0x3F)) |
|
36 elif code < 0x00200000: |
|
37 return '%c%c%c%c' % \ |
|
38 (0xF0 + (code >> 18), |
|
39 0x80 + ((code >> 12) & 0x3F), |
|
40 0x80 + ((code >> 6) & 0x3F), |
|
41 0x80 + (code & 0x3F)) |
|
42 elif code < 0x04000000: |
|
43 return '%c%c%c%c%c' % \ |
|
44 (0xF8 + (code >> 24), |
|
45 0x80 + ((code >> 18) & 0x3F), |
|
46 0x80 + ((code >> 12) & 0x3F), |
|
47 0x80 + ((code >> 6) & 0x3F), |
|
48 0x80 + (code & 0x3F)) |
|
49 else: |
|
50 return '%c%c%c%c%c%c' % \ |
|
51 (0xFC + (code >> 30), |
|
52 0x80 + ((code >> 24) & 0x3F), |
|
53 0x80 + ((code >> 18) & 0x3F), |
|
54 0x80 + ((code >> 12) & 0x3F), |
|
55 0x80 + ((code >> 6) & 0x3F), |
|
56 0x80 + (code & 0x3F)) |
|
57 |
25 |
58 def _simple_subset_generation(fn,npages,alter=0): |
26 def _simple_subset_generation(fn,npages,alter=0): |
59 c = Canvas(outputfile(fn)) |
27 c = Canvas(outputfile(fn)) |
60 c.setFont('Helvetica', 30) |
28 c.setFont('Helvetica', 30) |
61 c.drawString(100,700, 'Unicode TrueType Font Test %d pages' % npages) |
29 c.drawString(100,700, 'Unicode TrueType Font Test %d pages' % npages) |
83 |
51 |
84 # Do it twice with the same font object |
52 # Do it twice with the same font object |
85 c = Canvas(outputfile('test_pdfbase_ttfontsadditional.pdf')) |
53 c = Canvas(outputfile('test_pdfbase_ttfontsadditional.pdf')) |
86 # Draw a table of Unicode characters |
54 # Draw a table of Unicode characters |
87 c.setFont('Vera', 10) |
55 c.setFont('Vera', 10) |
88 c.drawString(100, 700, 'Hello, ' + utf8(0xffee)) |
56 c.drawString(100, 700, b'Hello, ' + utf8(0xffee)) |
89 c.save() |
57 c.save() |
90 |
58 |
91 |
59 |
92 class TTFontFileTestCase(NearTestCase): |
60 class TTFontFileTestCase(NearTestCase): |
93 "Tests TTFontFile, TTFontParser and TTFontMaker classes" |
61 "Tests TTFontFile, TTFontParser and TTFontMaker classes" |
94 |
62 |
95 def testFontFileFailures(self): |
63 def testFontFileFailures(self): |
96 "Tests TTFontFile constructor error checks" |
64 "Tests TTFontFile constructor error checks" |
97 self.assertRaises(TTFError, TTFontFile, "nonexistent file") |
65 self.assertRaises(TTFError, TTFontFile, "nonexistent file") |
98 self.assertRaises(TTFError, TTFontFile, StringIO("")) |
66 self.assertRaises(TTFError, TTFontFile, getBytesIO(b"")) |
99 self.assertRaises(TTFError, TTFontFile, StringIO("invalid signature")) |
67 self.assertRaises(TTFError, TTFontFile, getBytesIO(b"invalid signature")) |
100 self.assertRaises(TTFError, TTFontFile, StringIO("OTTO - OpenType not supported yet")) |
68 self.assertRaises(TTFError, TTFontFile, getBytesIO(b"OTTO - OpenType not supported yet")) |
101 self.assertRaises(TTFError, TTFontFile, StringIO("\0\1\0\0")) |
69 self.assertRaises(TTFError, TTFontFile, getBytesIO(b"\0\1\0\0")) |
102 |
70 |
103 def testFontFileReads(self): |
71 def testFontFileReads(self): |
104 "Tests TTFontParset.read_xxx" |
72 "Tests TTFontParset.read_xxx" |
105 |
73 |
106 class FakeTTFontFile(TTFontParser): |
74 class FakeTTFontFile(TTFontParser): |
107 def __init__(self, data): |
75 def __init__(self, data): |
108 self._ttf_data = data |
76 self._ttf_data = data |
109 self._pos = 0 |
77 self._pos = 0 |
110 |
78 |
111 ttf = FakeTTFontFile("\x81\x02\x03\x04" "\x85\x06" "ABCD" "\x7F\xFF" "\x80\x00" "\xFF\xFF") |
79 ttf = FakeTTFontFile(b"\x81\x02\x03\x04" b"\x85\x06" b"ABCD" b"\x7F\xFF" b"\x80\x00" b"\xFF\xFF") |
112 self.assertEquals(ttf.read_ulong(), 0x81020304) # big-endian |
80 self.assertEquals(ttf.read_ulong(), 0x81020304) # big-endian |
113 self.assertEquals(ttf._pos, 4) |
81 self.assertEquals(ttf._pos, 4) |
114 self.assertEquals(ttf.read_ushort(), 0x8506) |
82 self.assertEquals(ttf.read_ushort(), 0x8506) |
115 self.assertEquals(ttf._pos, 6) |
83 self.assertEquals(ttf._pos, 6) |
116 self.assertEquals(ttf.read_tag(), 'ABCD') |
84 self.assertEquals(ttf.read_tag(), 'ABCD') |
120 self.assertEquals(ttf.read_short(), -1) |
88 self.assertEquals(ttf.read_short(), -1) |
121 |
89 |
122 def testFontFile(self): |
90 def testFontFile(self): |
123 "Tests TTFontFile and TTF parsing code" |
91 "Tests TTFontFile and TTF parsing code" |
124 ttf = TTFontFile("Vera.ttf") |
92 ttf = TTFontFile("Vera.ttf") |
125 self.assertEquals(ttf.name, "BitstreamVeraSans-Roman") |
93 self.assertEquals(ttf.name, b"BitstreamVeraSans-Roman") |
126 self.assertEquals(ttf.flags, FF_SYMBOLIC) |
94 self.assertEquals(ttf.flags, FF_SYMBOLIC) |
127 self.assertEquals(ttf.italicAngle, 0.0) |
95 self.assertEquals(ttf.italicAngle, 0.0) |
128 self.assertNear(ttf.ascent,759.765625) |
96 self.assertNear(ttf.ascent,759.765625) |
129 self.assertNear(ttf.descent,-240.234375) |
97 self.assertNear(ttf.descent,-240.234375) |
130 self.assertEquals(ttf.capHeight, 759.765625) |
98 self.assertEquals(ttf.capHeight, 759.765625) |
139 self.assertEquals(add32(0x80000000, -1), 0x7FFFFFFF) |
107 self.assertEquals(add32(0x80000000, -1), 0x7FFFFFFF) |
140 self.assertEquals(add32(0x7FFFFFFF, 1), 0x80000000) |
108 self.assertEquals(add32(0x7FFFFFFF, 1), 0x80000000) |
141 |
109 |
142 def testChecksum(self): |
110 def testChecksum(self): |
143 "Test calcChecksum function" |
111 "Test calcChecksum function" |
144 self.assertEquals(calcChecksum(""), 0) |
112 self.assertEquals(calcChecksum(b""), 0) |
145 self.assertEquals(calcChecksum("\1"), 0x01000000) |
113 self.assertEquals(calcChecksum(b"\1"), 0x01000000) |
146 self.assertEquals(calcChecksum("\x01\x02\x03\x04\x10\x20\x30\x40"), 0x11223344) |
114 self.assertEquals(calcChecksum(b"\x01\x02\x03\x04\x10\x20\x30\x40"), 0x11223344) |
147 self.assertEquals(calcChecksum("\x81"), 0x81000000) |
115 self.assertEquals(calcChecksum(b"\x81"), 0x81000000) |
148 self.assertEquals(calcChecksum("\x81\x02"), 0x81020000) |
116 self.assertEquals(calcChecksum(b"\x81\x02"), 0x81020000) |
149 self.assertEquals(calcChecksum("\x81\x02\x03"), 0x81020300) |
117 self.assertEquals(calcChecksum(b"\x81\x02\x03"), 0x81020300) |
150 self.assertEquals(calcChecksum("\x81\x02\x03\x04"), 0x81020304) |
118 self.assertEquals(calcChecksum(b"\x81\x02\x03\x04"), 0x81020304) |
151 self.assertEquals(calcChecksum("\x81\x02\x03\x04\x05"), 0x86020304) |
119 self.assertEquals(calcChecksum(b"\x81\x02\x03\x04\x05"), 0x86020304) |
152 self.assertEquals(calcChecksum("\x41\x02\x03\x04\xD0\x20\x30\x40"), 0x11223344) |
120 self.assertEquals(calcChecksum(b"\x41\x02\x03\x04\xD0\x20\x30\x40"), 0x11223344) |
153 self.assertEquals(calcChecksum("\xD1\x02\x03\x04\x40\x20\x30\x40"), 0x11223344) |
121 self.assertEquals(calcChecksum(b"\xD1\x02\x03\x04\x40\x20\x30\x40"), 0x11223344) |
154 self.assertEquals(calcChecksum("\x81\x02\x03\x04\x90\x20\x30\x40"), 0x11223344) |
122 self.assertEquals(calcChecksum(b"\x81\x02\x03\x04\x90\x20\x30\x40"), 0x11223344) |
155 self.assertEquals(calcChecksum("\x7F\xFF\xFF\xFF\x00\x00\x00\x01"), 0x80000000) |
123 self.assertEquals(calcChecksum(b"\x7F\xFF\xFF\xFF\x00\x00\x00\x01"), 0x80000000) |
156 |
124 |
157 def testFontFileChecksum(self): |
125 def testFontFileChecksum(self): |
158 "Tests TTFontFile and TTF parsing code" |
126 "Tests TTFontFile and TTF parsing code" |
159 file = TTFOpenFile("Vera.ttf")[1].read() |
127 F = TTFOpenFile("Vera.ttf")[1].read() |
160 TTFontFile(StringIO(file), validate=1) # should not fail |
128 TTFontFile(getBytesIO(F), validate=1) # should not fail |
161 file1 = file[:12345] + "\xFF" + file[12346:] # change one byte |
129 F1 = F[:12345] + b"\xFF" + F[12346:] # change one byte |
162 self.assertRaises(TTFError, TTFontFile, StringIO(file1), validate=1) |
130 self.assertRaises(TTFError, TTFontFile, getBytesIO(F1), validate=1) |
163 file1 = file[:8] + "\xFF" + file[9:] # change one byte |
131 F1 = F[:8] + b"\xFF" + F[9:] # change one byte |
164 self.assertRaises(TTFError, TTFontFile, StringIO(file1), validate=1) |
132 self.assertRaises(TTFError, TTFontFile, getBytesIO(F1), validate=1) |
165 |
133 |
166 def testSubsetting(self): |
134 def testSubsetting(self): |
167 "Tests TTFontFile and TTF parsing code" |
135 "Tests TTFontFile and TTF parsing code" |
168 ttf = TTFontFile("Vera.ttf") |
136 ttf = TTFontFile("Vera.ttf") |
169 subset = ttf.makeSubset([0x41, 0x42]) |
137 subset = ttf.makeSubset([0x41, 0x42]) |
170 subset = TTFontFile(StringIO(subset), 0) |
138 subset = TTFontFile(getBytesIO(subset), 0) |
171 for tag in ('cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'OS/2', |
139 for tag in ('cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'OS/2', |
172 'post', 'cvt ', 'fpgm', 'glyf', 'loca', 'prep'): |
140 'post', 'cvt ', 'fpgm', 'glyf', 'loca', 'prep'): |
173 self.assert_(subset.get_table(tag)) |
141 self.assert_(subset.get_table(tag)) |
174 |
142 |
175 subset.seek_table('loca') |
143 subset.seek_table('loca') |
176 for n in range(4): |
144 for n in range(4): |
177 pos = subset.read_ushort() # this is actually offset / 2 |
145 pos = subset.read_ushort() # this is actually offset / 2 |
178 self.failIf(pos % 2 != 0, "glyph %d at +%d should be long aligned" % (n, pos * 2)) |
146 self.failIf(pos % 2 != 0, "glyph %d at +%d should be long aligned" % (n, pos * 2)) |
179 |
147 |
180 self.assertEquals(subset.name, "BitstreamVeraSans-Roman") |
148 self.assertEquals(subset.name, b"BitstreamVeraSans-Roman") |
181 self.assertEquals(subset.flags, FF_SYMBOLIC) |
149 self.assertEquals(subset.flags, FF_SYMBOLIC) |
182 self.assertEquals(subset.italicAngle, 0.0) |
150 self.assertEquals(subset.italicAngle, 0.0) |
183 self.assertNear(subset.ascent,759.765625) |
151 self.assertNear(subset.ascent,759.765625) |
184 self.assertNear(subset.descent,-240.234375) |
152 self.assertNear(subset.descent,-240.234375) |
185 self.assertEquals(subset.capHeight, 759.765625) |
153 self.assertEquals(subset.capHeight, 759.765625) |
187 self.assertEquals(subset.stemV, 87) |
155 self.assertEquals(subset.stemV, 87) |
188 |
156 |
189 def testFontMaker(self): |
157 def testFontMaker(self): |
190 "Tests TTFontMaker class" |
158 "Tests TTFontMaker class" |
191 ttf = TTFontMaker() |
159 ttf = TTFontMaker() |
192 ttf.add("ABCD", "xyzzy") |
160 ttf.add("ABCD", b"xyzzy") |
193 ttf.add("QUUX", "123") |
161 ttf.add("QUUX", b"123") |
194 ttf.add("head", "12345678xxxx") |
162 ttf.add("head", b"12345678xxxx") |
195 stm = ttf.makeStream() |
163 stm = ttf.makeStream() |
196 ttf = TTFontParser(StringIO(stm), 0) |
164 ttf = TTFontParser(getBytesIO(stm), 0) |
197 self.assertEquals(ttf.get_table("ABCD"), "xyzzy") |
165 self.assertEquals(ttf.get_table("ABCD"), b"xyzzy") |
198 self.assertEquals(ttf.get_table("QUUX"), "123") |
166 self.assertEquals(ttf.get_table("QUUX"), b"123") |
199 |
167 |
200 |
168 |
201 class TTFontFaceTestCase(unittest.TestCase): |
169 class TTFontFaceTestCase(unittest.TestCase): |
202 "Tests TTFontFace class" |
170 "Tests TTFontFace class" |
203 |
171 |
222 |
190 |
223 |
191 |
224 class TTFontTestCase(NearTestCase): |
192 class TTFontTestCase(NearTestCase): |
225 "Tests TTFont class" |
193 "Tests TTFont class" |
226 |
194 |
227 def testParseUTF8(self): |
|
228 "Tests parse_utf8" |
|
229 self.assertEquals(parse_utf8(""), []) |
|
230 for i in range(0, 0x80): |
|
231 self.assertEquals(parse_utf8(chr(i)), [i]) |
|
232 for i in range(0x80, 0xA0): |
|
233 self.assertRaises(ValueError, parse_utf8, chr(i)) |
|
234 self.assertEquals(parse_utf8("abc"), [0x61, 0x62, 0x63]) |
|
235 self.assertEquals(parse_utf8("\xC2\xA9x"), [0xA9, 0x78]) |
|
236 self.assertEquals(parse_utf8("\xE2\x89\xA0x"), [0x2260, 0x78]) |
|
237 self.assertRaises(ValueError, parse_utf8, "\xE2\x89x") |
|
238 # for i in range(0, 0xFFFF): - overkill |
|
239 for i in list(range(0x80, 0x200)) + list(range(0x300, 0x400)) + [0xFFFE, 0xFFFF]: |
|
240 self.assertEquals(parse_utf8(utf8(i)), [i]) |
|
241 |
|
242 def testStringWidth(self): |
195 def testStringWidth(self): |
243 "Test TTFont.stringWidth" |
196 "Test TTFont.stringWidth" |
244 font = TTFont("Vera", "Vera.ttf") |
197 font = TTFont("Vera", "Vera.ttf") |
245 self.assert_(font.stringWidth("test", 10) > 0) |
198 self.assert_(font.stringWidth("test", 10) > 0) |
246 width = font.stringWidth(utf8(0x2260) * 2, 1000) |
199 width = font.stringWidth(utf8(0x2260) * 2, 1000) |
249 |
202 |
250 def testSplitString(self): |
203 def testSplitString(self): |
251 "Tests TTFont.splitString" |
204 "Tests TTFont.splitString" |
252 doc = PDFDocument() |
205 doc = PDFDocument() |
253 font = TTFont("Vera", "Vera.ttf") |
206 font = TTFont("Vera", "Vera.ttf") |
254 text = "".join(list(map(utf8, range(0, 511)))) |
207 text = b"".join(utf8(i) for i in range(511)) |
255 allchars = "".join(list(map(chr, range(0, 256)))) |
208 allchars = b"".join(int2Byte(i) for i in range(256)) |
256 nospace = allchars[:32] + allchars[33:] |
209 nospace = allchars[:32] + allchars[33:] |
257 chunks = [(0, allchars), (1, nospace)] |
210 chunks = [(0, allchars), (1, nospace)] |
258 self.assertEquals(font.splitString(text, doc), chunks) |
211 self.assertEquals(font.splitString(text, doc), chunks) |
259 # Do it twice |
212 # Do it twice |
260 self.assertEquals(font.splitString(text, doc), chunks) |
213 self.assertEquals(font.splitString(text, doc), chunks) |
261 |
214 |
262 text = "".join(list(map(utf8, list(range(510, -1, -1))))) |
215 text = b"".join(utf8(i) for i in range(510, -1, -1)) |
263 allchars = "".join(list(map(chr, list(range(255, -1, -1))))) |
216 allchars = b"".join(int2Byte(i) for i in range(255, -1, -1)) |
264 nospace = allchars[:223] + allchars[224:] |
217 nospace = allchars[:223] + allchars[224:] |
265 chunks = [(1, nospace), (0, allchars)] |
218 chunks = [(1, nospace), (0, allchars)] |
266 self.assertEquals(font.splitString(text, doc), chunks) |
219 self.assertEquals(font.splitString(text, doc), chunks) |
267 |
220 |
268 def testSplitStringSpaces(self): |
221 def testSplitStringSpaces(self): |
270 # glyph must have a code 32, and no other character should have |
223 # glyph must have a code 32, and no other character should have |
271 # that code in any subset, or word spacing will be applied to it. |
224 # that code in any subset, or word spacing will be applied to it. |
272 |
225 |
273 doc = PDFDocument() |
226 doc = PDFDocument() |
274 font = TTFont("Vera", "Vera.ttf") |
227 font = TTFont("Vera", "Vera.ttf") |
275 text = "".join(list(map(utf8, list(range(512, -1, -1))))) |
228 text = b"".join(utf8(i) for i in range(512, -1, -1)) |
276 chunks = font.splitString(text, doc) |
229 chunks = font.splitString(text, doc) |
277 state = font.state[doc] |
230 state = font.state[doc] |
278 self.assertEquals(state.assignments[32], 32) |
231 self.assertEquals(state.assignments[32], 32) |
279 self.assertEquals(state.subsets[0][32], 32) |
232 self.assertEquals(state.subsets[0][32], 32) |
280 self.assertEquals(state.subsets[1][32], 32) |
233 self.assertEquals(state.subsets[1][32], 32) |
282 def testSubsetInternalName(self): |
235 def testSubsetInternalName(self): |
283 "Tests TTFont.getSubsetInternalName" |
236 "Tests TTFont.getSubsetInternalName" |
284 doc = PDFDocument() |
237 doc = PDFDocument() |
285 font = TTFont("Vera", "Vera.ttf") |
238 font = TTFont("Vera", "Vera.ttf") |
286 # Actually generate some subsets |
239 # Actually generate some subsets |
287 text = "".join(list(map(utf8, list(range(0, 513))))) |
240 text = b"".join(utf8(i) for i in range(513)) |
288 font.splitString(text, doc) |
241 font.splitString(text, doc) |
289 self.assertRaises(IndexError, font.getSubsetInternalName, -1, doc) |
242 self.assertRaises(IndexError, font.getSubsetInternalName, -1, doc) |
290 self.assertRaises(IndexError, font.getSubsetInternalName, 3, doc) |
243 self.assertRaises(IndexError, font.getSubsetInternalName, 3, doc) |
291 self.assertEquals(font.getSubsetInternalName(0, doc), "/F1+0") |
244 self.assertEquals(font.getSubsetInternalName(0, doc), "/F1+0") |
292 self.assertEquals(font.getSubsetInternalName(1, doc), "/F1+1") |
245 self.assertEquals(font.getSubsetInternalName(1, doc), "/F1+1") |
319 try: |
272 try: |
320 rl_config.ttfAsciiReadable = 1 |
273 rl_config.ttfAsciiReadable = 1 |
321 doc1 = PDFDocument() |
274 doc1 = PDFDocument() |
322 doc2 = PDFDocument() |
275 doc2 = PDFDocument() |
323 font = TTFont("Vera", "Vera.ttf") |
276 font = TTFont("Vera", "Vera.ttf") |
324 self.assertEquals(font.splitString('hello ', doc1), [(0, 'hello ')]) |
277 self.assertEquals(font.splitString('hello ', doc1), [(0, b'hello ')]) |
325 self.assertEquals(font.splitString('hello ', doc2), [(0, 'hello ')]) |
278 self.assertEquals(font.splitString('hello ', doc2), [(0, b'hello ')]) |
326 self.assertEquals(font.splitString('\u0410\u0411'.encode('UTF-8'), doc1), [(0, '\x80\x81')]) |
279 self.assertEquals(font.splitString('\u0410\u0411'.encode('UTF-8'), doc1), [(0, b'\x80\x81')]) |
327 self.assertEquals(font.splitString('\u0412'.encode('UTF-8'), doc2), [(0, '\x80')]) |
280 self.assertEquals(font.splitString('\u0412'.encode('UTF-8'), doc2), [(0, b'\x80')]) |
328 font.addObjects(doc1) |
281 font.addObjects(doc1) |
329 self.assertEquals(font.splitString('\u0413'.encode('UTF-8'), doc2), [(0, '\x81')]) |
282 self.assertEquals(font.splitString('\u0413'.encode('UTF-8'), doc2), [(0, b'\x81')]) |
330 font.addObjects(doc2) |
283 font.addObjects(doc2) |
331 finally: |
284 finally: |
332 rl_config.ttfAsciiReadable = ttfAsciiReadable |
285 rl_config.ttfAsciiReadable = ttfAsciiReadable |
333 |
286 |
334 def testAddObjects(self): |
287 def testAddObjects(self): |