@@ -36,6 +36,7 @@ internal class BaseGlyphBuilder : IGlyphRenderer
3636 private int layerStartIndex ;
3737 private Paint ? activeLayerPaint ;
3838 private FillRule activeLayerFillRule ;
39+ private FontRectangle ? activeClipBounds ;
3940
4041 public BaseGlyphBuilder ( ) => this . Builder = new PathBuilder ( ) ;
4142
@@ -108,7 +109,7 @@ bool IGlyphRenderer.BeginGlyph(in FontRectangle bounds, in GlyphRendererParamete
108109 this . layerStartIndex = this . graphemePathCount ;
109110 this . activeLayerPaint = null ;
110111 this . activeLayerFillRule = FillRule . NonZero ;
111-
112+ this . activeClipBounds = null ;
112113 this . BeginGlyph ( in bounds , in parameters ) ;
113114 return true ;
114115 }
@@ -153,8 +154,6 @@ void IGlyphRenderer.EndGlyph()
153154 this . inLayer = false ;
154155 this . usedLayers = false ;
155156 this . layerStartIndex = this . graphemePathCount ;
156- this . activeLayerPaint = null ;
157- this . activeLayerFillRule = FillRule . NonZero ;
158157 }
159158
160159 /// <inheritdoc/>
@@ -189,16 +188,17 @@ void IGlyphRenderer.QuadraticBezierTo(Vector2 secondControlPoint, Vector2 point)
189188 }
190189
191190 /// <inheritdoc/>
192- void IGlyphRenderer . BeginLayer ( Paint ? paint , FillRule fillRule )
191+ void IGlyphRenderer . BeginLayer ( Paint ? paint , FillRule fillRule , in FontRectangle ? clipBounds )
193192 {
194193 this . usedLayers = true ;
195194 this . inLayer = true ;
196195 this . layerStartIndex = this . graphemePathCount ;
197196 this . activeLayerPaint = paint ;
198197 this . activeLayerFillRule = fillRule ;
198+ this . activeClipBounds = clipBounds ;
199199
200200 this . Builder . Clear ( ) ;
201- this . BeginLayer ( paint , fillRule ) ;
201+ this . BeginLayer ( paint , fillRule , clipBounds ) ;
202202 }
203203
204204 /// <inheritdoc/>
@@ -210,6 +210,8 @@ void IGlyphRenderer.EndLayer()
210210 }
211211
212212 IPath path = this . Builder . Build ( ) ;
213+
214+ // TODO: We need to clip the path by activeClipBounds if set.
213215 this . CurrentPaths . Add ( path ) ;
214216
215217 if ( this . graphemeBuilder is not null )
@@ -228,6 +230,9 @@ void IGlyphRenderer.EndLayer()
228230
229231 this . Builder . Clear ( ) ;
230232 this . inLayer = false ;
233+ this . activeLayerPaint = null ;
234+ this . activeLayerFillRule = FillRule . NonZero ;
235+ this . activeClipBounds = null ;
231236 this . EndLayer ( ) ;
232237 }
233238
@@ -386,8 +391,8 @@ protected virtual void EndText()
386391 {
387392 }
388393
389- /// <inheritdoc cref="IGlyphRenderer.BeginLayer(Paint?, FillRule)"/>
390- protected virtual void BeginLayer ( Paint ? paint , FillRule fillRule )
394+ /// <inheritdoc cref="IGlyphRenderer.BeginLayer(Paint?, FillRule, in FontRectangle? )"/>
395+ protected virtual void BeginLayer ( Paint ? paint , FillRule fillRule , in FontRectangle ? clipBounds )
391396 {
392397 }
393398
0 commit comments