Browse Source

Merge pull request #10293 from Gillibald/feature/moveThemeFontAssets

Move theme font assets to a dedicated package
pull/10476/head
Max Katz 4 years ago
committed by GitHub
parent
commit
cb5bcc5f4a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      Avalonia.sln
  2. 1
      samples/ControlCatalog/ControlCatalog.csproj
  3. BIN
      src/Avalonia.Fonts.Inter/Assets/Inter-Bold.otf
  4. BIN
      src/Avalonia.Fonts.Inter/Assets/Inter-ExtraLight.otf
  5. BIN
      src/Avalonia.Fonts.Inter/Assets/Inter-Light.otf
  6. BIN
      src/Avalonia.Fonts.Inter/Assets/Inter-Medium.otf
  7. BIN
      src/Avalonia.Fonts.Inter/Assets/Inter-Regular.otf
  8. BIN
      src/Avalonia.Fonts.Inter/Assets/Inter-SemiBold.otf
  9. BIN
      src/Avalonia.Fonts.Inter/Assets/Inter-Thin.otf
  10. 13
      src/Avalonia.Fonts.Inter/Avalonia.Fonts.Inter.csproj
  11. 3
      src/Avalonia.Fonts.Inter/Properties/AssemblyInfo.cs
  12. 2
      src/Avalonia.Themes.Fluent/Accents/Base.xaml
  13. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-Bold.ttf
  14. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-ExtraLight.ttf
  15. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-Light.ttf
  16. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-Medium.ttf
  17. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-Regular.ttf
  18. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-SemiBold.ttf
  19. BIN
      src/Avalonia.Themes.Fluent/Assets/Inter-Thin.ttf
  20. 3
      src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj
  21. 1
      src/Avalonia.Themes.Fluent/Controls/EmbeddableControlRoot.xaml
  22. 1
      src/Avalonia.Themes.Simple/Accents/Base.xaml
  23. 1
      src/Avalonia.Themes.Simple/Controls/EmbeddableControlRoot.xaml
  24. 4
      src/Avalonia.Themes.Simple/Controls/OverlayPopupHost.xaml
  25. 4
      src/Avalonia.Themes.Simple/Controls/PopupRoot.xaml
  26. 1
      src/Avalonia.Themes.Simple/Controls/Window.xaml
  27. 23
      src/Skia/Avalonia.Skia/FontManagerImpl.cs
  28. 1
      src/Skia/Avalonia.Skia/Helpers/DrawingContextHelper.cs
  29. 3
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs

6
Avalonia.sln

@ -244,6 +244,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Controls.ItemsRepe
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("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Fonts.Inter", "src\Avalonia.Fonts.Inter\Avalonia.Fonts.Inter.csproj", "{13F1135D-BA1A-435C-9C5B-A368D1D63DE4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -571,6 +573,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
{13F1135D-BA1A-435C-9C5B-A368D1D63DE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13F1135D-BA1A-435C-9C5B-A368D1D63DE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13F1135D-BA1A-435C-9C5B-A368D1D63DE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13F1135D-BA1A-435C-9C5B-A368D1D63DE4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

1
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.Fonts.Inter\Avalonia.Fonts.Inter.csproj" />
<ProjectReference Include="..\MiniMvvm\MiniMvvm.csproj" />
<ProjectReference Include="..\SampleControls\ControlSamples.csproj" />
</ItemGroup>

BIN
src/Avalonia.Fonts.Inter/Assets/Inter-Bold.otf

Binary file not shown.

BIN
src/Avalonia.Fonts.Inter/Assets/Inter-ExtraLight.otf

Binary file not shown.

BIN
src/Avalonia.Fonts.Inter/Assets/Inter-Light.otf

Binary file not shown.

BIN
src/Avalonia.Fonts.Inter/Assets/Inter-Medium.otf

Binary file not shown.

BIN
src/Avalonia.Fonts.Inter/Assets/Inter-Regular.otf

Binary file not shown.

BIN
src/Avalonia.Fonts.Inter/Assets/Inter-SemiBold.otf

Binary file not shown.

BIN
src/Avalonia.Fonts.Inter/Assets/Inter-Thin.otf

Binary file not shown.

13
src/Avalonia.Fonts.Inter/Avalonia.Fonts.Inter.csproj

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<PackageId>Avalonia.Fonts.Inter</PackageId>
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" />
</ItemGroup>
<Import Project="..\..\build\BuildTargets.targets" />
</Project>

3
src/Avalonia.Fonts.Inter/Properties/AssemblyInfo.cs

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

2
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.Fonts.Inter/Assets#Inter, $Default</FontFamily>
<sys:Double x:Key="ControlContentThemeFontSize">14</sys:Double>
<SolidColorBrush x:Key="SystemControlTransparentBrush" Color="Transparent" />

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-Bold.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-ExtraLight.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-Light.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-Medium.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-Regular.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-SemiBold.ttf

Binary file not shown.

BIN
src/Avalonia.Themes.Fluent/Assets/Inter-Thin.ttf

Binary file not shown.

3
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" />

1
src/Avalonia.Themes.Fluent/Controls/EmbeddableControlRoot.xaml

@ -4,6 +4,7 @@
<Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}"/>
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundAltHighBrush}"/>
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}"/>
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="Template">
<ControlTemplate>
<Panel>

1
src/Avalonia.Themes.Simple/Accents/Base.xaml

@ -76,6 +76,7 @@
<SolidColorBrush x:Key="RefreshVisualizerBackground" Color="Transparent" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<FontFamily x:Key="ContentControlThemeFontFamily">avares://Avalonia.Fonts.Inter/Assets#Inter, $Default</FontFamily>
<Color x:Key="ThemeAccentColor">#CC119EDA</Color>
<Color x:Key="ThemeAccentColor2">#99119EDA</Color>
<Color x:Key="ThemeAccentColor3">#66119EDA</Color>

1
src/Avalonia.Themes.Simple/Controls/EmbeddableControlRoot.xaml

@ -5,6 +5,7 @@
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="Template">
<ControlTemplate>
<Panel>

4
src/Avalonia.Themes.Simple/Controls/OverlayPopupHost.xaml

@ -4,9 +4,7 @@
TargetType="OverlayPopupHost">
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
<Setter Property="FontFamily" Value="{x:Static FontFamily.Default}" />
<Setter Property="FontWeight" Value="400" />
<Setter Property="FontStyle" Value="Normal" />
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="Template">
<ControlTemplate>
<!-- Do not forget to update Templated_Control_With_Popup_In_Template_Should_Set_TemplatedParent test -->

4
src/Avalonia.Themes.Simple/Controls/PopupRoot.xaml

@ -6,9 +6,7 @@
<Setter Property="TransparencyLevelHint" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
<Setter Property="FontFamily" Value="{x:Static FontFamily.Default}" />
<Setter Property="FontWeight" Value="400" />
<Setter Property="FontStyle" Value="Normal" />
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="Template">
<ControlTemplate>
<LayoutTransformControl LayoutTransform="{TemplateBinding Transform}">

1
src/Avalonia.Themes.Simple/Controls/Window.xaml

@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="{x:Type Window}"
TargetType="Window">
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}" />
<Setter Property="TransparencyBackgroundFallback" Value="{DynamicResource HighlightForegroundColor}" />
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />

23
src/Skia/Avalonia.Skia/FontManagerImpl.cs

@ -99,7 +99,20 @@ namespace Avalonia.Skia
{
SKTypeface? skTypeface = null;
if (typeface.FontFamily.Key is null)
if(typeface.FontFamily.Key is not null)
{
var fontCollection = SKTypefaceCollectionCache.GetOrAddTypefaceCollection(typeface.FontFamily);
skTypeface = fontCollection.Get(typeface);
if (skTypeface is null && !typeface.FontFamily.FamilyNames.HasFallbacks)
{
throw new InvalidOperationException(
$"Could not create glyph typeface for: {typeface.FontFamily.Name}.");
}
}
if (skTypeface is null)
{
var defaultName = SKTypeface.Default.FamilyName;
@ -128,13 +141,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(

1
src/Skia/Avalonia.Skia/Helpers/DrawingContextHelper.cs

@ -13,7 +13,6 @@ namespace Avalonia.Skia.Helpers
/// </summary>
/// <param name="canvas"></param>
/// <param name="dpi"></param>
/// <param name="visualBrushRenderer"></param>
/// <returns>DrawingContext</returns>
public static IDrawingContextImpl WrapSkiaCanvas(SKCanvas canvas, Vector dpi)
{

3
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs

@ -702,9 +702,10 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml
// EndInit should be second-to-last operation, as last operation will be
// caused by styling being applied on EndInit.
Assert.Equal("EndInit 0", tracker.Order[tracker.Order.Count - 2]);
Assert.Equal("EndInit 0", tracker.Order[tracker.Order.Count - 3]);
// Caused by styling.
Assert.Equal("Property FontFamily Changed", tracker.Order[tracker.Order.Count - 2]);
Assert.Equal("Property Foreground Changed", tracker.Order[tracker.Order.Count - 1]);
}
}

Loading…
Cancel
Save