Skip to content

Commit 7b6aecd

Browse files
committed
Implement basic font rendering tuning for code editor. (2/2: Libraries part)
Ability to disable anti-aliasing for 'pixel-perfect' fonts like Courier New. Ability to disable hinting to forget about jagged default WPF rendering.
1 parent 19611ad commit 7b6aecd

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

ICSharpCode.AvalonEdit/TextEditor.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
</Setter.Value>
5656
</Setter>
5757
<Setter Property="SelectionForeground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
58+
<Setter Property="TextOptions.TextFormattingMode" Value="{Binding (TextOptions.TextFormattingMode), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ScrollContentPresenter}}" />
5859
<Setter Property="Template">
5960
<Setter.Value>
6061
<ControlTemplate TargetType="{x:Type editing:TextArea}">

ICSharpCode.AvalonEdit/TextEditorOptions.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,5 +493,49 @@ public bool AllowToggleOverstrikeMode {
493493
}
494494
}
495495
}
496+
497+
bool enableTextAntialiasing = true;
498+
499+
/// <summary>
500+
/// Gets/Sets if anti-aliasing should be applied while text rendering.
501+
/// </summary>
502+
[DefaultValue(true)]
503+
public bool EnableTextAntialiasing
504+
{
505+
get
506+
{
507+
return enableTextAntialiasing;
508+
}
509+
set
510+
{
511+
if (enableTextAntialiasing != value)
512+
{
513+
enableTextAntialiasing = value;
514+
OnPropertyChanged("EnableTextAntialiasing");
515+
}
516+
}
517+
}
518+
519+
bool enableTextHinting = true;
520+
521+
/// <summary>
522+
/// Gets/Sets if TrueType hinting should be applied while text rendering.
523+
/// </summary>
524+
[DefaultValue(true)]
525+
public bool EnableTextHinting
526+
{
527+
get
528+
{
529+
return enableTextHinting;
530+
}
531+
set
532+
{
533+
if (enableTextHinting != value)
534+
{
535+
enableTextHinting = value;
536+
OnPropertyChanged("EnableTextHinting");
537+
}
538+
}
539+
}
496540
}
497541
}

0 commit comments

Comments
 (0)