/// <summary> /// Initializes a new instance of the <see cref="NeovimControl"/> class. /// </summary> /// <param name="parent">The parent control.</param> /// <param name="neovimClient">the neovim client.</param> public NeovimControl(IElement parent, NeovimClient.NeovimClient neovimClient) : base(parent) { this.neovimClient = neovimClient; this.neovimClient.Redraw += this.Invalidate; this.neovimClient.FontChanged += this.OnFontChanged; this.textAnalyzer = new DWrite.TextAnalyzer(this.factoryDWrite); this.cursorEffects = new CursorEffects(this.DeviceContext); this.brushCache = new BrushCache(); this.scriptAnalysesCache = new ScriptAnalysesCache(); this.fontCache = new FontCache(this.factoryDWrite); this.textParam = new TextLayoutParameters( this.factoryDWrite, "Consolas", 11, false, false, false, false, this.Factory.DesktopDpi); }
/// <summary> /// GuiFont changed. /// </summary> /// <param name="font">The font settings.</param> public void OnFontChanged(FontSettings font) { this.pendingActions.Enqueue(() => { if (this.fontCache.SetPrimaryFontFamily(font.FontName)) { this.textParam = new TextLayoutParameters( this.factoryDWrite, font.FontName, font.FontPointSize, font.Bold, font.Italic, font.Underline, font.StrikeOut, this.Factory.DesktopDpi); this.neovimClient.TryResize(this.DesiredColCount, this.DesiredRowCount); } else { this.neovimClient.WriteErrorMessage($"Dotnvim: Unable to use font: {font.FontName}"); } }); this.Invalidate(); }