@@ -11,8 +11,8 @@ public abstract class TextPainter<TCanvas, TColor> : Painter<TCanvas, TextSource
11
11
public TextPainter ( float fontSize = DefaultFontSize , float lineWidth = DefaultFontSize * 100 ) : base ( fontSize ) { }
12
12
13
13
//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 ;
16
16
protected Typography . TextLayout . GlyphLayout _glyphLayout = new Typography . TextLayout . GlyphLayout ( ) ;
17
17
18
18
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
45
45
_relativeXCoordDisplay . Width , _relativeXCoordDisplay . Ascent , _relativeXCoordDisplay . Descent , FontSize , CoordinatesFromBottomLeftInsteadOfTopLeft , width ?? c . Width , c . Height , alignment , padding , offsetX , offsetY ) ) ;
46
46
//offsetY is already included in _relativeXCoordDisplay.Position, no need to add it again below
47
47
_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 } ) ) ;
49
49
}
50
50
}
51
51
/// <summary>
@@ -56,11 +56,14 @@ public void DrawOneLine(TCanvas canvas, float x, float y) {
56
56
if ( ! Source . IsValid ) DrawError ( c ) ;
57
57
else {
58
58
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 ) ;
60
63
_relativeXCoordDisplay . Position = new PointF ( _relativeXCoordDisplay . Position . X + x , _relativeXCoordDisplay . Position . Y + y ) ;
61
64
//y is already included in _relativeXCoordDisplay.Position, no need to add it again below
62
65
_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 } ) ) ;
64
67
}
65
68
}
66
69
}
0 commit comments