Browse Source

TextRunProperties: Add setter for TypographyProperties and NumberSubstitution.

pull/27/merge
Daniel Grunwald 14 years ago
parent
commit
b0367b735a
  1. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  2. 128
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/DefaultTextRunTypographyProperties.cs
  3. 10
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
  4. 34
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineElementTextRunProperties.cs

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -234,6 +234,7 @@
<DependentUpon>IVisualLineTransformer.cs</DependentUpon> <DependentUpon>IVisualLineTransformer.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Rendering\ColumnRulerRenderer.cs" /> <Compile Include="Rendering\ColumnRulerRenderer.cs" />
<Compile Include="Rendering\DefaultTextRunTypographyProperties.cs" />
<Compile Include="Rendering\DocumentColorizingTransformer.cs"> <Compile Include="Rendering\DocumentColorizingTransformer.cs">
<DependentUpon>IVisualLineTransformer.cs</DependentUpon> <DependentUpon>IVisualLineTransformer.cs</DependentUpon>
</Compile> </Compile>

128
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/DefaultTextRunTypographyProperties.cs

@ -0,0 +1,128 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows;
using System.Windows.Media.TextFormatting;
namespace ICSharpCode.AvalonEdit.Rendering
{
/// <summary>
/// Default implementation for TextRunTypographyProperties.
/// </summary>
public class DefaultTextRunTypographyProperties : TextRunTypographyProperties
{
public override FontVariants Variants {
get { return FontVariants.Normal; }
}
public override bool StylisticSet1 { get { return false; } }
public override bool StylisticSet2 { get { return false; } }
public override bool StylisticSet3 { get { return false; } }
public override bool StylisticSet4 { get { return false; } }
public override bool StylisticSet5 { get { return false; } }
public override bool StylisticSet6 { get { return false; } }
public override bool StylisticSet7 { get { return false; } }
public override bool StylisticSet8 { get { return false; } }
public override bool StylisticSet9 { get { return false; } }
public override bool StylisticSet10 { get { return false; } }
public override bool StylisticSet11 { get { return false; } }
public override bool StylisticSet12 { get { return false; } }
public override bool StylisticSet13 { get { return false; } }
public override bool StylisticSet14 { get { return false; } }
public override bool StylisticSet15 { get { return false; } }
public override bool StylisticSet16 { get { return false; } }
public override bool StylisticSet17 { get { return false; } }
public override bool StylisticSet18 { get { return false; } }
public override bool StylisticSet19 { get { return false; } }
public override bool StylisticSet20 { get { return false; } }
public override int StylisticAlternates {
get { return 0; }
}
public override int StandardSwashes {
get { return 0; }
}
public override bool StandardLigatures {
get { return true; }
}
public override bool SlashedZero {
get { return false; }
}
public override FontNumeralStyle NumeralStyle {
get { return FontNumeralStyle.Normal; }
}
public override FontNumeralAlignment NumeralAlignment {
get { return FontNumeralAlignment.Normal; }
}
public override bool MathematicalGreek {
get { return false; }
}
public override bool Kerning {
get { return true; }
}
public override bool HistoricalLigatures {
get { return false; }
}
public override bool HistoricalForms {
get { return false; }
}
public override FontFraction Fraction {
get { return FontFraction.Normal; }
}
public override FontEastAsianWidths EastAsianWidths {
get { return FontEastAsianWidths.Normal; }
}
public override FontEastAsianLanguage EastAsianLanguage {
get { return FontEastAsianLanguage.Normal; }
}
public override bool EastAsianExpertForms {
get { return false; }
}
public override bool DiscretionaryLigatures {
get { return false; }
}
public override int ContextualSwashes {
get { return 0; }
}
public override bool ContextualLigatures {
get { return true; }
}
public override bool ContextualAlternates {
get { return true; }
}
public override bool CaseSensitiveForms {
get { return false; }
}
public override bool CapitalSpacing {
get { return false; }
}
public override FontCapitals Capitals {
get { return FontCapitals.Normal; }
}
public override int AnnotationAlternates {
get { return 0; }
}
}
}

10
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs

@ -1,6 +1,7 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System.Linq;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
@ -187,6 +188,15 @@ namespace ICSharpCode.AvalonEdit.Rendering
foreach (IVisualLineTransformer transformer in transformers) { foreach (IVisualLineTransformer transformer in transformers) {
transformer.Transform(context, elements); transformer.Transform(context, elements);
} }
// For some strange reason, WPF requires that either all or none of the typography properties are set.
if (elements.Any(e => e.TextRunProperties.TypographyProperties != null)) {
// Fix typographic properties
foreach (VisualLineElement element in elements) {
if (element.TextRunProperties.TypographyProperties == null) {
element.TextRunProperties.SetTypographyProperties(new DefaultTextRunTypographyProperties());
}
}
}
} }
internal void SetTextLines(List<TextLine> textLines) internal void SetTextLines(List<TextLine> textLines)

34
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineElementTextRunProperties.cs

@ -26,6 +26,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
Typeface typeface; Typeface typeface;
TextDecorationCollection textDecorations; TextDecorationCollection textDecorations;
TextEffectCollection textEffects; TextEffectCollection textEffects;
TextRunTypographyProperties typographyProperties;
NumberSubstitution numberSubstitution;
/// <summary> /// <summary>
/// Creates a new VisualLineElementTextRunProperties instance that copies its values /// Creates a new VisualLineElementTextRunProperties instance that copies its values
@ -52,6 +54,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
if (textEffects != null && !textEffects.IsFrozen) { if (textEffects != null && !textEffects.IsFrozen) {
textEffects = textEffects.Clone(); textEffects = textEffects.Clone();
} }
typographyProperties = textRunProperties.TypographyProperties;
numberSubstitution = textRunProperties.NumberSubstitution;
} }
/// <summary> /// <summary>
@ -203,5 +207,35 @@ namespace ICSharpCode.AvalonEdit.Rendering
ExtensionMethods.CheckIsFrozen(value); ExtensionMethods.CheckIsFrozen(value);
textEffects = value; textEffects = value;
} }
/// <summary>
/// Gets the typography properties for the text run.
/// </summary>
public override TextRunTypographyProperties TypographyProperties {
get { return typographyProperties; }
}
/// <summary>
/// Sets the <see cref="TypographyProperties"/>.
/// </summary>
public void SetTypographyProperties(TextRunTypographyProperties value)
{
typographyProperties = value;
}
/// <summary>
/// Gets the number substitution settings for the text run.
/// </summary>
public override NumberSubstitution NumberSubstitution {
get { return numberSubstitution; }
}
/// <summary>
/// Sets the <see cref="NumberSubstitution"/>.
/// </summary>
public void SetNumberSubstitution(NumberSubstitution value)
{
numberSubstitution = value;
}
} }
} }

Loading…
Cancel
Save