From 2ef354b1ffa6fdcc1f271fa4924de5c8abb73322 Mon Sep 17 00:00:00 2001 From: Roger Maitland Date: Fri, 3 Mar 2023 21:20:21 -0500 Subject: [PATCH] Refactor fontsize to font_size --- docs/general_examples.py | 4 ++-- examples/build123d_customizable_logo.py | 10 +++++----- examples/build123d_logo.py | 8 ++++---- examples/clock.py | 2 +- examples/extrude.py | 6 +++--- src/build123d/build_sketch.py | 8 ++++---- src/build123d/topology.py | 14 +++++++------- tests/test_build_sketch.py | 2 +- tests/test_direct_api.py | 2 +- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/general_examples.py b/docs/general_examples.py index 634fe3b..e328662 100644 --- a/docs/general_examples.py +++ b/docs/general_examples.py @@ -796,10 +796,10 @@ with BuildPart() as ex34: Box(length, width, thickness) topf = ex34.faces().sort_by(Axis.Z)[-1] with BuildSketch(topf) as ex34_sk: - Text("Hello", fontsize=fontsz, align=(Align.CENTER, Align.MIN)) + Text("Hello", font_size=fontsz, align=(Align.CENTER, Align.MIN)) Extrude(amount=fontht) with BuildSketch(topf) as ex34_sk2: - Text("World", fontsize=fontsz, align=(Align.CENTER, Align.MAX)) + Text("World", font_size=fontsz, align=(Align.CENTER, Align.MAX)) Extrude(amount=-fontht, mode=Mode.SUBTRACT) # [Ex. 34] diff --git a/examples/build123d_customizable_logo.py b/examples/build123d_customizable_logo.py index 7c09caa..386d077 100644 --- a/examples/build123d_customizable_logo.py +++ b/examples/build123d_customizable_logo.py @@ -27,11 +27,11 @@ license: from build123d import * with BuildSketch() as logo_text: - Text("123d", fontsize=10, align=(Align.MIN, Align.MIN)) + Text("123d", font_size=10, align=(Align.MIN, Align.MIN)) font_height = logo_text.vertices().sort_by(Axis.Y)[-1].Y with BuildSketch() as build_text: - Text("build", fontsize=5, align=(Align.CENTER, Align.CENTER)) + Text("build", font_size=5, align=(Align.CENTER, Align.CENTER)) build_bb = BoundingBox(build_text.sketch, mode=Mode.PRIVATE) build_vertices = build_bb.vertices().sort_by(Axis.X) build_width = build_vertices[-1].X - build_vertices[0].X @@ -39,7 +39,7 @@ with BuildSketch() as build_text: with BuildSketch() as cust_text: Text( "customizable", - fontsize=2.9, + font_size=2.9, align=(Align.CENTER, Align.CENTER), font_style=FontStyle.BOLD, ) @@ -53,12 +53,12 @@ with BuildLine() as one: with BuildSketch() as two: with Locations((font_height * 0.35, 0)): - Text("2", fontsize=10, align=(Align.MIN, Align.MIN)) + Text("2", font_size=10, align=(Align.MIN, Align.MIN)) with BuildPart() as three_d: with Locations((font_height * 1.1, 0)): with BuildSketch(): - Text("3d", fontsize=10, align=(Align.MIN, Align.MIN)) + Text("3d", font_size=10, align=(Align.MIN, Align.MIN)) Extrude(amount=font_height * 0.3) logo_width = three_d.vertices().sort_by(Axis.X)[-1].X diff --git a/examples/build123d_logo.py b/examples/build123d_logo.py index d989ab2..e4bf4a8 100644 --- a/examples/build123d_logo.py +++ b/examples/build123d_logo.py @@ -27,11 +27,11 @@ license: from build123d import * with BuildSketch() as logo_text: - Text("123d", fontsize=10, align=(Align.MIN, Align.MIN)) + Text("123d", font_size=10, align=(Align.MIN, Align.MIN)) font_height = logo_text.vertices().sort_by(Axis.Y)[-1].Y with BuildSketch() as build_text: - Text("build", fontsize=5, align=(Align.CENTER, Align.CENTER)) + Text("build", font_size=5, align=(Align.CENTER, Align.CENTER)) build_bb = BoundingBox(build_text.sketch, mode=Mode.PRIVATE) build_vertices = build_bb.vertices().sort_by(Axis.X) build_width = build_vertices[-1].X - build_vertices[0].X @@ -42,12 +42,12 @@ with BuildLine() as one: with BuildSketch() as two: with Locations((font_height * 0.35, 0)): - Text("2", fontsize=10, align=(Align.MIN, Align.MIN)) + Text("2", font_size=10, align=(Align.MIN, Align.MIN)) with BuildPart() as three_d: with Locations((font_height * 1.1, 0)): with BuildSketch(): - Text("3d", fontsize=10, align=(Align.MIN, Align.MIN)) + Text("3d", font_size=10, align=(Align.MIN, Align.MIN)) Extrude(amount=font_height * 0.3) logo_width = three_d.vertices().sort_by(Axis.X)[-1].X diff --git a/examples/clock.py b/examples/clock.py index ded69ce..6370938 100644 --- a/examples/clock.py +++ b/examples/clock.py @@ -46,7 +46,7 @@ with BuildSketch() as clock_face: with PolarLocations(clock_radius * 0.75, 1, -hour * 30 + 90, 360, rotate=False): Text( str(hour), - fontsize=clock_radius * 0.175, + font_size=clock_radius * 0.175, font_style=FontStyle.BOLD, mode=Mode.SUBTRACT, ) diff --git a/examples/extrude.py b/examples/extrude.py index 0d9eee6..3d5cce5 100644 --- a/examples/extrude.py +++ b/examples/extrude.py @@ -30,13 +30,13 @@ from build123d import * # Extrude pending face by amount with BuildPart() as simple: with BuildSketch(): - Text("O", fontsize=10) + Text("O", font_size=10) Extrude(amount=5) # Extrude pending face in both directions by amount with BuildPart() as both: with BuildSketch(): - Text("O", fontsize=10) + Text("O", font_size=10) Extrude(amount=5, both=True) # Extrude multiple pending faces on multiple faces @@ -45,7 +45,7 @@ with BuildPart() as multiple: with Workplanes(*multiple.faces()): with GridLocations(5, 5, 2, 2): with BuildSketch(): - Text("Ω", fontsize=3) + Text("Ω", font_size=3) Extrude(amount=1) # Non-planar surface diff --git a/src/build123d/build_sketch.py b/src/build123d/build_sketch.py index d01fab7..1f090df 100644 --- a/src/build123d/build_sketch.py +++ b/src/build123d/build_sketch.py @@ -734,7 +734,7 @@ class Text(BaseSketchObject): Args: txt (str): text to be rendered - fontsize (float): size of the font in model units + font_size (float): size of the font in model units font (str, optional): font name. Defaults to "Arial". font_path (str, optional): system path to font library. Defaults to None. font_style (Font_Style, optional): style. Defaults to Font_Style.REGULAR. @@ -752,7 +752,7 @@ class Text(BaseSketchObject): def __init__( self, txt: str, - fontsize: float, + font_size: float, font: str = "Arial", font_path: str = None, font_style: FontStyle = FontStyle.REGULAR, @@ -766,7 +766,7 @@ class Text(BaseSketchObject): context.validate_inputs(self) self.txt = txt - self.fontsize = fontsize + self.font_size = font_size self.font = font self.font_path = font_path self.font_style = font_style @@ -778,7 +778,7 @@ class Text(BaseSketchObject): text_string = Compound.make_text( txt=txt, - fontsize=fontsize, + font_size=font_size, font=font, font_path=font_path, font_style=font_style, diff --git a/src/build123d/topology.py b/src/build123d/topology.py index 7da7b28..fe9358d 100644 --- a/src/build123d/topology.py +++ b/src/build123d/topology.py @@ -2971,7 +2971,7 @@ class Compound(Shape, Mixin3D): def make_text( cls, txt: str, - fontsize: float, + font_size: float, font: str = "Arial", font_path: Optional[str] = None, font_style: FontStyle = FontStyle.REGULAR, @@ -2988,7 +2988,7 @@ class Compound(Shape, Mixin3D): Args: txt: text to be rendered - fontsize: size of the font in model units + font_size: size of the font in model units font: font name font_path: path to font file font_style: text style. Defaults to FontStyle.REGULAR. @@ -3005,7 +3005,7 @@ class Compound(Shape, Mixin3D): fox = Compound.make_text( txt="The quick brown fox jumped over the lazy dog", - fontsize=10, + font_size=10, position_on_path=0.1, text_path=jump_edge, ) @@ -3057,7 +3057,7 @@ class Compound(Shape, Mixin3D): font_i = StdPrs_BRepFont( NCollection_Utf8String(font_t.FontName().ToCString()), font_kind, - float(fontsize), + float(font_size), ) text_flat = Compound(builder.Perform(font_i, NCollection_Utf8String(txt))) @@ -6043,14 +6043,14 @@ class SVG: arrow = arrow_arc.fuse(copy.copy(arrow_arc).mirror(Plane.XZ)) x_label = ( Compound.make_text( - "X", fontsize=axes_scale / 4, align=(Align.MIN, Align.CENTER) + "X", font_size=axes_scale / 4, align=(Align.MIN, Align.CENTER) ) .move(Location(x_axis @ 1)) .edges() ) y_label = ( Compound.make_text( - "Y", fontsize=axes_scale / 4, align=(Align.MIN, Align.CENTER) + "Y", font_size=axes_scale / 4, align=(Align.MIN, Align.CENTER) ) .rotate(Axis.Z, 90) .move(Location(y_axis @ 1)) @@ -6058,7 +6058,7 @@ class SVG: ) z_label = ( Compound.make_text( - "Z", fontsize=axes_scale / 4, align=(Align.CENTER, Align.MIN) + "Z", font_size=axes_scale / 4, align=(Align.CENTER, Align.MIN) ) .rotate(Axis.Y, 90) .rotate(Axis.X, 90) diff --git a/tests/test_build_sketch.py b/tests/test_build_sketch.py index d589181..4fa2021 100644 --- a/tests/test_build_sketch.py +++ b/tests/test_build_sketch.py @@ -285,7 +285,7 @@ class TestBuildSketchObjects(unittest.TestCase): with BuildSketch() as test: t = Text("test", 2) self.assertEqual(t.txt, "test") - self.assertEqual(t.fontsize, 2) + self.assertEqual(t.font_size, 2) self.assertEqual(t.font, "Arial") self.assertIsNone(t.font_path) self.assertEqual(t.font_style, FontStyle.REGULAR) diff --git a/tests/test_direct_api.py b/tests/test_direct_api.py index c2fd8b3..a857c2c 100644 --- a/tests/test_direct_api.py +++ b/tests/test_direct_api.py @@ -2043,7 +2043,7 @@ class TestProjection(unittest.TestCase): ) projected_text = sphere.project_faces( - faces=Compound.make_text("dog", fontsize=14), + faces=Compound.make_text("dog", font_size=14), path=arch_path, ) self.assertEqual(len(projected_text.solids()), 0)