From daec1be03337e9774869a150c5b245dbec3f476c Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Fri, 26 Oct 2018 15:47:38 +0200 Subject: [PATCH 1/6] OpenTypeFont support for embedded fonts --- .../Media/Fonts/FontFamilyKey.cs | 35 +++++++++++++++---- .../Media/Fonts/FontFamilyLoader.cs | 4 +-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs b/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs index cb996867c4..9af9509e4e 100644 --- a/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs +++ b/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs @@ -17,7 +17,10 @@ namespace Avalonia.Media.Fonts /// public FontFamilyKey(Uri source) { - if (source == null) throw new ArgumentNullException(nameof(source)); + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } if (source.AbsolutePath.Contains(".ttf")) { @@ -26,6 +29,14 @@ namespace Avalonia.Media.Fonts FileName = fileNameWithoutExtension + ".ttf"; Location = new Uri(source.OriginalString.Replace("." + FileName, string.Empty), UriKind.RelativeOrAbsolute); } + + if (source.AbsolutePath.Contains(".otf")) + { + var filePathWithoutExtension = source.AbsolutePath.Replace(".otf", string.Empty); + var fileNameWithoutExtension = filePathWithoutExtension.Split('.').Last(); + FileName = fileNameWithoutExtension + ".otf"; + Location = new Uri(source.OriginalString.Replace("." + FileName, string.Empty), UriKind.RelativeOrAbsolute); + } else { Location = source; @@ -77,11 +88,20 @@ namespace Avalonia.Media.Fonts /// public override bool Equals(object obj) { - if (!(obj is FontFamilyKey other)) return false; + if (!(obj is FontFamilyKey other)) + { + return false; + } - if (Location != other.Location) return false; + if (Location != other.Location) + { + return false; + } - if (FileName != other.FileName) return false; + if (FileName != other.FileName) + { + return false; + } return true; } @@ -94,7 +114,10 @@ namespace Avalonia.Media.Fonts /// public override string ToString() { - if (FileName == null) return Location.PathAndQuery; + if (FileName == null) + { + return Location.PathAndQuery; + } var builder = new UriBuilder(Location); @@ -103,4 +126,4 @@ namespace Avalonia.Media.Fonts return builder.ToString(); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/Fonts/FontFamilyLoader.cs b/src/Avalonia.Visuals/Media/Fonts/FontFamilyLoader.cs index 57e6c756cc..b6b83e2097 100644 --- a/src/Avalonia.Visuals/Media/Fonts/FontFamilyLoader.cs +++ b/src/Avalonia.Visuals/Media/Fonts/FontFamilyLoader.cs @@ -34,7 +34,7 @@ namespace Avalonia.Media.Fonts { var availableAssets = s_assetLoader.GetAssets(location); - var matchingAssets = availableAssets.Where(x => x.absolutePath.EndsWith(".ttf")); + var matchingAssets = availableAssets.Where(x => x.absolutePath.EndsWith(".ttf") || x.absolutePath.EndsWith(".otf")); return matchingAssets.Select(x => GetAssetUri(x.absolutePath, x.assembly)); } @@ -53,7 +53,7 @@ namespace Avalonia.Media.Fonts var compareTo = location.AbsolutePath + "." + fileName.Split('*').First(); var matchingResources = - availableResources.Where(x => x.absolutePath.Contains(compareTo) && x.absolutePath.EndsWith(".ttf")); + availableResources.Where(x => x.absolutePath.Contains(compareTo) && (x.absolutePath.EndsWith(".ttf") || x.absolutePath.EndsWith(".otf"))); return matchingResources.Select(x => GetAssetUri(x.absolutePath, x.assembly)); } From 2a7de6681b622294fabba11ca580315f34c53a60 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Sat, 27 Oct 2018 00:47:55 +0200 Subject: [PATCH 2/6] Fix FamilyKey --- .../Media/Fonts/FontFamilyKey.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs b/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs index 9af9509e4e..99b0091139 100644 --- a/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs +++ b/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs @@ -29,19 +29,21 @@ namespace Avalonia.Media.Fonts FileName = fileNameWithoutExtension + ".ttf"; Location = new Uri(source.OriginalString.Replace("." + FileName, string.Empty), UriKind.RelativeOrAbsolute); } - - if (source.AbsolutePath.Contains(".otf")) - { - var filePathWithoutExtension = source.AbsolutePath.Replace(".otf", string.Empty); - var fileNameWithoutExtension = filePathWithoutExtension.Split('.').Last(); - FileName = fileNameWithoutExtension + ".otf"; - Location = new Uri(source.OriginalString.Replace("." + FileName, string.Empty), UriKind.RelativeOrAbsolute); - } else { - Location = source; + if (source.AbsolutePath.Contains(".otf")) + { + var filePathWithoutExtension = source.AbsolutePath.Replace(".otf", string.Empty); + var fileNameWithoutExtension = filePathWithoutExtension.Split('.').Last(); + FileName = fileNameWithoutExtension + ".otf"; + Location = new Uri(source.OriginalString.Replace("." + FileName, string.Empty), UriKind.RelativeOrAbsolute); + } + else + { + Location = source; + } } - } + } /// /// Location of stored font asset that belongs to a From 1bb863134030f5d1ed752124dbb9b6ecb1113d5d Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Sat, 27 Oct 2018 11:26:40 +0200 Subject: [PATCH 3/6] Remove extra whitespaces --- src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs b/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs index 99b0091139..90ccac0e46 100644 --- a/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs +++ b/src/Avalonia.Visuals/Media/Fonts/FontFamilyKey.cs @@ -43,7 +43,7 @@ namespace Avalonia.Media.Fonts Location = source; } } - } + } /// /// Location of stored font asset that belongs to a From f23b1a672d8cc33f3e8a73ab103901b5cbab1123 Mon Sep 17 00:00:00 2001 From: Tom Daffin Date: Wed, 24 Oct 2018 05:23:15 -0600 Subject: [PATCH 4/6] Fix a crash when pressing F10 on a window that has no main menu --- src/Avalonia.Input/AccessKeyHandler.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Input/AccessKeyHandler.cs b/src/Avalonia.Input/AccessKeyHandler.cs index b36e145d44..d80acbcd34 100644 --- a/src/Avalonia.Input/AccessKeyHandler.cs +++ b/src/Avalonia.Input/AccessKeyHandler.cs @@ -234,8 +234,10 @@ namespace Avalonia.Input case Key.F10: _owner.ShowAccessKeys = _showingAccessKeys = true; - MainMenu.Open(); - e.Handled = true; + if (MainMenu != null){ + MainMenu.Open(); + e.Handled = true; + } break; } } From 1fff6937301d1f932d94ebe6c4d5631ee1b049a6 Mon Sep 17 00:00:00 2001 From: Tom Daffin Date: Sun, 28 Oct 2018 19:21:08 -0600 Subject: [PATCH 5/6] Fix brace style --- src/Avalonia.Input/AccessKeyHandler.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Input/AccessKeyHandler.cs b/src/Avalonia.Input/AccessKeyHandler.cs index d80acbcd34..29768513f3 100644 --- a/src/Avalonia.Input/AccessKeyHandler.cs +++ b/src/Avalonia.Input/AccessKeyHandler.cs @@ -234,7 +234,8 @@ namespace Avalonia.Input case Key.F10: _owner.ShowAccessKeys = _showingAccessKeys = true; - if (MainMenu != null){ + if (MainMenu != null) + { MainMenu.Open(); e.Handled = true; } From f5f8d1594c21ea35af4679215bf71497e13f0802 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Sun, 28 Oct 2018 23:41:18 -0700 Subject: [PATCH 6/6] Publish test results and make task names more readable. --- azure-pipelines.yml | 66 ++++++++++++++++++++++++++++++++++----------- build.cake | 22 ++++++++++----- parameters.cake | 6 ++++- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 00fe51534c..5156bac3b5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -4,20 +4,31 @@ jobs: vmImage: 'ubuntu-16.04' steps: - task: CmdLine@2 + displayName: 'Install CastXML' inputs: script: | sudo apt-get update sudo apt-get install castxml + - task: CmdLine@2 + displayName: 'Install Cake' inputs: script: | dotnet tool install -g Cake.Tool --version 0.30.0 - - script: | - export PATH="$PATH:$HOME/.dotnet/tools" - dotnet --info - printenv - dotnet cake build.cake -target="Azure-Linux" -configuration="Release" + - task: CmdLine@2 + displayName: 'Run Cake' + inputs: + script: | + export PATH="$PATH:$HOME/.dotnet/tools" + dotnet --info + printenv + dotnet cake build.cake -target="Azure-Linux" -configuration="Release" + + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'VSTest' + testResultsFiles: '$(Build.SourcesDirectory)/artifacts/test-results/*.trx' - job: macOS pool: @@ -26,6 +37,7 @@ jobs: - task: DotNetCoreInstaller@0 inputs: version: '2.1.403' + - task: Xcode@5 inputs: actions: 'build' @@ -35,29 +47,43 @@ jobs: xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace' xcodeVersion: 'default' # Options: 8, 9, default, specifyPath args: '-derivedDataPath ./' + - task: CmdLine@2 + displayName: 'Install CastXML' inputs: script: brew install castxml + - task: CmdLine@2 + displayName: 'Install Cake' inputs: script: | dotnet tool install -g Cake.Tool --version 0.30.0 - - script: | - export COREHOST_TRACE=0 - export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 - export DOTNET_CLI_TELEMETRY_OPTOUT=1 - which dotnet - dotnet --info - export PATH="$PATH:$HOME/.dotnet/tools" - dotnet --info - printenv - dotnet cake build.cake -target="Azure-OSX" -configuration="Release" + + - task: CmdLine@2 + displayName: 'Run Cake' + inputs: + script: | + export COREHOST_TRACE=0 + export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 + export DOTNET_CLI_TELEMETRY_OPTOUT=1 + which dotnet + dotnet --info + export PATH="$PATH:$HOME/.dotnet/tools" + dotnet --info + printenv + dotnet cake build.cake -target="Azure-OSX" -configuration="Release" + + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'VSTest' + testResultsFiles: '$(Build.SourcesDirectory)/artifacts/test-results/*.trx' - task: PublishBuildArtifacts@1 inputs: pathToPublish: '$(Build.SourcesDirectory)/Build/Products/Release/' artifactName: 'Avalonia.Native.OSX' condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false)) + - task: PublishBuildArtifacts@1 inputs: pathtoPublish: '$(Build.SourcesDirectory)/artifacts/nuget' @@ -69,19 +95,29 @@ jobs: vmImage: 'vs2017-win2016' steps: - task: CmdLine@2 + displayName: 'Install Cake' inputs: script: | dotnet tool install -g Cake.Tool --version 0.30.0 + - task: CmdLine@2 + displayName: 'Run Cake' inputs: script: | set PATH=%PATH%;%USERPROFILE%\.dotnet\tools dotnet cake build.cake -target="Azure-Windows" -configuration="Release" + + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'VSTest' + testResultsFiles: '$(Build.SourcesDirectory)/artifacts/test-results/*.trx' + - task: PublishBuildArtifacts@1 inputs: pathtoPublish: '$(Build.SourcesDirectory)/artifacts/nuget' artifactName: 'NuGet' condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false)) + - task: PublishBuildArtifacts@1 inputs: pathToPublish: '$(Build.SourcesDirectory)/artifacts/zip' diff --git a/build.cake b/build.cake index c074578f95..c781c0f2e5 100644 --- a/build.cake +++ b/build.cake @@ -78,6 +78,7 @@ Task("Clean-Impl") CleanDirectory(data.ArtifactsDir); CleanDirectory(data.NugetRoot); CleanDirectory(data.ZipRoot); + CleanDirectory(data.TestResultsRoot); }); void DotNetCoreBuild(Parameters parameters) @@ -129,13 +130,20 @@ void RunCoreTest(string project, Parameters parameters, bool coreOnly = false) continue; Information("Running for " + fw); - DotNetCoreTest(project, - new DotNetCoreTestSettings { - Configuration = parameters.Configuration, - Framework = fw, - NoBuild = true, - NoRestore = true - }); + var settings = new DotNetCoreTestSettings { + Configuration = parameters.Configuration, + Framework = fw, + NoBuild = true, + NoRestore = true + }; + + if (parameters.PublishTestResults) + { + settings.Logger = "trx"; + settings.ResultsDirectory = parameters.TestResultsRoot; + } + + DotNetCoreTest(project, settings); } } diff --git a/parameters.cake b/parameters.cake index 7db344c41c..8d813accbb 100644 --- a/parameters.cake +++ b/parameters.cake @@ -22,11 +22,13 @@ public class Parameters public bool IsReleasable { get; private set; } public bool IsMyGetRelease { get; private set; } public bool IsNuGetRelease { get; private set; } + public bool PublishTestResults { get; private set; } public string Version { get; private set; } public DirectoryPath ArtifactsDir { get; private set; } public DirectoryPath NugetRoot { get; private set; } public DirectoryPath ZipRoot { get; private set; } public DirectoryPath BinRoot { get; private set; } + public DirectoryPath TestResultsRoot { get; private set; } public string DirSuffix { get; private set; } public DirectoryPathCollection BuildDirs { get; private set; } public string FileZipSuffix { get; private set; } @@ -91,7 +93,8 @@ public class Parameters else if (IsRunningOnAzure) { // Use AssemblyVersion with Build as version - Version += "-build" + context.EnvironmentVariable("BUILD_BUILDID") + "-beta"; + Version += "-build" + context.EnvironmentVariable("BUILD_BUILDID") + "-beta"; + PublishTestResults = true; } // DIRECTORIES @@ -99,6 +102,7 @@ public class Parameters NugetRoot = ArtifactsDir.Combine("nuget"); ZipRoot = ArtifactsDir.Combine("zip"); BinRoot = ArtifactsDir.Combine("bin"); + TestResultsRoot = ArtifactsDir.Combine("test-results"); BuildDirs = context.GetDirectories("**/bin") + context.GetDirectories("**/obj"); DirSuffix = Configuration; FileZipSuffix = Version + ".zip";