private void DrawText(string text, float locX, float locY, D2D1.Brush fg, D2D1.Brush bg, string font = "", float size = 0) { using (TextFormat = new DW.TextFormat(DWFactory, font == "" ? Config.CooldownBarTextFont : font, size == 0 ? Config.CooldownBarTextFontSize : size)) { TextFormat.WordWrapping = DW.WordWrapping.NoWrap; using (DW.TextLayout TextLayout = new DW.TextLayout(DWFactory, text, TextFormat, 500, 500)) { using (TextBrush = new TextBrush(fg, bg)) { using (TextRenderer = new TextRenderer(Render, TextBrush)) { TextLayout.SetDrawingEffect(TextBrush, new DW.TextRange(10, 20)); TextLayout.Draw(TextRenderer, locX, locY); } } } } }
public override Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, DW.GlyphRun glyphRun, DW.GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect) { try { TextBrush textBrush = _textBrush; if (clientDrawingEffect != null && clientDrawingEffect is TextBrush) { textBrush = (TextBrush)clientDrawingEffect; } using (textBrush) { _renderTarget.DrawGlyphRun(new Vector2(baselineOriginX - 1, baselineOriginY - 1), glyphRun, textBrush.BGBrush, measuringMode); _renderTarget.DrawGlyphRun(new Vector2(baselineOriginX + 1, baselineOriginY + 1), glyphRun, textBrush.BGBrush, measuringMode); _renderTarget.DrawGlyphRun(new Vector2(baselineOriginX, baselineOriginY), glyphRun, textBrush.FGBrush, measuringMode); } return(Result.Ok); } catch { return(Result.Fail); } }
public TextRenderer(RenderTarget renderTarget, TextBrush textBrush) { _renderTarget = renderTarget; _textBrush = textBrush; }