Optimizing Text Rendering for Speed and Clarity in .NET Applications
Rendering source code efficiently and clearly is a core challenge in any code-editor component. In the latest update of AlterNET Studio’s Code Editor, we tackled the twin goals of ultra-fast rendering and visually smooth text display across both WinForms and WPF platforms.
In the Windows Forms version, our primary focus was eliminating flicker, accelerating drawing of numerous syntax-colored fragments, and optimizing text-metrics handling for monospaced and non-monospaced fonts. In the WPF version, we leveraged hardware-accelerated layers and the advanced text-formatting pipeline built into WPF for a rich editing experience. And looking ahead, we’re already planning cross-platform rendering via the AlterNET UI framework and engines like Skia.

WinForms Text Rendering: Tackling Flicker and Fragmentation
In the early development of the Code Editor for WinForms, we encountered significant performance and flicker-related issues when rendering multi-line source text with syntax highlighting.
Text was frequently broken into many small fragments (reserved words, comments, numbers etc.), and drawing each fragment using GDI+ methods such as DrawString/MeasureString proved too slow.
To address this, we adopted the native GDI ExtTextOut API internally, which allows simultaneous drawing of background and text fragments and therefore markedly reduced flicker.
We also introduced text metrics caching (for font size, character widths, etc.) so that repeated measurements of characters didn’t degrade performance - especially important given that even monospaced fonts must handle international characters of varying widths.
For non-monospaced fonts, we switch to GDI’s DrawText API which includes features such as kerning and handles italic overhangs more gracefully.

WPF Text Rendering: Leveraging DirectX and TextFormatting APIs
The WPF variant of our editor took a different approach, embracing the full power of WPF’s graphics stack. We render code with DirectX-backed layers that separate background, text, and UI elements into independent visuals.
Internally we rely on System.Windows.Media.TextFormatting’s TextLine and TextSource classes for high-quality measurement, layout and rendering of text content. This approach enables smooth scrolling, crisp anti-aliased text, text formatting, and rendering international characters while maintaining high throughput.
Looking Forward: Cross-Platform Rendering with AlterNET UI & Skia
As part of our roadmap, we’re extending text-rendering support via the AlterNET UI cross-platform framework, with potential use of the fast, hardware-accelerated Skia/OpenGL graphics engine. This will bring performance and visual consistency to macOS, Linux and potentially mobile platforms.
Why It Matters for Developers
High-quality text rendering isn’t just an aesthetic detail - it directly impacts developer productivity. Smooth scrolling, fast load times for large files, flicker-free rendering, and crisp text readability all contribute to a more stable editing experience. When choosing a code-editor component for your application, the underlying rendering architecture makes a significant difference.
Summary
In the Code Editor component of AlterNET Studio, we’ve addressed the most demanding challenges of text rendering on the .NET platform. For WinForms we optimized measurement and drawing using GDI APIs and caching; for WPF we harnessed DirectX-backed layers and advanced formatting APIs; and moving ahead we’re extending the strategy into a cross-platform realm via AlterNET UI and Skia. The result is an editor that delivers high performance and superior visual fidelity for source-code editing scenarios.