@@ -338,11 +338,18 @@ protected void RenderDecorationsTo(
338338 float scaledPPEM ,
339339 TextOptions options )
340340 {
341- bool perGlyph = options . DecorationPositioningMode == DecorationPositioningMode . PerGlyphFromFont ;
341+ bool perGlyph = options . DecorationPositioningMode == DecorationPositioningMode . GlyphFont ;
342342 FontMetrics fontMetrics = perGlyph
343343 ? this . FontMetrics
344344 : options . Font . FontMetrics ;
345345
346+ // The scale factor for the decoration length is treated separately from other factors
347+ // as it is used to scale the length of the decoration line.
348+ // This must always be derived from the glyph's own scale factor to ensure correct length.
349+ Vector2 lengthScaleFactor = this . ScaleFactor ;
350+
351+ // These factors determine horizontal and vertical scaling and offset for the decorations.
352+ // and are either per-glyph or derived from the common font metrics.
346353 Vector2 scaleFactor ;
347354 Vector2 offset ;
348355 if ( perGlyph )
@@ -383,12 +390,13 @@ protected void RenderDecorationsTo(
383390 return ( Vector2 . Zero , Vector2 . Zero , 0 ) ;
384391 }
385392
393+ Vector2 lengthScale = new Vector2 ( scaledPPEM ) / lengthScaleFactor ;
386394 Vector2 scale = new Vector2 ( scaledPPEM ) / scaleFactor ;
387395
388396 // Undo the vertical offset applied when laying out the text.
389397 Vector2 scaledOffset = ( offset + new Vector2 ( decoratorPosition , 0 ) ) * scale ;
390398
391- length *= scale . Y ;
399+ length *= lengthScale . Y ;
392400 thickness *= scale . X ;
393401
394402 Vector2 tl = new ( scaledOffset . X , scaledOffset . Y ) ;
@@ -421,10 +429,11 @@ protected void RenderDecorationsTo(
421429 return ( Vector2 . Zero , Vector2 . Zero , 0 ) ;
422430 }
423431
432+ Vector2 lengthScale = new Vector2 ( scaledPPEM ) / lengthScaleFactor ;
424433 Vector2 scale = new Vector2 ( scaledPPEM ) / scaleFactor ;
425434 Vector2 scaledOffset = ( offset + new Vector2 ( 0 , decoratorPosition ) ) * scale ;
426435
427- length *= scale . X ;
436+ length *= lengthScale . X ;
428437 thickness *= scale . Y ;
429438
430439 Vector2 tl = new ( scaledOffset . X , scaledOffset . Y ) ;
0 commit comments