Browse Source

Merge 87916e5c27 into 10ace0b759

pull/731/merge
13.beta2 10 years ago
parent
commit
9ad14316cd
  1. 6
      data/resources/StringResources.resx
  2. 8
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml
  3. 49
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  4. 44
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

6
data/resources/StringResources.resx

@ -8446,4 +8446,10 @@ Press Esc to cancel this operation.</value> @@ -8446,4 +8446,10 @@ Press Esc to cancel this operation.</value>
<data name="ICSharpCode.WpfDesign.AddIn.Options.EnableAppXamlParsing" xml:space="preserve">
<value>Enable App.xaml parsing</value>
</data>
<data name="Dialog.Options.IDEOptions.TextEditor.General.EnableTextAntialiasing" xml:space="preserve">
<value>Enable anti-aliasing</value>
</data>
<data name="Dialog.Options.IDEOptions.TextEditor.General.EnableTextHinting" xml:space="preserve">
<value>Enable hinting</value>
</data>
</root>

8
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml

@ -4,7 +4,15 @@ @@ -4,7 +4,15 @@
<StackPanel>
<GroupBox
Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.FontGroupBox}">
<widgets:StackPanelWithSpacing SpaceBetweenItems="5">
<gui:FontSelector x:Name="fontSelectionPanel" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.EnableTextAntialiasing}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.EnableTextAntialiasing}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.EnableTextHinting}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.EnableTextHinting}" />
</widgets:StackPanelWithSpacing>
</GroupBox>
<GroupBox
Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.GeneralOptionsGroupBox}">

49
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -166,6 +166,40 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -166,6 +166,40 @@ namespace ICSharpCode.AvalonEdit.Rendering
}
}
void SetupTextRendering()
{
if (Options.EnableTextAntialiasing)
{
if (Options.EnableTextHinting)
{
if (CurrentZoom == 1.0)
{
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
TextOptions.SetTextHintingMode(this, TextHintingMode.Auto);
}
else
{
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Ideal);
TextOptions.SetTextRenderingMode(this, TextRenderingMode.Grayscale);
TextOptions.SetTextHintingMode(this, TextHintingMode.Auto);
}
}
else
{
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Ideal);
TextOptions.SetTextRenderingMode(this, TextRenderingMode.Grayscale);
TextOptions.SetTextHintingMode(this, TextHintingMode.Animated);
}
}
else
{
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
TextOptions.SetTextRenderingMode(this, TextRenderingMode.Aliased);
TextOptions.SetTextHintingMode(this, TextHintingMode.Auto);
}
}
/// <inheritdoc cref="IWeakEventListener.ReceiveWeakEvent"/>
protected virtual bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
{
@ -225,6 +259,7 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -225,6 +259,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
else
columnRulerRenderer.SetRuler(-1, ColumnRulerPen);
SetupTextRendering();
UpdateBuiltinElementGeneratorsFromOptions();
Redraw();
}
@ -1419,6 +1454,18 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -1419,6 +1454,18 @@ namespace ICSharpCode.AvalonEdit.Rendering
ScrollViewer IScrollInfo.ScrollOwner { get; set; }
/// <summary>
/// Gets the zoom level;
/// </summary>
public double CurrentZoom
{
get
{
dynamic scrollOwner = ((IScrollInfo) this).ScrollOwner;
return scrollOwner?.CurrentZoom ?? 1.0;
}
}
void IScrollInfo.LineUp()
{
((IScrollInfo)this).SetVerticalOffset(scrollOffset.Y - DefaultLineHeight);
@ -1999,6 +2046,8 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -1999,6 +2046,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == TextView.ActualHeightProperty)
SetupTextRendering();
if (TextFormatterFactory.PropertyChangeAffectsTextFormatter(e.Property)) {
// first, create the new text formatter:
RecreateTextFormatter();

44
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

@ -493,5 +493,49 @@ namespace ICSharpCode.AvalonEdit @@ -493,5 +493,49 @@ namespace ICSharpCode.AvalonEdit
}
}
}
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");
}
}
}
}
}

Loading…
Cancel
Save