Commit 65d03b7
committed
Fix text wrap width on figure edges (#31537)
Text with wrap=True at an axis-aligned rotation on the matching figure
edge collapsed to zero wrap width. In _get_dist_to_box the trig formula
divides by cos(radians(90)) (~6e-17): normally that term's large value
loses the min() to the sensible other side, but when the position sits
exactly on the edge its numerator is also zero and the returned
distance is zero.
Short-circuit cardinal rotations. Also normalize rotation to [0, 360)
with a small absolute tolerance so near-cardinal angles coming out of
transform_angles (e.g. -90.00000000000003 via transform_rotates_text)
still take the fast path instead of blowing up in the trig formula.
Regression tests cover each cardinal rotation on its broken edge plus
a transform_rotates_text case.1 parent e964783 commit 65d03b7
2 files changed
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
762 | 803 | | |
763 | 804 | | |
764 | 805 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
746 | 761 | | |
747 | 762 | | |
748 | 763 | | |
| |||
0 commit comments