@@ -27,14 +27,6 @@ function tex_layout(expr, state)
2727 if head in [:char , :delimiter , :digit , :punctuation , :symbol ]
2828 char = args[1 ]
2929 texchar = TeXChar (char, state, head)
30-
31- if char == ' °'
32- return Group (
33- [texchar],
34- [Point2f (- 0.2 , 0 )],
35- [1 ]
36- )
37- end
3830 return texchar
3931 elseif head == :combining_accent
4032 accent, core = tex_layout .(args, state)
@@ -52,21 +44,20 @@ function tex_layout(expr, state)
5244 [core, accent],
5345 Point2f[
5446 (0 , 0 ),
55- (x + hmid (core) - hmid (accent), y )
47+ (x + hmid (core) - hmid (accent), 0 )
5648 ],
5749 [1 , 1 ]
5850 )
5951 elseif head == :decorated
6052 core, sub, super = tex_layout .(args, state)
61-
62- core_width = hadvance (core)
6353
54+ # Should be a bit smarter for slanted font
6455 return Group (
6556 [core, sub, super],
6657 Point2f[
6758 (0 , 0 ),
68- (core_width , - 0.2 ),
69- (core_width , 0.8 * xheight (core))],
59+ (rightinkbound (core) + 0.1 , - 0.2 ),
60+ (rightinkbound (core) + 0.1 , 0.9 * xheight (core))],
7061 [1 , shrink, shrink]
7162 )
7263 elseif head == :delimited
@@ -129,26 +120,19 @@ function tex_layout(expr, state)
129120 return horizontal_layout (elements)
130121 elseif head == :integral
131122 pad = 0.1
132- sub, super = tex_layout .(args[2 : 3 ], state)
133-
134- # Always use ComputerModern fallback for the integral sign
135- # as the Unicode LaTeX approach requires to use glyph variant
136- # which is unlikely to be supported by backends
137- intfont = load_font (joinpath (" ComputerModern" , " cmex10.ttf" ))
138- int = TeXChar (Char (0x5a ), intfont)
139- h = inkheight (int)
123+ int, sub, super = tex_layout .(args, state)
140124
141125 return Group (
142126 [int, sub, super],
143127 Point2f[
144- (0 , y_for_centered (font_family, int) ),
128+ (0 , 0 ),
145129 (
146130 0.15 - inkwidth (sub)* shrink/ 2 ,
147- - h / 2 + xheight (font_family) / 2 - topinkbound (sub)* shrink - pad
131+ bottominkbound (int) - topinkbound (sub)* shrink - pad
148132 ),
149133 (
150134 0.85 - inkwidth (super)* shrink/ 2 ,
151- h / 2 + xheight (font_family) / 2 + pad
135+ topinkbound (int) + pad
152136 )
153137 ],
154138 [1 , shrink, shrink]
@@ -160,27 +144,24 @@ function tex_layout(expr, state)
160144 return horizontal_layout ([Space (0.2 ), sym, Space (0.2 )])
161145 elseif head == :sqrt
162146 content = tex_layout (args[1 ], state)
163- sqrt = TeXChar (' √' , state, :symbol )
164-
165- relpad = 0.15
166-
167147 h = inkheight (content)
168- ypad = relpad * h
169- h += 2 ypad
170-
171- if h > inkheight (sqrt)
172- sqrt = TeXChar (' ⎷' , state, :symbol )
173- h = inkheight (sqrt)
174- y0 = (topinkbound (sqrt) - bottominkbound (sqrt))/ 2 + xheight (font_family)/ 2
175- else
176- y0 = bottominkbound (content) - bottominkbound (sqrt) - 0.1
148+ sqrt = nothing
149+
150+ for name in [" radical.v1" , " radical.v2" , " radical.v3" , " radical.v4" ]
151+ sqrt = TeXChar (name, state, :symbol ; represented = ' √' )
152+ if inkheight (sqrt) >= 1.05 h
153+ pad = (inkheight (sqrt) - 1.05 h) / 2
154+ break
155+ end
177156 end
178157
179- lw = thickness (font_family )
158+ h = inkheight (sqrt )
180159
160+ lw = thickness (font_family)
161+ y0 = bottominkbound (content) - bottominkbound (sqrt) - pad
181162 y = y0 + topinkbound (sqrt) - lw
182163
183- hline = HLine (inkwidth (content) + 0.1 , lw)
164+ hline = HLine (inkwidth (content) + pad , lw)
184165
185166 return Group (
186167 [sqrt, hline, content, Space (1.2 )],
@@ -204,14 +185,7 @@ function tex_layout(expr, state)
204185
205186 # The leftmost element must have x = 0
206187 x0 = - min (0 , dxsub, dxsuper)
207-
208- # Special case to deal with sum symbols and the like that do not
209- # have their baseline properly set in the font
210- if core isa TeXChar
211- y0 = y_for_centered (font_family, core)
212- else
213- y0 = 0.0
214- end
188+ y0 = 0.0
215189
216190 return Group (
217191 [core, sub, super],
0 commit comments