Fix macOS label renderer Italic Font attributes (#2729) fixes #2728

This commit is contained in:
Sivamuthu Kumar 2018-06-05 19:03:33 -04:00 коммит произвёл Rui Marinho
Родитель 81134f75c9
Коммит f30ab27ae8
3 изменённых файлов: 42 добавлений и 2 удалений

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

@ -0,0 +1,38 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using NUnit.Framework;
using Xamarin.UITest;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 2728, "[macOS] Label FontAttributes Italic is not working")]
public class Issue2728 : TestContentPage
{
protected override void Init()
{
var label = new Label { Text = "Hello Label", FontAttributes = FontAttributes.Italic };
Content = new StackLayout
{
Children = {
label
}
};
}
#if UITEST
[Test]
public void Issue2728TestsItalicLabel ()
{
RunningApp.WaitForElement(q => q.Text("Home"));
RunningApp.Screenshot ("Label rendererd with italic font");
}
#endif
}
}

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

@ -732,6 +732,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue1323.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue2399.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1729.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue2728.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1667.cs" />
</ItemGroup>
<ItemGroup>

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

@ -231,8 +231,9 @@ namespace Xamarin.Forms.Platform.MacOS
}
if (italic)
{
Debug.WriteLine("Italic font requested, passing regular one");
return NSFont.UserFontOfSize(size);
var defaultFont = UIFont.SystemFontOfSize(size);
var descriptor = defaultFont.FontDescriptor.FontDescriptorWithSymbolicTraits(NSFontSymbolicTraits.ItalicTrait);
return NSFont.FromDescription(descriptor, 0);
}
#endif
if (bold)