Esempio n. 1
0
def test_one_liner(doc):
    layout = doc.blocks.new('test_one_liner')
    text = "OneLine"
    mtext = MText(text, (0., 0., 0.))
    mtext.render(layout)
    assert len(layout) == 1
    lines = list(layout)
    assert lines[0].dxftype() == 'TEXT'
    assert lines[0].dxf.align_point == (0, 0, 0)
    assert lines[0].dxf.valign == MText.TOP
    assert lines[0].dxf.halign == MText.LEFT
Esempio n. 2
0
def test_horiz_middle(doc):
    layout = doc.blocks.new('test_horiz_middle')
    text = "lineA\nlineB"
    mtext = MText(text, (0., 0., 0.), 1.0, align='MIDDLE_LEFT')
    mtext.render(layout)
    assert len(layout) == 2
    lines = list(layout)
    assert lines[0].dxftype() == 'TEXT'
    assert lines[1].dxftype() == 'TEXT'
    assert lines[0].dxf.text == 'lineA'
    assert lines[1].dxf.text == 'lineB'
    assert lines[0].dxf.align_point == (0, .5, 0)
    assert lines[1].dxf.align_point == (0, -.5, 0)
    assert lines[0].dxf.valign == MText.MIDDLE
    assert lines[0].dxf.halign == MText.LEFT
Esempio n. 3
0
def test_horiz_bottom(doc):
    layout = doc.blocks.new('test_horiz_bottom')
    text = "lineA\nlineB"
    mtext = MText(text, (0., 0., 0.), 1.0, align='BOTTOM_LEFT')
    mtext.render(layout)
    assert len(layout) == 2
    lines = list(layout)
    assert lines[0].dxftype() == 'TEXT'
    assert lines[1].dxftype() == 'TEXT'
    assert lines[0].dxf.text == 'lineA'
    assert lines[1].dxf.text == 'lineB'
    assert lines[0].dxf.align_point == (0, 1, 0)
    assert lines[1].dxf.align_point == (0, 0, 0)
    assert lines[0].dxf.valign == MText.BOTTOM
    assert lines[0].dxf.halign == MText.LEFT
Esempio n. 4
0
def test_horiz_top(doc):
    layout = doc.blocks.new('test_horiz_top')
    text = "lineA\nlineB"
    mtext = MText(text, (0., 0., 0.), 1.0)
    mtext.render(layout)
    assert len(layout) == 2
    lines = list(layout)
    assert lines[0].dxftype() == 'TEXT'
    assert lines[1].dxftype() == 'TEXT'
    assert lines[0].dxf.text == 'lineA'
    assert lines[1].dxf.text == 'lineB'
    assert lines[0].dxf.align_point == (0, 0, 0)
    assert lines[1].dxf.align_point == (0, -1, 0)
    assert lines[0].dxf.valign == MText.TOP
    assert lines[0].dxf.halign == MText.LEFT
Esempio n. 5
0
def test_horiz_middle(doc):
    layout = doc.blocks.new("test_horiz_middle")
    text = "lineA\nlineB"
    mtext = MText(text, (0.0, 0.0, 0.0), 1.0, align="MIDDLE_LEFT")
    mtext.render(layout)
    assert len(layout) == 2
    lines = list(layout)
    assert lines[0].dxftype() == "TEXT"
    assert lines[1].dxftype() == "TEXT"
    assert lines[0].dxf.text == "lineA"
    assert lines[1].dxf.text == "lineB"
    assert lines[0].dxf.align_point == (0, 0.5, 0)
    assert lines[1].dxf.align_point == (0, -0.5, 0)
    assert lines[0].dxf.valign == MText.MIDDLE
    assert lines[0].dxf.halign == MText.LEFT
Esempio n. 6
0
def test_horiz_bottom(doc):
    layout = doc.blocks.new("test_horiz_bottom")
    text = "lineA\nlineB"
    mtext = MText(text, (0.0, 0.0, 0.0), 1.0, align="BOTTOM_LEFT")
    mtext.render(layout)
    assert len(layout) == 2
    lines = list(layout)
    assert lines[0].dxftype() == "TEXT"
    assert lines[1].dxftype() == "TEXT"
    assert lines[0].dxf.text == "lineA"
    assert lines[1].dxf.text == "lineB"
    assert lines[0].dxf.align_point == (0, 1, 0)
    assert lines[1].dxf.align_point == (0, 0, 0)
    assert lines[0].dxf.valign == MText.BOTTOM
    assert lines[0].dxf.halign == MText.LEFT
Esempio n. 7
0
def test_45deg_bottom(doc):
    layout = doc.blocks.new('test_45deg_bottom')
    text = "lineA\nlineB\nlineC"
    mtext = MText(text, (0., 0., 0.), 1.0, align='BOTTOM_LEFT', rotation=45)
    mtext.render(layout)
    assert len(layout) == 3
    lines = list(layout)
    assert lines[0].dxftype() == 'TEXT'
    assert lines[1].dxftype() == 'TEXT'
    assert lines[2].dxftype() == 'TEXT'
    assert lines[0].dxf.text == 'lineA'
    assert lines[1].dxf.text == 'lineB'
    assert lines[2].dxf.text == 'lineC'
    assert lines[0].dxf.align_point == (-1.414214, 1.414214, 0)
    assert lines[1].dxf.align_point == (-0.707107, 0.707107, 0)
    assert lines[2].dxf.align_point == (0, 0, 0)
    assert lines[0].dxf.rotation == 45
    assert lines[0].dxf.valign == MText.BOTTOM
    assert lines[0].dxf.halign == MText.LEFT
Esempio n. 8
0
def test_45deg_top(doc):
    layout = doc.blocks.new("test_45deg_top")
    text = "lineA\nlineB\nlineC"
    mtext = MText(text, (0.0, 0.0, 0.0), 1.0, align="TOP_LEFT", rotation=45)
    mtext.render(layout)
    assert len(layout) == 3
    lines = list(layout)
    assert lines[0].dxftype() == "TEXT"
    assert lines[1].dxftype() == "TEXT"
    assert lines[2].dxftype() == "TEXT"
    assert lines[0].dxf.text == "lineA"
    assert lines[1].dxf.text == "lineB"
    assert lines[2].dxf.text == "lineC"
    assert lines[0].dxf.align_point == (0, 0, 0)
    assert lines[1].dxf.align_point == (0.707107, -0.707107, 0)
    assert lines[2].dxf.align_point == (1.414214, -1.414214, 0)
    assert lines[0].dxf.rotation == 45
    assert lines[0].dxf.valign == MText.TOP
    assert lines[0].dxf.halign == MText.LEFT
Esempio n. 9
0
def test_45deg_top(dxf):
    layout = dxf.blocks.new('test_45deg_top')
    text = "lineA\nlineB\nlineC"
    mtext = MText(text, (0., 0., 0.), 1.0, align='TOP_LEFT', rotation=45)
    mtext.render(layout)
    assert len(layout) == 3
    lines = list(layout)
    assert lines[0].dxftype() == 'TEXT'
    assert lines[1].dxftype() == 'TEXT'
    assert lines[2].dxftype() == 'TEXT'
    assert lines[0].dxf.text == 'lineA'
    assert lines[1].dxf.text == 'lineB'
    assert lines[2].dxf.text == 'lineC'
    assert lines[0].dxf.align_point == (0, 0, 0)
    assert lines[1].dxf.align_point == (0.707107, -0.707107, 0)
    assert lines[2].dxf.align_point == (1.414214, -1.414214, 0)
    assert lines[0].dxf.rotation == 45
    assert lines[0].dxf.valign == MText.TOP
    assert lines[0].dxf.halign == MText.LEFT