Skip to content

Commit 8dc1a5c

Browse files
text() docstring update (#813)
* docstring update text() * Remove following line from docstring (appears to be copy/paste error from extrude()) extrude always *adds* material to a part. * Swap order of :param distance: and :param fontsize: to match argument order * Mention fontsize is in model units (fix #463) * distance: mention distance is for both extrude/cut * Update kind default in docstring as "regular" not "Normal" * Add missing fontPath arg description * Add examples of usage - Using an installed system font - Using a font at provided path (when font not installed on system) I tested with the free fonts from http://www.gust.org.pl/projects/e-foundry/tex-gyre - Cut text into solid * Change docstring to fix autodoc-typehints issue where the Parameters section is duplicated (see screenshot) * Update cadquery/cq.py Co-authored-by: Marcus Boyd <[email protected]> * Update cadquery/cq.py Co-authored-by: Marcus Boyd <[email protected]> * Update cadquery/cq.py Co-authored-by: Marcus Boyd <[email protected]> * Update cadquery/cq.py Co-authored-by: Marcus Boyd <[email protected]> * Update cadquery/cq.py Co-authored-by: Marcus Boyd <[email protected]> * Update cadquery/cq.py Co-authored-by: Marcus Boyd <[email protected]> * Update cadquery/cq.py Co-authored-by: Marcus Boyd <[email protected]> * Update cadquery/cq.py Co-authored-by: Marcus Boyd <[email protected]> * Update cadquery/cq.py Co-authored-by: Marcus Boyd <[email protected]> * Update cadquery/cq.py Co-authored-by: Marcus Boyd <[email protected]> Co-authored-by: Marcus Boyd <[email protected]>
1 parent ab876ac commit 8dc1a5c

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

cadquery/cq.py

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3919,28 +3919,43 @@ def text(
39193919
"""
39203920
Create a 3D text
39213921
3922-
:param str txt: text to be rendered
3923-
:param distance: the distance to extrude, normal to the workplane plane
3922+
:param txt: text to be rendered
3923+
:param fontsize: size of the font in model units
3924+
:param distance: the distance to extrude or cut, normal to the workplane plane
39243925
:type distance: float, negative means opposite the normal direction
3925-
:param float fontsize: size of the font
3926-
:param boolean cut: True to cut the resulting solid from the parent solids if found.
3927-
:param boolean combine: True to combine the resulting solid with parent solids if found.
3928-
:param boolean clean: call :py:meth:`clean` afterwards to have a clean shape
3929-
:param str font: fontname (default: Arial)
3930-
:param str kind: font type (default: Normal)
3931-
:param str halign: horizontal alignment (default: center)
3932-
:param str valign: vertical alignment (default: center)
3933-
:return: a CQ object with the resulting solid selected.
3934-
3935-
extrude always *adds* material to a part.
3936-
3937-
The returned object is always a CQ object, and depends on whether combine is True, and
3926+
:param cut: True to cut the resulting solid from the parent solids if found
3927+
:param combine: True to combine the resulting solid with parent solids if found
3928+
:param clean: call :py:meth:`clean` afterwards to have a clean shape
3929+
:param font: font name
3930+
:param fontPath: path to font file
3931+
:param kind: font type
3932+
:param halign: horizontal alignment
3933+
:param valign: vertical alignment
3934+
:return: a CQ object with the resulting solid selected
3935+
3936+
The returned object is always a Workplane object, and depends on whether combine is True, and
39383937
whether a context solid is already defined:
39393938
39403939
* if combine is False, the new value is pushed onto the stack.
39413940
* if combine is true, the value is combined with the context solid if it exists,
39423941
and the resulting solid becomes the new context solid.
39433942
3943+
Examples::
3944+
3945+
cq.Workplane().text("CadQuery", 5, 1)
3946+
3947+
Specify the font (name), and kind to use an installed system font::
3948+
3949+
cq.Workplane().text("CadQuery", 5, 1, font="Liberation Sans Narrow", kind="italic")
3950+
3951+
Specify fontPath to use a font from a given file::
3952+
3953+
cq.Workplane().text("CadQuery", 5, 1, fontPath="/opt/fonts/texgyrecursor-bold.otf")
3954+
3955+
Cutting text into a solid::
3956+
3957+
cq.Workplane().box(8, 8, 8).faces(">Z").workplane().text("Z", 5, -1.0)
3958+
39443959
"""
39453960
r = Compound.makeText(
39463961
txt,

0 commit comments

Comments
 (0)