|
|
|
@ -1,12 +1,18 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Globalization; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Controls.Platform; |
|
|
|
using Avalonia.Input; |
|
|
|
using Avalonia.Input.Platform; |
|
|
|
using Avalonia.Media; |
|
|
|
using Avalonia.Media.Fonts; |
|
|
|
using Avalonia.Media.TextFormatting; |
|
|
|
using Avalonia.Platform; |
|
|
|
using Avalonia.Utility; |
|
|
|
|
|
|
|
namespace Avalonia.Headless |
|
|
|
{ |
|
|
|
@ -74,6 +80,88 @@ namespace Avalonia.Headless |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class HeadlessGlyphTypefaceImpl : IGlyphTypefaceImpl |
|
|
|
{ |
|
|
|
public short DesignEmHeight => 10; |
|
|
|
|
|
|
|
public int Ascent => 5; |
|
|
|
|
|
|
|
public int Descent => 5; |
|
|
|
|
|
|
|
public int LineGap => 2; |
|
|
|
|
|
|
|
public int UnderlinePosition => 5; |
|
|
|
|
|
|
|
public int UnderlineThickness => 5; |
|
|
|
|
|
|
|
public int StrikethroughPosition => 5; |
|
|
|
|
|
|
|
public int StrikethroughThickness => 2; |
|
|
|
|
|
|
|
public bool IsFixedPitch => true; |
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
public ushort GetGlyph(uint codepoint) |
|
|
|
{ |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
public int GetGlyphAdvance(ushort glyph) |
|
|
|
{ |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
public int[] GetGlyphAdvances(ReadOnlySpan<ushort> glyphs) |
|
|
|
{ |
|
|
|
return glyphs.ToArray().Select(x => (int)x).ToArray(); |
|
|
|
} |
|
|
|
|
|
|
|
public ushort[] GetGlyphs(ReadOnlySpan<uint> codepoints) |
|
|
|
{ |
|
|
|
return codepoints.ToArray().Select(x => (ushort)x).ToArray(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class HeadlessTextShaperStub : ITextShaperImpl |
|
|
|
{ |
|
|
|
public GlyphRun ShapeText(ReadOnlySlice<char> text, TextFormat textFormat) |
|
|
|
{ |
|
|
|
return new GlyphRun(new GlyphTypeface(new Typeface("Arial")), textFormat.FontRenderingEmSize, |
|
|
|
new ReadOnlySlice<ushort>(new ushort[] { 1, 2, 3 }), |
|
|
|
new ReadOnlySlice<double>(new double[] { 1, 2, 3 }), |
|
|
|
new ReadOnlySlice<Vector>(new Vector[] { new Vector(1, 1), new Vector(2, 2), new Vector(3, 3) }), |
|
|
|
text, |
|
|
|
new ReadOnlySlice<ushort>(new ushort[] { 1, 2, 3 })); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class HeadlessFontManagerStub : IFontManagerImpl |
|
|
|
{ |
|
|
|
public IGlyphTypefaceImpl CreateGlyphTypeface(Typeface typeface) |
|
|
|
{ |
|
|
|
return new HeadlessGlyphTypefaceImpl(); |
|
|
|
} |
|
|
|
|
|
|
|
public string GetDefaultFontFamilyName() |
|
|
|
{ |
|
|
|
return "Arial"; |
|
|
|
} |
|
|
|
|
|
|
|
public IEnumerable<string> GetInstalledFontFamilyNames(bool checkForUpdates = false) |
|
|
|
{ |
|
|
|
return new List<string> { "Arial" }; |
|
|
|
} |
|
|
|
|
|
|
|
public bool TryMatchCharacter(int codepoint, FontWeight fontWeight, FontStyle fontStyle, FontFamily fontFamily, CultureInfo culture, out FontKey fontKey) |
|
|
|
{ |
|
|
|
fontKey = new FontKey("Arial", fontWeight, fontStyle); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class HeadlessIconLoaderStub : IPlatformIconLoader |
|
|
|
{ |
|
|
|
|
|
|
|
|