Is there any good way to find the largest rectangular area in any irregular closed path
Is there any good way to find the largest rectangular area in any irregular closed path? Because, I need to mark a number in this closed path area, and the number cannot overlap the edge of the path.

see: Figure 1 is a closed path. I want to mark numbers on it. Figures 2 and 3 are wrong because the numbers are pressing on the edge of the path. Figures 3, 4, and 5 are all correct. I can only get the segment of each Bezier curve of the closed path, so how can I calculate the correct marker position?