@@ -264,12 +264,23 @@ fn path_commands_to_py(
264264 match cmd {
265265 PathCommand :: MoveTo ( x, y) => ( "M" , x, y) . into_pyobject ( py) . unwrap ( ) . into_any ( ) . unbind ( ) ,
266266 PathCommand :: LineTo ( x, y) => ( "L" , x, y) . into_pyobject ( py) . unwrap ( ) . into_any ( ) . unbind ( ) ,
267- PathCommand :: QuadTo { cx, cy, x, y } => {
268- ( "Q" , cx, cy, x, y) . into_pyobject ( py) . unwrap ( ) . into_any ( ) . unbind ( )
269- }
270- PathCommand :: CubicTo { cx1, cy1, cx2, cy2, x, y } => {
271- ( "C" , cx1, cy1, cx2, cy2, x, y) . into_pyobject ( py) . unwrap ( ) . into_any ( ) . unbind ( )
272- }
267+ PathCommand :: QuadTo { cx, cy, x, y } => ( "Q" , cx, cy, x, y)
268+ . into_pyobject ( py)
269+ . unwrap ( )
270+ . into_any ( )
271+ . unbind ( ) ,
272+ PathCommand :: CubicTo {
273+ cx1,
274+ cy1,
275+ cx2,
276+ cy2,
277+ x,
278+ y,
279+ } => ( "C" , cx1, cy1, cx2, cy2, x, y)
280+ . into_pyobject ( py)
281+ . unwrap ( )
282+ . into_any ( )
283+ . unbind ( ) ,
273284 PathCommand :: Close => ( "Z" , ) . into_pyobject ( py) . unwrap ( ) . into_any ( ) . unbind ( ) ,
274285 }
275286 } ;
@@ -1018,7 +1029,11 @@ impl Graphics {
10181029 let h: f32 = args. get_item ( 2 ) ?. extract ( ) ?;
10191030 ( z, Some ( w) , Some ( h) )
10201031 }
1021- _ => return Err ( PyRuntimeError :: new_err ( "text() takes 3-6 positional arguments" ) ) ,
1032+ _ => {
1033+ return Err ( PyRuntimeError :: new_err (
1034+ "text() takes 3-6 positional arguments" ,
1035+ ) ) ;
1036+ }
10221037 } ;
10231038 graphics_record_command (
10241039 self . entity ,
@@ -1035,8 +1050,7 @@ impl Graphics {
10351050 }
10361051
10371052 pub fn text_style ( & self , style : u8 ) -> PyResult < ( ) > {
1038- graphics_text_style ( self . entity , style)
1039- . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) )
1053+ graphics_text_style ( self . entity , style) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) )
10401054 }
10411055
10421056 #[ pyo3( signature = ( content, x, y, max_w=None , max_h=None ) ) ]
@@ -1106,12 +1120,7 @@ impl Graphics {
11061120 /// Extract glyph outlines as path commands (one list per glyph).
11071121 /// Each command is a tuple: ("M", x, y), ("L", x, y), ("Q", cx, cy, x, y),
11081122 /// ("C", cx1, cy1, cx2, cy2, x, y), or ("Z",).
1109- pub fn text_to_paths (
1110- & self ,
1111- content : & str ,
1112- x : f32 ,
1113- y : f32 ,
1114- ) -> PyResult < Vec < Vec < Py < PyAny > > > > {
1123+ pub fn text_to_paths ( & self , content : & str , x : f32 , y : f32 ) -> PyResult < Vec < Vec < Py < PyAny > > > > {
11151124 let paths = graphics_text_to_paths ( self . entity , content, x, y)
11161125 . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
11171126 Python :: attach ( |py| Ok ( path_commands_to_py ( py, paths) ) )
@@ -1120,12 +1129,7 @@ impl Graphics {
11201129 /// Extract glyph outlines as per-contour path commands.
11211130 /// Each contour (MoveTo...Close sequence) is a separate list.
11221131 /// Commands use the same tuple shapes as `text_to_paths`.
1123- pub fn text_to_contours (
1124- & self ,
1125- content : & str ,
1126- x : f32 ,
1127- y : f32 ,
1128- ) -> PyResult < Vec < Vec < Py < PyAny > > > > {
1132+ pub fn text_to_contours ( & self , content : & str , x : f32 , y : f32 ) -> PyResult < Vec < Vec < Py < PyAny > > > > {
11291133 let contours = graphics_text_to_contours ( self . entity , content, x, y)
11301134 . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
11311135 Python :: attach ( |py| Ok ( path_commands_to_py ( py, contours) ) )
@@ -1146,17 +1150,11 @@ impl Graphics {
11461150 }
11471151
11481152 /// Generate a 3D extruded mesh from text outlines.
1149- pub fn text_to_model (
1150- & self ,
1151- content : & str ,
1152- x : f32 ,
1153- y : f32 ,
1154- depth : f32 ,
1155- ) -> PyResult < Geometry > {
1153+ pub fn text_to_model ( & self , content : & str , x : f32 , y : f32 , depth : f32 ) -> PyResult < Geometry > {
11561154 let mesh = graphics_text_to_model ( self . entity , content, x, y, depth)
11571155 . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
1158- let entity = geometry_create_from_mesh ( mesh )
1159- . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
1156+ let entity =
1157+ geometry_create_from_mesh ( mesh ) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
11601158 Ok ( Geometry { entity } )
11611159 }
11621160
@@ -1251,13 +1249,11 @@ impl Graphics {
12511249 }
12521250
12531251 pub fn text_ascent ( & self ) -> PyResult < f32 > {
1254- graphics_text_ascent ( self . entity )
1255- . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) )
1252+ graphics_text_ascent ( self . entity ) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) )
12561253 }
12571254
12581255 pub fn text_descent ( & self ) -> PyResult < f32 > {
1259- graphics_text_descent ( self . entity )
1260- . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) )
1256+ graphics_text_descent ( self . entity ) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) )
12611257 }
12621258
12631259 /// Loads an image from a file and returns an Image object.
0 commit comments