Add SKPaint.FontMetrics property.

This commit is contained in:
Peter Golde 2016-03-15 10:28:12 -07:00
Родитель f4306bd147
Коммит 665dbad77c
4 изменённых файлов: 118 добавлений и 9 удалений

Просмотреть файл

@ -133,15 +133,16 @@ namespace SkiaSharp
CounterClockwise CounterClockwise
} }
public enum SKPathFillType public enum SKPathFillType
{ {
Winding, Winding,
EvenOdd, EvenOdd,
InverseWinding, InverseWinding,
InverseEvenOdd InverseEvenOdd
} }
public enum SKColorType { public enum SKColorType
{
Unknown, Unknown,
Rgba_8888, Rgba_8888,
Bgra_8888, Bgra_8888,
@ -1140,5 +1141,101 @@ namespace SkiaSharp
}; };
} }
} }
[StructLayout(LayoutKind.Sequential)]
public struct SKFontMetrics
{
uint flags; // Bit field to identify which values are unknown
float top; // The greatest distance above the baseline for any glyph (will be <= 0)
float ascent; // The recommended distance above the baseline (will be <= 0)
float descent; // The recommended distance below the baseline (will be >= 0)
float bottom; // The greatest distance below the baseline for any glyph (will be >= 0)
float leading; // The recommended distance to add between lines of text (will be >= 0)
float avgCharWidth; // the average character width (>= 0)
float maxCharWidth; // the max character width (>= 0)
float xMin; // The minimum bounding box x value for all glyphs
float xMax; // The maximum bounding box x value for all glyphs
float xHeight; // The height of an 'x' in px, or 0 if no 'x' in face
float capHeight; // The cap height (> 0), or 0 if cannot be determined.
float underlineThickness; // underline thickness, or 0 if cannot be determined
float underlinePosition; // underline position, or 0 if cannot be determined
const uint flagsUnderlineThicknessIsValid = (1U << 0);
const uint flagsUnderlinePositionIsValid = (1U << 1);
float Top {
get { return top; }
}
float Ascent
{
get { return ascent; }
}
float Descent
{
get { return descent; }
}
float Bottom
{
get { return bottom; }
}
float Leading
{
get { return leading; }
}
float AverageCharacterWidth
{
get { return avgCharWidth; }
}
float MaxCharacterWidth
{
get { return maxCharWidth; }
}
float XMin
{
get { return xMin; }
}
float XMax
{
get { return xMax; }
}
float XHeight
{
get { return xHeight; }
}
float CapHeight
{
get { return capHeight; }
}
float? UnderlineThickness
{
get {
if ((flags & flagsUnderlineThicknessIsValid) != 0)
return underlineThickness;
else
return null;
}
}
float? UnderlinePosition
{
get {
if ((flags & flagsUnderlinePositionIsValid) != 0)
return underlinePosition;
else
return null;
}
}
}
} }

Просмотреть файл

@ -247,6 +247,16 @@ namespace SkiaSharp
return (long)SkiaApi.sk_paint_break_text (Handle, buffer, length, maxWidth, out measuredWidth); return (long)SkiaApi.sk_paint_break_text (Handle, buffer, length, maxWidth, out measuredWidth);
} }
public SKFontMetrics FontMetrics
{
get
{
SKFontMetrics metrics;
SkiaApi.sk_paint_get_fontmetrics(Handle, out metrics);
return metrics;
}
}
} }
} }

Просмотреть файл

@ -244,6 +244,8 @@ namespace SkiaSharp
public extern static IntPtr sk_paint_break_utf16_text(sk_paint_t t, [MarshalAs(UnmanagedType.LPWStr)] string text, IntPtr length, float maxWidth, out float measuredWidth); public extern static IntPtr sk_paint_break_utf16_text(sk_paint_t t, [MarshalAs(UnmanagedType.LPWStr)] string text, IntPtr length, float maxWidth, out float measuredWidth);
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)] [DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static IntPtr sk_paint_break_text (sk_paint_t t, byte [] text, IntPtr length, float maxWidth, out float measuredWidth); public extern static IntPtr sk_paint_break_text (sk_paint_t t, byte [] text, IntPtr length, float maxWidth, out float measuredWidth);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_paint_get_fontmetrics(sk_paint_t t, out SKFontMetrics fontMetrics);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]

2
skia

@ -1 +1 @@
Subproject commit 45bdc31f6d735d23779b131c3e373047f2bbc8ac Subproject commit a4049c724ff869706f026e38dd07f634b7d18256