@@ -11,8 +11,8 @@ public abstract class TextPainter<TCanvas, TColor> : Painter<TCanvas, TextSource
1111 public TextPainter ( float fontSize = DefaultFontSize , float lineWidth = DefaultFontSize * 100 ) : base ( fontSize ) { }
1212
1313 //display maths should always be center-aligned regardless of parameter for Draw()
14- public Display . MathListDisplay < Fonts , Glyph > _absoluteXCoordDisplay ;
15- public Display . MathListDisplay < Fonts , Glyph > _relativeXCoordDisplay ;
14+ public Display . ListDisplay < Fonts , Glyph > _absoluteXCoordDisplay ;
15+ public Display . ListDisplay < Fonts , Glyph > _relativeXCoordDisplay ;
1616 protected Typography . TextLayout . GlyphLayout _glyphLayout = new Typography . TextLayout . GlyphLayout ( ) ;
1717
1818 public TextAtom Atom { get => Source . Atom ; set => Source = new TextSource ( value ) ; }
@@ -45,7 +45,7 @@ private void DrawCore(TCanvas canvas, float? width, TextAlignment alignment, Thi
4545 _relativeXCoordDisplay . Width , _relativeXCoordDisplay . Ascent , _relativeXCoordDisplay . Descent , FontSize , CoordinatesFromBottomLeftInsteadOfTopLeft , width ?? c . Width , c . Height , alignment , padding , offsetX , offsetY ) ) ;
4646 //offsetY is already included in _relativeXCoordDisplay.Position, no need to add it again below
4747 _absoluteXCoordDisplay . Position = new PointF ( _absoluteXCoordDisplay . Position . X + offsetX , _absoluteXCoordDisplay . Position . Y + _relativeXCoordDisplay . Position . Y ) ;
48- DrawCore ( c , new Display . MathListDisplay < Fonts , Glyph > ( new [ ] { _relativeXCoordDisplay , _absoluteXCoordDisplay } ) ) ;
48+ DrawCore ( c , new Display . ListDisplay < Fonts , Glyph > ( new [ ] { _relativeXCoordDisplay , _absoluteXCoordDisplay } ) ) ;
4949 }
5050 }
5151 /// <summary>
@@ -56,11 +56,14 @@ public void DrawOneLine(TCanvas canvas, float x, float y) {
5656 if ( ! Source . IsValid ) DrawError ( c ) ;
5757 else {
5858 UpdateDisplay ( float . PositiveInfinity ) ;
59- if ( ! CoordinatesFromBottomLeftInsteadOfTopLeft ) { y -= _relativeXCoordDisplay . Descent ; y *= - 1 ; } else y -= _relativeXCoordDisplay . Ascent ;
59+ if ( ! CoordinatesFromBottomLeftInsteadOfTopLeft ) {
60+ y -= _relativeXCoordDisplay . Displays . Max ( dp => dp . Ascent ) ;
61+ y *= - 1 ;
62+ } else y -= _relativeXCoordDisplay . Displays . Max ( dp => dp . Descent ) ;
6063 _relativeXCoordDisplay . Position = new PointF ( _relativeXCoordDisplay . Position . X + x , _relativeXCoordDisplay . Position . Y + y ) ;
6164 //y is already included in _relativeXCoordDisplay.Position, no need to add it again below
6265 _absoluteXCoordDisplay . Position = new PointF ( _absoluteXCoordDisplay . Position . X + x , _relativeXCoordDisplay . Position . Y ) ;
63- DrawCore ( c , new Display . MathListDisplay < Fonts , Glyph > ( new [ ] { _relativeXCoordDisplay , _absoluteXCoordDisplay } ) ) ;
66+ DrawCore ( c , new Display . ListDisplay < Fonts , Glyph > ( new [ ] { _relativeXCoordDisplay , _absoluteXCoordDisplay } ) ) ;
6467 }
6568 }
6669 }
0 commit comments