MCPcopy
hub / github.com/CadQuery/cadquery / text

Method text

cadquery/cq.py:4239–4313  ·  view source on GitHub ↗

Returns a 3D text. :param txt: text to be rendered :param fontsize: size of the font in model units :param distance: the distance to extrude or cut, normal to the workplane plane :type distance: float, negative means opposite the normal direction :pa

(
        self: T,
        txt: str,
        fontsize: float,
        distance: float,
        combine: CombineMode = "cut",
        clean: bool = True,
        font: str = "Arial",
        fontPath: Optional[str] = None,
        kind: Literal["regular", "bold", "italic"] = "regular",
        halign: Literal["center", "left", "right"] = "center",
        valign: Literal["center", "top", "bottom"] = "center",
    )

Source from the content-addressed store, hash-verified

4237 return self.newObject(cleanObjects)
4238
4239 def text(
4240 self: T,
4241 txt: str,
4242 fontsize: float,
4243 distance: float,
4244 combine: CombineMode = "cut",
4245 clean: bool = True,
4246 font: str = "Arial",
4247 fontPath: Optional[str] = None,
4248 kind: Literal["regular", "bold", "italic"] = "regular",
4249 halign: Literal["center", "left", "right"] = "center",
4250 valign: Literal["center", "top", "bottom"] = "center",
4251 ) -> T:
4252 """
4253 Returns a 3D text.
4254
4255 :param txt: text to be rendered
4256 :param fontsize: size of the font in model units
4257 :param distance: the distance to extrude or cut, normal to the workplane plane
4258 :type distance: float, negative means opposite the normal direction
4259 :param combine: True or "a" to combine the resulting solid with parent solids if found,
4260 "cut" or "s" to remove the resulting solid from the parent solids if found.
4261 False to keep the resulting solid separated from the parent solids.
4262 :param clean: call :meth:`clean` afterwards to have a clean shape
4263 :param font: font name
4264 :param fontPath: path to font file
4265 :param kind: font type
4266 :param halign: horizontal alignment
4267 :param valign: vertical alignment
4268 :return: a CQ object with the resulting solid selected
4269
4270 The returned object is always a Workplane object, and depends on whether combine is True, and
4271 whether a context solid is already defined:
4272
4273 * if combine is False, the new value is pushed onto the stack.
4274 * if combine is True, "a", "cut" or "s", the value is combined with the context solid if it exists,
4275 and the resulting solid becomes the new context solid.
4276
4277 Examples::
4278
4279 Create text::
4280
4281 cq.Workplane().text("CadQuery", 5, 1)
4282
4283 Specify the font (name), and kind to use an installed system font::
4284
4285 cq.Workplane().text("CadQuery", 5, 1, font="Liberation Sans Narrow", kind="italic")
4286
4287 Specify fontPath to use a font from a given file::
4288
4289 cq.Workplane().text("CadQuery", 5, 1, fontPath="/opt/fonts/texgyrecursor-bold.otf")
4290
4291 Cut text from a solid (default behavior when context solid exists and combine is not overridden)::
4292
4293 cq.Workplane().box(8, 8, 8).faces(">Z").workplane().text("Z", 5, -1.0)
4294
4295 Add text to a solid::
4296

Callers 4

test_dxf_textFunction · 0.80
testTextMethod · 0.80
testTextAlignmentMethod · 0.80
vtk.jsFile · 0.80

Calls 2

_combineWithBaseMethod · 0.95
makeTextMethod · 0.80

Tested by 3

test_dxf_textFunction · 0.64
testTextMethod · 0.64
testTextAlignmentMethod · 0.64