|
@@ -12,7 +12,7 @@ namespace Avalonia.Skia
|
|
|
{
|
|
|
private bool _isDisposed;
|
|
|
|
|
|
- public GlyphTypefaceImpl(SKTypeface typeface, bool isFakeBold = false, bool isFakeItalic = false)
|
|
|
+ public GlyphTypefaceImpl(SKTypeface typeface, FontSimulations fontSimulations)
|
|
|
{
|
|
|
Typeface = typeface ?? throw new ArgumentNullException(nameof(typeface));
|
|
|
|
|
@@ -52,9 +52,7 @@ namespace Avalonia.Skia
|
|
|
|
|
|
GlyphCount = Typeface.GlyphCount;
|
|
|
|
|
|
- IsFakeBold = isFakeBold;
|
|
|
-
|
|
|
- IsFakeItalic = isFakeItalic;
|
|
|
+ FontSimulations = fontSimulations;
|
|
|
}
|
|
|
|
|
|
public Face Face { get; }
|
|
@@ -63,6 +61,8 @@ namespace Avalonia.Skia
|
|
|
|
|
|
public SKTypeface Typeface { get; }
|
|
|
|
|
|
+ public FontSimulations FontSimulations { get; }
|
|
|
+
|
|
|
public int ReplacementCodepoint { get; }
|
|
|
|
|
|
public FontMetrics Metrics { get; }
|
|
@@ -73,6 +73,26 @@ namespace Avalonia.Skia
|
|
|
|
|
|
public bool IsFakeItalic { get; }
|
|
|
|
|
|
+ public bool TryGetGlyphMetrics(ushort glyph, out GlyphMetrics metrics)
|
|
|
+ {
|
|
|
+ metrics = default;
|
|
|
+
|
|
|
+ if (!Font.TryGetGlyphExtents(glyph, out var extents))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ metrics = new GlyphMetrics
|
|
|
+ {
|
|
|
+ XBearing = extents.XBearing,
|
|
|
+ YBearing = extents.YBearing,
|
|
|
+ Width = extents.Width,
|
|
|
+ Height = extents.Height
|
|
|
+ };
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
/// <inheritdoc cref="IGlyphTypeface"/>
|
|
|
public ushort GetGlyph(uint codepoint)
|
|
|
{
|