File: text.rst

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (131 lines) | stat: -rw-r--r-- 3,759 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
Text
====

.. module:: ezdxf.entities
    :noindex:

The TEXT entity (`DXF Reference`_) represents a single line of text.
The :attr:`~Text.dxf.style` attribute stores the associated :class:`Textstyle` entity as
string, which defines the basic font properties. The text size is stored as cap-height
in the :attr:`~Text.dxf.height` attribute in drawing units. Text alignments
are defined as enums of type :class:`ezdxf.enums.TextEntityAlignment`.

.. seealso::

    See the documentation for the :class:`Textstyle` class to understand the
    limitations of text representation in the DXF format.

    :ref:`tut_text`

======================== ==========================================
Subclass of              :class:`ezdxf.entities.DXFGraphic`
DXF type                 ``'TEXT'``
Factory function         :meth:`ezdxf.layouts.BaseLayout.add_text`
Inherited DXF attributes :ref:`Common graphical DXF attributes`
======================== ==========================================

.. warning::

    Do not instantiate entity classes by yourself - always use the provided
    factory functions!


.. class:: Text

    .. attribute:: dxf.text

        Text content as string.

    .. attribute:: dxf.insert

        First alignment point of text (2D/3D Point in :ref:`OCS`), relevant for
        the adjustments LEFT, ALIGNED  and FIT.

    .. attribute:: dxf.align_point

        The main alignment point of text (2D/3D Point in :ref:`OCS`), if the
        alignment is anything else than LEFT, or the second alignment point
        for the ALIGNED and FIT alignments.

    .. attribute:: dxf.height

        Text height in drawing units as float value, the default value is 1.

    .. attribute:: dxf.rotation

        Text rotation in degrees as float value, the default value is 0.

    .. attribute:: dxf.oblique

        Text oblique angle (slanting)  in degrees as float value, the default
        value is 0 (straight vertical text).

    .. attribute:: dxf.style

        :class:`Textstyle` name as case insensitive string, the default value
        is "Standard"

    .. attribute:: dxf.width

        Width scale factor as float value, the default value is 1.

    .. attribute:: dxf.halign

        Horizontal alignment flag as int value, use the :meth:`~Text.set_placement`
        and :meth:`~Text.get_align_enum` methods to handle text alignment, the
        default value is 0.

        === =========
        0   Left
        2   Right
        3   Aligned (if vertical alignment = 0)
        4   Middle (if vertical alignment = 0)
        5   Fit (if vertical alignment = 0)
        === =========

    .. attribute:: dxf.valign

        Vertical alignment flag as int value, use the :meth:`~Text.set_placement`
        and :meth:`~Text.get_align_enum` methods to handle text alignment, the
        default value is 0.

        === =========
        0   Baseline
        1   Bottom
        2   Middle
        3   Top
        === =========

    .. attribute:: dxf.text_generation_flag

        Text generation flags as int value, use the :attr:`is_backward` and
        :attr:`is_upside_down` attributes to handle this flags.

        === =========
        2   text is backward (mirrored in X)
        4   text is upside down (mirrored in Y)
        === =========

    .. autoproperty:: is_backward

    .. autoproperty:: is_upside_down

    .. automethod:: set_placement

    .. automethod:: get_placement

    .. automethod:: get_align_enum

    .. automethod:: set_align_enum

    .. automethod:: transform

    .. automethod:: translate

    .. automethod:: plain_text

    .. automethod:: font_name

    .. automethod:: fit_length

.. _DXF Reference: http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-62E5383D-8A14-47B4-BFC4-35824CAE8363