Exemplo n.º 1
0
 def export_mtext(self, tagwriter: 'TagWriter') -> None:
     txt = escape_dxf_line_endings(self.text)
     str_chunks = split_mtext_string(txt, size=250)
     if len(str_chunks) == 0:
         str_chunks.append("")
     while len(str_chunks) > 1:
         tagwriter.write_tag2(3, str_chunks.pop(0))
     tagwriter.write_tag2(1, str_chunks[0])
Exemplo n.º 2
0
 def export_coordinate_system_definition(self, tagwriter: 'TagWriter'):
     text = self.coordinate_system_definition.replace('\n', '^J')
     chunks = split_mtext_string(text, size=255)
     if len(chunks) == 0:
         chunks.append("")
     while len(chunks) > 1:
         tagwriter.write_tag2(303, chunks.pop(0))
     tagwriter.write_tag2(301, chunks[0])
Exemplo n.º 3
0
 def test_split_longer_string(self):
     chunks = split_mtext_string(self.MTEXT_SHORT_STR * 4, 20)
     assert len(chunks) == 2
     assert chunks[0] == self.MTEXT_SHORT_STR * 2
     assert chunks[1] == self.MTEXT_SHORT_STR * 2
Exemplo n.º 4
0
 def test_split_long_string(self):
     chunks = split_mtext_string(self.MTEXT_SHORT_STR * 3, 20)
     assert len(chunks) == 2
     assert self.MTEXT_SHORT_STR * 2 == chunks[0]
     assert self.MTEXT_SHORT_STR == chunks[1]
Exemplo n.º 5
0
 def test_split_short_string(self):
     chunks = split_mtext_string(self.MTEXT_SHORT_STR, 20)
     assert len(chunks) == 1
     assert self.MTEXT_SHORT_STR == chunks[0]
Exemplo n.º 6
0
 def test_split_empty_string(self):
     chunks = split_mtext_string('', 20)
     assert len(chunks) == 0
Exemplo n.º 7
0
 def test_do_not_split_at_caret(self):
     # do not split at '^'
     chunks = split_mtext_string('a' * 19 + '^Ixxx^', 20)
     assert len(chunks) == 2
     assert chunks[0] == 'a' * 19
     assert chunks[1] == '^Ixxx^'
Exemplo n.º 8
0
 def test_do_not_split_at_caret(self):
     # do not split at '^'
     chunks = split_mtext_string("a" * 19 + "^Ixxx^", 20)
     assert len(chunks) == 2
     assert chunks[0] == "a" * 19
     assert chunks[1] == "^Ixxx^"