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
|
.. module:: ezdxf.addons.text2path
text2path
=========
Tools to convert text strings and text based DXF entities into outer- and inner
linear paths as :class:`~ezdxf.path.Path` objects. At the moment only the TEXT and the
ATTRIB entity can be converted into paths and hatches.
.. versionadded:: 1.1
Text rendering is done by the `fontTools`_ package, which is a hard dependency of
`ezdxf`. Support for stroke fonts, these are the basic vector fonts included in CAD
applications, like .shx, .shp or .lff fonts was added but these fonts cannot be
rendered as HATCH entities.
The required font files are not included with `ezdxf` as they are copyrighted or,
in the case of the LibreCAD font format, licensed under the "GPL v2 and later".
Set the paths to such stroke fonts in the config file, see option
:attr:`ezdxf.options.support_dirs`:
.. code-block:: ini
[core]
support_dirs =
"C:\Program Files\Bricsys\BricsCAD V23 en_US\Fonts",
~/shx_fonts,
~/shp_fonts,
~/lff_fonts,
Don't expect a 100% match compared to CAD applications but the results with `fontTools`
are better than the previous `Matplotlib` renderings.
Text Alignments
---------------
The text alignments are enums of type :class:`ezdxf.enums.TextEntityAlignment`
============ =============== ================= =====
Vertical Left Center Right
============ =============== ================= =====
Top TOP_LEFT TOP_CENTER TOP_RIGHT
Middle MIDDLE_LEFT MIDDLE_CENTER MIDDLE_RIGHT
Bottom BOTTOM_LEFT BOTTOM_CENTER BOTTOM_RIGHT
Baseline LEFT CENTER RIGHT
============ =============== ================= =====
The vertical middle alignments (MIDDLE_XXX), center the text
vertically in the middle of the uppercase letter "X" (cap height).
Special alignments, where the horizontal alignment is always in the center of
the text:
- ALIGNED: text is scaled to match the given `length`, scales x- and
y-direction by the same factor.
- FIT: text is scaled to match the given `length`, but scales only in
x-direction.
- MIDDLE: insertion point is the center of the total height (cap height +
descender height) without scaling, the `length` argument is ignored.
Font Face Definition
--------------------
A font face is defined by the Matplotlib compatible
:class:`~ezdxf.tools.fonts.FontFace` object by ``font-family``, ``font-style``,
``font-stretch`` and ``font-weight``.
.. seealso::
- :ref:`font_anatomy`
- :ref:`font_properties`
String Functions
----------------
.. autofunction:: make_path_from_str
.. autofunction:: make_paths_from_str
.. autofunction:: make_hatches_from_str
Entity Functions
----------------
.. autoclass:: Kind
.. autofunction:: virtual_entities
.. autofunction:: explode
.. autofunction:: make_path_from_entity
.. autofunction:: make_paths_from_entity
.. _fontTools: https://pypi.org/project/fonttools/
|