text.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Created: 25.03.2011
  2. # Copyright (c) 2011-2018, Manfred Moitzi
  3. # License: MIT License
  4. from ezdxf.legacy import text
  5. from .graphics import ExtendedTags, DXFAttr, DefSubclass, DXFAttributes, XType
  6. from .graphics import none_subclass, entity_subclass, ModernGraphicEntityExtension
  7. _TEXT_TPL = """0
  8. TEXT
  9. 5
  10. 0
  11. 330
  12. 0
  13. 100
  14. AcDbEntity
  15. 8
  16. 0
  17. 100
  18. AcDbText
  19. 10
  20. 0.0
  21. 20
  22. 0.0
  23. 30
  24. 0.0
  25. 40
  26. 1.0
  27. 1
  28. TEXTCONTENT
  29. 50
  30. 0.0
  31. 51
  32. 0.0
  33. 7
  34. STANDARD
  35. 41
  36. 1.0
  37. 71
  38. 0
  39. 72
  40. 0
  41. 11
  42. 0.0
  43. 21
  44. 0.0
  45. 31
  46. 0.0
  47. 100
  48. AcDbText
  49. 73
  50. 0
  51. """
  52. text_subclass = (
  53. DefSubclass('AcDbText', {
  54. 'insert': DXFAttr(10, xtype=XType.any_point),
  55. 'height': DXFAttr(40),
  56. 'text': DXFAttr(1),
  57. 'rotation': DXFAttr(50, default=0.0), # in degrees (circle = 360deg)
  58. 'oblique': DXFAttr(51, default=0.0), # in degrees, vertical = 0deg
  59. 'style': DXFAttr(7, default='STANDARD'), # text style
  60. 'width': DXFAttr(41, default=1.0), # width FACTOR!
  61. 'text_generation_flag': DXFAttr(71, default=0), # 2 = backward (mirror-x), 4 = upside down (mirror-y)
  62. 'halign': DXFAttr(72, default=0), # horizontal justification
  63. 'align_point': DXFAttr(11, xtype=XType.any_point),
  64. 'thickness': DXFAttr(39, default=0.0),
  65. 'extrusion': DXFAttr(210, xtype=XType.point3d, default=(0.0, 0.0, 1.0)),
  66. }),
  67. DefSubclass('AcDbText', {'valign': DXFAttr(73, default=0)}))
  68. class Text(text.Text, ModernGraphicEntityExtension):
  69. __slots__ = ()
  70. TEMPLATE = ExtendedTags.from_text(_TEXT_TPL)
  71. DXFATTRIBS = DXFAttributes(none_subclass, entity_subclass, *text_subclass)