mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
Add effects drawing for underline/strikethrough styles (#3488)
This commit is contained in:
@@ -337,7 +337,7 @@ internal sealed class TextBlock : IDisposable
|
||||
var size = style.TextStrokeWidth.Value.GetPixels( 1.0f );
|
||||
var effect = TextEffect.Outline( color.ToSk(), size );
|
||||
effect.StrokeMiter = 2.0f;
|
||||
effect.StrkeJoin = SKStrokeJoin.Round;
|
||||
effect.StrokeJoin = SKStrokeJoin.Round;
|
||||
Style.AddEffect( effect );
|
||||
|
||||
EffectMargin.Left = MathF.Max( EffectMargin.Left, size ).CeilToInt();
|
||||
|
||||
24
engine/ThirdParty/Topten.RichTextKit/FontRun.cs
vendored
24
engine/ThirdParty/Topten.RichTextKit/FontRun.cs
vendored
@@ -864,24 +864,24 @@ namespace Topten.RichTextKit
|
||||
// text strokes.
|
||||
//
|
||||
_textBlob = null;
|
||||
CreateTextBlob( ctx, false );
|
||||
var glyphVOffset = CreateTextBlob( ctx, false );
|
||||
|
||||
if ( _textBlob == null )
|
||||
return;
|
||||
|
||||
using ( var effectPaint = new SKPaint() )
|
||||
using var effectPaint = new SKPaint();
|
||||
foreach ( var effect in Style.TextEffects )
|
||||
{
|
||||
foreach ( var effect in Style.TextEffects )
|
||||
{
|
||||
effectPaint.Style = effect.PaintStyle;
|
||||
effectPaint.StrokeWidth = effect.Width;
|
||||
effectPaint.StrokeJoin = effect.StrkeJoin;
|
||||
effectPaint.StrokeMiter = effect.StrokeMiter;
|
||||
effectPaint.Color = effect.Color;
|
||||
effectPaint.ImageFilter = effect.BlurSize > 0 ? SKImageFilter.CreateDropShadow( effect.Offset.X, effect.Offset.Y, effect.BlurSize, effect.BlurSize, effect.Color ) : null;
|
||||
effectPaint.Style = effect.PaintStyle;
|
||||
effectPaint.StrokeWidth = effect.Width;
|
||||
effectPaint.StrokeJoin = effect.StrokeJoin;
|
||||
effectPaint.StrokeMiter = effect.StrokeMiter;
|
||||
effectPaint.Color = effect.Color;
|
||||
effectPaint.ImageFilter = effect.BlurSize > 0 ? SKImageFilter.CreateDropShadow( effect.Offset.X, effect.Offset.Y, effect.BlurSize, effect.BlurSize, effect.Color ) : null;
|
||||
|
||||
ctx.Canvas.DrawText( _textBlob, 0, 0, effectPaint );
|
||||
}
|
||||
ctx.Canvas.DrawText( _textBlob, 0, 0, effectPaint );
|
||||
PaintUnderline( ctx, effectPaint );
|
||||
PaintStrikeThrough( ctx, effectPaint, glyphVOffset );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Topten.RichTextKit
|
||||
public SKPaintStyle PaintStyle { get; set; }
|
||||
public SKBlurStyle BlurStyle { get; set; }
|
||||
public float BlurSize { get; set; }
|
||||
public SKStrokeJoin StrkeJoin { get; set; }
|
||||
public SKStrokeJoin StrokeJoin { get; set; }
|
||||
public float StrokeMiter { get; set; }
|
||||
|
||||
public static TextEffect DropShadow( SKColor sKColor, float x, float y, float blurSize )
|
||||
@@ -58,7 +58,7 @@ namespace Topten.RichTextKit
|
||||
Width = size,
|
||||
PaintStyle = SKPaintStyle.StrokeAndFill,
|
||||
StrokeMiter = 0.5f,
|
||||
StrkeJoin = SKStrokeJoin.Round
|
||||
StrokeJoin = SKStrokeJoin.Round
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user