Simplify text formatting constructors by MrJul · Pull Request #20527 · AvaloniaUI/Avalonia (original) (raw)
This PR makes the fontFeatures parameter optional for the constructors of the following types:
For each of the above types, the other constructor without fontFeatures has been removed.
Doing so fixes the existing TODO12 comments for these types, and make them easier to use (seeing the differences between the two constructors with that many parameter isn't always obvious).
This PR also fixes another simple TODO12: the flowDirection parameter of TextCollapsingProperties.CreateCollapsedRuns has been removed.
namespace Avalonia.Media.TextFormatting { public class GenericTextRunProperties : Avalonia.Media.TextFormatting.TextRunProperties {
public GenericTextRunProperties(Typeface? typeface, FontFeatureCollection? fontFeatures, double? fontRenderingEmSize = 12, TextDecorationCollection? textDecorations = null, IBrush? foregroundBrush = null, IBrush? backgroundBrush = null, BaselineAlignment? baselineAlignment = 3, CultureInfo? cultureInfo = null);public GenericTextRunProperties(Typeface? typeface, double? fontRenderingEmSize = 12, TextDecorationCollection? textDecorations = null, IBrush? foregroundBrush = null, IBrush? backgroundBrush = null, BaselineAlignment? baselineAlignment = 3, CultureInfo? cultureInfo = null);
public GenericTextRunProperties(Typeface? typeface, double? fontRenderingEmSize = 12, TextDecorationCollection? textDecorations = null, IBrush? foregroundBrush = null, IBrush? backgroundBrush = null, BaselineAlignment? baselineAlignment = 3, CultureInfo? cultureInfo = null, FontFeatureCollection? fontFeatures = null); } public abstract class TextCollapsingProperties {
public static TextRun[] CreateCollapsedRuns(TextLine textLine, int collapsedLength, FlowDirection flowDirection, TextRun shapedSymbol);
public static TextRun[] CreateCollapsedRuns(TextLine textLine, int collapsedLength, TextRun shapedSymbol); } public class TextLayout {
public TextLayout(string? text, Typeface? typeface, FontFeatureCollection? fontFeatures, double? fontSize, IBrush? foreground, TextAlignment? textAlignment = 0, TextWrapping? textWrapping = 0, TextTrimming? textTrimming = null, TextDecorationCollection? textDecorations = null, FlowDirection? flowDirection = 0, double? maxWidth = PositiveInfinity, double? maxHeight = PositiveInfinity, double? lineHeight = NaN, double? letterSpacing = 0, int? maxLines = 0, IReadOnlyList<ValueSpan<TextRunProperties>>? textStyleOverrides = null);public TextLayout(string? text, Typeface? typeface, double? fontSize, IBrush? foreground, TextAlignment? textAlignment = 0, TextWrapping? textWrapping = 0, TextTrimming? textTrimming = null, TextDecorationCollection? textDecorations = null, FlowDirection? flowDirection = 0, double? maxWidth = PositiveInfinity, double? maxHeight = PositiveInfinity, double? lineHeight = NaN, double? letterSpacing = 0, int? maxLines = 0, IReadOnlyList<ValueSpan<TextRunProperties>>? textStyleOverrides = null);
public TextLayout(string? text, Typeface? typeface, double? fontSize = 12, IBrush? foreground = null, TextAlignment? textAlignment = 0, TextWrapping? textWrapping = 0, TextTrimming? textTrimming = null, TextDecorationCollection? textDecorations = null, FlowDirection? flowDirection = 0, double? maxWidth = PositiveInfinity, double? maxHeight = PositiveInfinity, double? lineHeight = NaN, double? letterSpacing = 0, int? maxLines = 0, FontFeatureCollection? fontFeatures = null, IReadOnlyList<ValueSpan<TextRunProperties>>? textStyleOverrides = null); } public sealed class TextShaperOptions {
public TextShaperOptions(GlyphTypeface typeface, double fontRenderingEmSize = 12, sbyte bidiLevel = 0, CultureInfo? culture = null, double incrementalTabWidth = 0, double letterSpacing = 0);public TextShaperOptions(GlyphTypeface typeface, IReadOnlyList<FontFeature>? fontFeatures, double fontRenderingEmSize = 12, sbyte bidiLevel = 0, CultureInfo? culture = null, double incrementalTabWidth = 0, double letterSpacing = 0);
}public TextShaperOptions(GlyphTypeface typeface, double fontRenderingEmSize = 12, sbyte bidiLevel = 0, CultureInfo? culture = null, double incrementalTabWidth = 0, double letterSpacing = 0, IReadOnlyList<FontFeature>? fontFeatures = null); }