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

Method testText

tests/test_cadquery.py:3850–3935  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3848 self.assertAlmostEqual(obj1.val().Volume(), obj2.val().Volume())
3849
3850 def testText(self):
3851 global testdataDir
3852
3853 box = Workplane("XY").box(4, 4, 0.5)
3854
3855 obj1 = (
3856 box.faces(">Z")
3857 .workplane()
3858 .text("CQ 2.0", 0.5, -0.05, halign="left", valign="bottom", font="Sans",)
3859 )
3860
3861 # combined object should have smaller volume
3862 self.assertGreater(box.val().Volume(), obj1.val().Volume())
3863
3864 obj2 = (
3865 box.faces(">Z")
3866 .workplane()
3867 .text("CQ 2.0", 0.5, 0.05, combine=True, font="Sans")
3868 )
3869
3870 # combined object should have bigger volume
3871 self.assertLess(box.val().Volume(), obj2.val().Volume())
3872
3873 # verify that the number of top faces is correct (NB: this is font specific)
3874 self.assertEqual(len(obj2.faces(">Z").vals()), 5)
3875
3876 obj3 = (
3877 box.faces(">Z")
3878 .workplane()
3879 .text(
3880 "CQ 2.0",
3881 0.5,
3882 0.05,
3883 combine=False,
3884 halign="right",
3885 valign="top",
3886 font="Sans",
3887 )
3888 )
3889
3890 # verify that the number of solids is correct
3891 self.assertEqual(len(obj3.solids().vals()), 5)
3892
3893 obj4 = (
3894 box.faces(">Z")
3895 .workplane()
3896 .text(
3897 "CQ 2.0",
3898 0.5,
3899 0.05,
3900 fontPath=testFont,
3901 combine=False,
3902 halign="right",
3903 valign="top",
3904 font="Sans",
3905 )
3906 )
3907

Callers

nothing calls this directly

Calls 9

WorkplaneClass · 0.85
boxMethod · 0.80
textMethod · 0.80
workplaneMethod · 0.80
VolumeMethod · 0.80
facesMethod · 0.45
valMethod · 0.45
valsMethod · 0.45
solidsMethod · 0.45

Tested by

no test coverage detected