| 2889 | overset = underset = _genset |
| 2890 | |
| 2891 | def sqrt(self, toks: ParseResults) -> T.Any: |
| 2892 | root = toks.get("root") |
| 2893 | body = toks["value"] |
| 2894 | state = self.get_state() |
| 2895 | thickness = state.get_current_underline_thickness() |
| 2896 | |
| 2897 | # Determine the height of the body, and add a little extra to |
| 2898 | # the height so it doesn't seem cramped |
| 2899 | height = body.height - body.shift_amount + 5 * thickness |
| 2900 | depth = body.depth + body.shift_amount |
| 2901 | check = AutoHeightChar(r'\__sqrt__', height, depth, state) |
| 2902 | height = check.height - check.shift_amount |
| 2903 | depth = check.depth + check.shift_amount |
| 2904 | |
| 2905 | # Put a little extra space to the left and right of the body |
| 2906 | padded_body = Hlist([Hbox(2 * thickness), body, Hbox(2 * thickness)]) |
| 2907 | rightside = Vlist([Hrule(state), Glue('fill'), padded_body]) |
| 2908 | # Stretch the glue between the hrule and the body |
| 2909 | rightside.vpack(height + (state.fontsize * state.dpi) / (100 * 12), |
| 2910 | 'exactly', depth) |
| 2911 | |
| 2912 | # Add the root and shift it upward so it is above the tick. |
| 2913 | # The value of 0.6 is a hard-coded hack ;) |
| 2914 | if not root: |
| 2915 | root = Box(0.5 * check.width, 0., 0.) |
| 2916 | else: |
| 2917 | root = Hlist(root) |
| 2918 | root.shrink() |
| 2919 | root.shrink() |
| 2920 | |
| 2921 | root_vlist = Vlist([Hlist([root])]) |
| 2922 | root_vlist.shift_amount = -height * 0.6 |
| 2923 | |
| 2924 | hlist = Hlist([ |
| 2925 | root_vlist, # Root |
| 2926 | Kern(-0.5 * check.width), # Negative kerning to put root over tick |
| 2927 | check, # Check |
| 2928 | rightside, # Body |
| 2929 | ]) |
| 2930 | return [hlist] |
| 2931 | |
| 2932 | def overline(self, toks: ParseResults) -> T.Any: |
| 2933 | body = toks["body"] |