import matplotlib.pyplot as plt from matplotlib.path import Path import matplotlib.patches as patches # Define the segments: each tuple is (segment_type, list_of_points) segments = [ ("cubic", [(253.0, 675.0), (226.0, 668.0), (191.0, 652.0), (169.0, 638.0)]), ("cubic", [(169.0, 638.0), (113.0, 601.0), (64.0, 543.0), (64.0, 457.0)]), ("cubic", [(64.0, 457.0), (64.0, 396.0), (86.0, 345.0), (132.0, 277.0)]), ("cubic", [(132.0, 277.0), (149.0, 257.0), (210.0, 171.0), (216.0, 161.0)]), ("cubic", [(216.0, 161.0), (226.0, 147.0), (241.0, 120.0), (241.0, 119.0)]), ("cubic", [(241.0, 119.0), (241.0, 118.0), (225.0, 118.0), (202.0, 118.0)]), ("cubic", [(202.0, 118.0), (159.0, 119.0), (151.0, 120.0), (140.0, 125.0)]), ("cubic", [(140.0, 125.0), (135.0, 128.0), (134.0, 129.0), (132.0, 133.0)]), ("cubic", [(132.0, 133.0), (127.0, 142.0), (122.0, 164.0), (116.0, 195.0)]), ("cubic", [(116.0, 195.0), (115.0, 203.0), (114.0, 211.0), (113.0, 212.0)]), ("line", [(113.0, 212.0), (113.0, 215.0)]), ("line", [(113.0, 215.0), (51.0, 215.0)]), ("line", [(51.0, 215.0), (51.0, 212.0)]), ("cubic", [(51.0, 212.0), (52.0, 211.0), (60.0, 164.0), (70.0, 108.0)]), ("cubic", [(70.0, 108.0), (79.0, 51.0), (87.0, 4.0), (88.0, 3.0)]), ("line", [(88.0, 3.0), (88.0, 0.0)]), ("line", [(88.0, 0.0), (196.0, 0.0)]), ("cubic", [(196.0, 0.0), (290.0, 0.0), (304.0, 0.0), (307.0, 2.0)]), ("cubic", [(307.0, 2.0), (315.0, 5.0), (318.0, 10.0), (318.0, 26.0)]), ("cubic", [(318.0, 26.0), (318.0, 32.0), (318.0, 40.0), (317.0, 49.0)]), ("cubic", [(317.0, 49.0), (313.0, 100.0), (303.0, 145.0), (275.0, 242.0)]), ("cubic", [(275.0, 242.0), (254.0, 312.0), (246.0, 341.0), (240.0, 375.0)]), ("cubic", [(240.0, 375.0), (235.0, 404.0), (232.0, 432.0), (232.0, 458.0)]), ("cubic", [(232.0, 458.0), (232.0, 581.0), (292.0, 645.0), (415.0, 645.0)]), ("cubic", [(415.0, 645.0), (538.0, 645.0), (598.0, 581.0), (598.0, 458.0)]), ("cubic", [(598.0, 458.0), (598.0, 432.0), (595.0, 404.0), (590.0, 375.0)]), ("cubic", [(590.0, 375.0), (584.0, 341.0), (576.0, 312.0), (555.0, 242.0)]), ("cubic", [(555.0, 242.0), (527.0, 145.0), (517.0, 100.0), (513.0, 49.0)]), ("cubic", [(513.0, 49.0), (512.0, 40.0), (512.0, 32.0), (512.0, 26.0)]), ("cubic", [(512.0, 26.0), (512.0, 10.0), (515.0, 5.0), (523.0, 2.0)]), ("cubic", [(523.0, 2.0), (526.0, 0.0), (540.0, 0.0), (634.0, 0.0)]), ("line", [(634.0, 0.0), (742.0, 0.0)]), ("line", [(742.0, 0.0), (742.0, 3.0)]), ("cubic", [(742.0, 3.0), (743.0, 4.0), (751.0, 51.0), (760.0, 108.0)]), ("cubic", [(760.0, 108.0), (770.0, 164.0), (778.0, 211.0), (779.0, 212.0)]), ("line", [(779.0, 212.0), (779.0, 215.0)]), ("line", [(779.0, 215.0), (717.0, 215.0)]), ("line", [(717.0, 215.0), (717.0, 212.0)]), ("cubic", [(717.0, 212.0), (716.0, 211.0), (715.0, 203.0), (714.0, 195.0)]), ("cubic", [(714.0, 195.0), (708.0, 164.0), (703.0, 142.0), (698.0, 133.0)]), ("cubic", [(698.0, 133.0), (696.0, 129.0), (695.0, 128.0), (690.0, 125.0)]), ("cubic", [(690.0, 125.0), (679.0, 120.0), (671.0, 119.0), (628.0, 118.0)]), ("cubic", [(628.0, 118.0), (605.0, 118.0), (589.0, 118.0), (589.0, 119.0)]), ("cubic", [(589.0, 119.0), (589.0, 120.0), (604.0, 147.0), (614.0, 161.0)]), ("cubic", [(614.0, 161.0), (620.0, 170.0), (682.0, 257.0), (698.0, 277.0)]), ("cubic", [(698.0, 277.0), (735.0, 331.0), (755.0, 375.0), (763.0, 421.0)]), ("cubic", [(763.0, 421.0), (765.0, 431.0), (766.0, 445.0), (766.0, 458.0)]), ("cubic", [(766.0, 458.0), (766.0, 465.0), (766.0, 472.0), (765.0, 477.0)]), ("cubic", [(765.0, 477.0), (758.0, 543.0), (720.0, 600.0), (661.0, 638.0)]), ("cubic", [(661.0, 638.0), (589.0, 679.0), (520.0, 696.0), (403.0, 696.0)]), ("cubic", [(403.0, 696.0), (340.0, 696.0), (294.0, 688.0), (253.0, 675.0)]) ] # Build the complete list of vertices and corresponding path codes. vertices = [] codes = [] # Begin at the first point of the first segment. start_point = segments[0][1][0] vertices.append(start_point) codes.append(Path.MOVETO) for seg_type, pts in segments: if seg_type == "cubic": # For a cubic segment, add the three control/end points. for p in pts[1:]: vertices.append(p) codes.append(Path.CURVE4) elif seg_type == "line": # For a line segment, add the destination point. vertices.append(pts[1]) codes.append(Path.LINETO) # Create the Path and a patch to draw it. path = Path(vertices, codes) patch = patches.PathPatch(path, facecolor='none', lw=2, edgecolor='blue') # Set up the plot. fig, ax = plt.subplots() ax.add_patch(patch) # Optionally, plot the anchor points for clarity. x, y = zip(*vertices) ax.plot(x, y, 'ro') # red dots at the vertices ax.set_aspect('equal') ax.set_title("Omega (U+03A9) Glyph from MathJax_Main-Bold.otf") ax.set_xlim(0, 800) ax.set_ylim(-50, 750) plt.show()