mirror of
https://github.com/gumyr/build123d.git
synced 2026-01-30 04:10:34 -08:00
Refactor fontsize to font_size
This commit is contained in:
parent
593ca4719e
commit
2ef354b1ff
9 changed files with 28 additions and 28 deletions
|
|
@ -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]
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue