Completed
Last Updated: 27 May 2022 12:28 by ADMIN
Release R2 2022 SP1
Simon
Created on: 20 May 2022 12:13
Category: UI for WinForms
Type: Bug Report
1
RadSyntaxEditor: The line numbers may be clipped when using custom fonts

Use a custom font set like this: 

this.radSyntaxEditor1.SyntaxEditorElement.EditorFontFamily = new Telerik.WinControls.SyntaxEditor.UI.FontFamily("Cascadia Code");
this.radSyntaxEditor1.SyntaxEditorElement.EditorFontSize = 13;

Then load a large document, at least 10K lines so that the clipping is visible.

1 comment
ADMIN
Hristo
Posted on: 20 May 2022 12:16

Hello,

The issue can be worked around by manually syncing the font of the measurement text block with that of the editor: 

this.radSyntaxEditor1.SyntaxEditorElement.EditorFontFamily = new Telerik.WinControls.SyntaxEditor.UI.FontFamily("Cascadia Code");
this.radSyntaxEditor1.SyntaxEditorElement.EditorFontSize = 13;

var lineNumberMargin = this.radSyntaxEditor1.SyntaxEditorElement.Margins.ScrollableLeft[0];
var textBlock = typeof(LineNumberMargin).
                    GetField("measureBlock", BindingFlags.Instance | BindingFlags.NonPublic).
                    GetValue(lineNumberMargin) as TextBlock;

if (textBlock != null)
{
    textBlock.FontFamily = this.radSyntaxEditor1.SyntaxEditorElement.EditorFontFamily;
    textBlock.FontSize = this.radSyntaxEditor1.SyntaxEditorElement.EditorFontSize;
}

Here is the result:

Regards,
Hristo
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.