Skip to content

Commit

Permalink
Implement basic font rendering tuning for code editor. (2/2: Librarie…
Browse files Browse the repository at this point in the history
…s part)

Ability to disable anti-aliasing for 'pixel-perfect' fonts like Courier New.
Ability to disable hinting to forget about jagged default WPF rendering.
  • Loading branch information
13-beta2 committed Jan 10, 2016
1 parent 19611ad commit 7b6aecd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions ICSharpCode.AvalonEdit/TextEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
</Setter.Value>
</Setter>
<Setter Property="SelectionForeground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
<Setter Property="TextOptions.TextFormattingMode" Value="{Binding (TextOptions.TextFormattingMode), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ScrollContentPresenter}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type editing:TextArea}">
Expand Down
44 changes: 44 additions & 0 deletions ICSharpCode.AvalonEdit/TextEditorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,49 @@ public bool AllowToggleOverstrikeMode {
}
}
}

bool enableTextAntialiasing = true;

/// <summary>
/// Gets/Sets if anti-aliasing should be applied while text rendering.
/// </summary>
[DefaultValue(true)]
public bool EnableTextAntialiasing
{
get
{
return enableTextAntialiasing;
}
set
{
if (enableTextAntialiasing != value)
{
enableTextAntialiasing = value;
OnPropertyChanged("EnableTextAntialiasing");
}
}
}

bool enableTextHinting = true;

/// <summary>
/// Gets/Sets if TrueType hinting should be applied while text rendering.
/// </summary>
[DefaultValue(true)]
public bool EnableTextHinting
{
get
{
return enableTextHinting;
}
set
{
if (enableTextHinting != value)
{
enableTextHinting = value;
OnPropertyChanged("EnableTextHinting");
}
}
}
}
}

0 comments on commit 7b6aecd

Please sign in to comment.