Explorar o código

Move font assets to a dedicated package

Benedikt Stebner %!s(int64=2) %!d(string=hai) anos
pai
achega
a6d42cb8b4

+ 7 - 1
Avalonia.sln

@@ -231,12 +231,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlCatalog.Browser.Blaz
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUIDemo", "samples\ReactiveUIDemo\ReactiveUIDemo.csproj", "{75C47156-C5D8-44BC-A5A7-E8657C2248D6}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GpuInterop", "samples\GpuInterop\GpuInterop.csproj", "{C810060E-3809-4B74-A125-F11533AF9C1B}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GpuInterop", "samples\GpuInterop\GpuInterop.csproj", "{C810060E-3809-4B74-A125-F11533AF9C1B}"
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Controls.ItemsRepeater", "src\Avalonia.Controls.ItemsRepeater\Avalonia.Controls.ItemsRepeater.csproj", "{EE0F0DD4-A70D-472B-BD5D-B7D32D0E9386}"
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Controls.ItemsRepeater.UnitTests", "tests\Avalonia.Controls.ItemsRepeater.UnitTests\Avalonia.Controls.ItemsRepeater.UnitTests.csproj", "{F4E36AA8-814E-4704-BC07-291F70F45193}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Themes.Fluent.Fonts", "src\Avalonia.Themes.Fluent.Fonts\Avalonia.Themes.Fluent.Fonts.csproj", "{5E19C5EF-19D7-4E70-9050-48DAE7FF5FA4}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -560,6 +562,10 @@ Global
 		{F4E36AA8-814E-4704-BC07-291F70F45193}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{F4E36AA8-814E-4704-BC07-291F70F45193}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{F4E36AA8-814E-4704-BC07-291F70F45193}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5E19C5EF-19D7-4E70-9050-48DAE7FF5FA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5E19C5EF-19D7-4E70-9050-48DAE7FF5FA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5E19C5EF-19D7-4E70-9050-48DAE7FF5FA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5E19C5EF-19D7-4E70-9050-48DAE7FF5FA4}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 1 - 0
samples/ControlCatalog/ControlCatalog.csproj

@@ -29,6 +29,7 @@
     <ProjectReference Include="..\..\src\Avalonia.Controls.ItemsRepeater\Avalonia.Controls.ItemsRepeater.csproj" />
     <ProjectReference Include="..\..\src\Avalonia.Themes.Simple\Avalonia.Themes.Simple.csproj" />
     <ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
+    <ProjectReference Include="..\..\src\Avalonia.Themes.Fluent.Fonts\Avalonia.Themes.Fluent.Fonts.csproj" />
     <ProjectReference Include="..\MiniMvvm\MiniMvvm.csproj" />
     <ProjectReference Include="..\SampleControls\ControlSamples.csproj" />
   </ItemGroup>

+ 0 - 0
src/Avalonia.Themes.Fluent/Assets/Inter-Bold.ttf → src/Avalonia.Themes.Fluent.Fonts/Assets/Inter-Bold.ttf


+ 0 - 0
src/Avalonia.Themes.Fluent/Assets/Inter-ExtraLight.ttf → src/Avalonia.Themes.Fluent.Fonts/Assets/Inter-ExtraLight.ttf


+ 0 - 0
src/Avalonia.Themes.Fluent/Assets/Inter-Light.ttf → src/Avalonia.Themes.Fluent.Fonts/Assets/Inter-Light.ttf


+ 0 - 0
src/Avalonia.Themes.Fluent/Assets/Inter-Medium.ttf → src/Avalonia.Themes.Fluent.Fonts/Assets/Inter-Medium.ttf


+ 0 - 0
src/Avalonia.Themes.Fluent/Assets/Inter-Regular.ttf → src/Avalonia.Themes.Fluent.Fonts/Assets/Inter-Regular.ttf


+ 0 - 0
src/Avalonia.Themes.Fluent/Assets/Inter-SemiBold.ttf → src/Avalonia.Themes.Fluent.Fonts/Assets/Inter-SemiBold.ttf


+ 0 - 0
src/Avalonia.Themes.Fluent/Assets/Inter-Thin.ttf → src/Avalonia.Themes.Fluent.Fonts/Assets/Inter-Thin.ttf


+ 17 - 0
src/Avalonia.Themes.Fluent.Fonts/Avalonia.Themes.Fluent.Fonts.csproj

@@ -0,0 +1,17 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
+    <!-- NativeMenuBar uses ReflectionBinding -->
+    <NoWarn>$(NoWarn);IL2026</NoWarn>
+  </PropertyGroup>
+  <ItemGroup>
+    <AvaloniaResource Include="Assets\*" />  
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" />
+  </ItemGroup>
+  <Import Project="..\..\build\NullableEnable.props" />
+  <Import Project="..\..\build\BuildTargets.targets" />
+  <Import Project="..\..\build\ApiDiff.props" />
+  <Import Project="..\..\build\TrimmingEnable.props" />
+</Project>

+ 3 - 0
src/Avalonia.Themes.Fluent.Fonts/Properties/AssemblyInfo.cs

@@ -0,0 +1,3 @@
+using Avalonia.Metadata;
+
+[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Themes.Fluent.Fonts")]

+ 1 - 1
src/Avalonia.Themes.Fluent/Accents/Base.xaml

@@ -3,7 +3,7 @@
                     xmlns:sys="using:System"
                     xmlns:converters="using:Avalonia.Controls.Converters">
   <!-- https://docs.microsoft.com/en-us/previous-versions/windows/apps/dn518235(v=win.10)?redirectedfrom=MSDN -->
-  <FontFamily x:Key="ContentControlThemeFontFamily">avares://Avalonia.Themes.Fluent/Assets#Inter</FontFamily>
+  <FontFamily x:Key="ContentControlThemeFontFamily">avares://Avalonia.Themes.Fluent.Fonts/Assets#Inter, $Default</FontFamily>
   <sys:Double x:Key="ControlContentThemeFontSize">14</sys:Double>
 
   <SolidColorBrush x:Key="SystemControlTransparentBrush" Color="Transparent" />

+ 1 - 2
src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj

@@ -9,8 +9,7 @@
     <ProjectReference Include="..\Avalonia.Controls\Avalonia.Controls.csproj" />
     <ProjectReference Include="..\Avalonia.Dialogs\Avalonia.Dialogs.csproj" />
     <ProjectReference Include="..\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj" />
-    <AvaloniaResource Include="**/*.xaml" />
-    <AvaloniaResource Include="Assets\*" />  
+    <AvaloniaResource Include="**/*.xaml" />  
   </ItemGroup>
   <Import Project="..\..\build\NullableEnable.props" />
   <Import Project="..\..\build\BuildTargets.targets" />

+ 9 - 8
src/Skia/Avalonia.Skia/FontManagerImpl.cs

@@ -106,7 +106,14 @@ namespace Avalonia.Skia
         {
             SKTypeface skTypeface = null;
 
-            if (typeface.FontFamily.Key == null)
+            if(typeface.FontFamily.Key != null)
+            {
+                var fontCollection = SKTypefaceCollectionCache.GetOrAddTypefaceCollection(typeface.FontFamily);
+
+                skTypeface = fontCollection.Get(typeface);
+            }
+
+            if (skTypeface is null)
             {
                 var defaultName = SKTypeface.Default.FamilyName;
 
@@ -135,13 +142,7 @@ namespace Avalonia.Skia
                 skTypeface ??= _skFontManager.MatchTypeface(SKTypeface.Default, fontStyle)
                     ?? SKTypeface.Default;
             }
-            else
-            {
-                var fontCollection = SKTypefaceCollectionCache.GetOrAddTypefaceCollection(typeface.FontFamily);
-
-                skTypeface = fontCollection.Get(typeface);
-            }
-
+           
             if (skTypeface == null)
             {
                 throw new InvalidOperationException(