зеркало из https://github.com/mono/SkiaSharp.git
Added a test for SKFontManager.MatchCharacter
This commit is contained in:
Родитель
ca4aa79555
Коммит
33883435bd
|
@ -92,6 +92,12 @@ namespace SkiaSharp
|
|||
|
||||
public SKTypeface MatchCharacter (string familyName, int weight, int width, SKFontStyleSlant slant, string[] bcp47, int character)
|
||||
{
|
||||
// TODO: work around for https://bugs.chromium.org/p/skia/issues/detail?id=6196
|
||||
if (familyName == null)
|
||||
{
|
||||
familyName = string.Empty;
|
||||
}
|
||||
|
||||
return GetObject<SKTypeface> (SkiaApi.sk_fontmgr_match_family_style_character (Handle, familyName, weight, width, slant, bcp47, bcp47?.Length ?? 0, character));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace SkiaSharpSample.Samples
|
|||
using (var courier = SKTypeface.FromFamilyName("Courier New"))
|
||||
{
|
||||
paint.Typeface = courier;
|
||||
canvas.DrawText("'A' and 'ݐ' and '年'", 40, 100, paint);
|
||||
canvas.DrawText("'A', 'ݐ', '年'", 40, 100, paint);
|
||||
}
|
||||
|
||||
// the font manager finds fonts
|
||||
|
@ -38,7 +38,7 @@ namespace SkiaSharpSample.Samples
|
|||
using (var courier = fontManager.MatchCharacter("Courier New", 'ݐ'))
|
||||
{
|
||||
paint.Typeface = courier;
|
||||
canvas.DrawText("'A' and 'ݐ' and '年'", 40, 200, paint);
|
||||
canvas.DrawText("'A', 'ݐ', '年'", 40, 200, paint);
|
||||
}
|
||||
|
||||
// if we know the font doesn't have the character, or don't want to fall back
|
||||
|
@ -46,7 +46,7 @@ namespace SkiaSharpSample.Samples
|
|||
using (var courier = SKTypeface.FromFamilyName("Courier New"))
|
||||
using (var japanese = fontManager.MatchCharacter("Courier New", '年'))
|
||||
{
|
||||
var first = "'A' and 'ݐ' and '";
|
||||
var first = "'A', 'ݐ', '";
|
||||
var mid = "年";
|
||||
var last = "'";
|
||||
|
||||
|
@ -73,7 +73,7 @@ namespace SkiaSharpSample.Samples
|
|||
using (var emoji = fontManager.MatchCharacter(emojiChar))
|
||||
{
|
||||
paint.Typeface = emoji;
|
||||
canvas.DrawText("🌐 🍪 🍕 🚀", 40, 400, paint);
|
||||
canvas.DrawText("🌐 🍪 🍕 🚀", 40, 400, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,6 +97,23 @@ namespace SkiaSharp.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestFontManagerMatchCharacter()
|
||||
{
|
||||
var fonts = SKFontManager.Default;
|
||||
var emoji = "🚀";
|
||||
var emojiChar = StringUtilities.GetUnicodeCharacterCode(emoji, SKTextEncoding.Utf32);
|
||||
using (var typeface = fonts.MatchCharacter(emojiChar))
|
||||
{
|
||||
if (IsLinux)
|
||||
Assert.Equal("", typeface.FamilyName); // see issue #225
|
||||
else if (IsMac)
|
||||
Assert.Equal("Apple Color Emoji", typeface.FamilyName);
|
||||
else if (IsWindows)
|
||||
Assert.Equal("Segoe UI Emoji", typeface.FamilyName);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ExceptionInInvalidGetTableData()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче