Skip to content

Commit

Permalink
v1.1.229
Browse files Browse the repository at this point in the history
  • Loading branch information
davidxuang committed Feb 23, 2024
1 parent 5c24237 commit 69d2b30
Show file tree
Hide file tree
Showing 20 changed files with 113 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
submodules: true
- name: Setup .NET
run: dotnet workload install android ios maccatalyst
run: dotnet workload install android ios maccatalyst macos
- name: Setup Java
uses: actions/setup-java@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,6 @@ $RECYCLE.BIN/
# !.vscode/tasks.json
# !.vscode/launch.json
# !.vscode/extensions.json


*Avalonia*/Assets/*.ttf
1 change: 0 additions & 1 deletion FluentIcons.Avalonia.Fluent/Assets/FluentSystemIcons.ttf

This file was deleted.

1 change: 0 additions & 1 deletion FluentIcons.Avalonia.Fluent/Assets/SeagullFluentIcons.ttf

This file was deleted.

3 changes: 1 addition & 2 deletions FluentIcons.Avalonia.Fluent/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ public static class Extensions
{
public static AppBuilder UseSegoeMetrics(this AppBuilder builder)
{
SymbolIcon.UseSegoeMetricsProperty.OverrideDefaultValue(typeof(SymbolIcon), true);
SymbolIcon.UseSegoeMetricsProperty.OverrideDefaultValue(typeof(SymbolIconSource), true);
SymbolIcon.UseSegoeMetricsDefaultValue = true;
return builder;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@

<ItemGroup>
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0" />
<PackageReference Condition="$(TargetFramework) == 'netstandard2.0'" Include="Nullable" Version="1.3.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FluentIcons.Common\FluentIcons.Common.csproj" ExactVersion="true" />
<SharedAssets Include="../seagull-icons/assets/*.ttf" />
</ItemGroup>

<Target Name="CopySharedAssets" BeforeTargets="AddAvaloniaResources">
<Copy SourceFiles="@(SharedAssets)" DestinationFolder="Assets" UseHardlinksIfPossible="true" />
</Target>

<ItemGroup>
<AvaloniaResource Include="Assets\FluentSystemIcons.ttf" />
<AvaloniaResource Include="Assets\SeagullFluentIcons.ttf" />
<AvaloniaResource Include="Assets\*.ttf" />
</ItemGroup>

</Project>
15 changes: 11 additions & 4 deletions FluentIcons.Avalonia.Fluent/SymbolIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ namespace FluentIcons.Avalonia.Fluent
[TypeConverter(typeof(SymbolIconConverter))]
public partial class SymbolIcon : FAIconElement
{
internal static readonly Typeface System = new(new FontFamily("avares://FluentIcons.Avalonia/Assets#Fluent System Icons"));
internal static readonly Typeface Seagull = new(new FontFamily("avares://FluentIcons.Avalonia/Assets#Seagull Fluent Icons"));
internal static readonly Typeface System = new("avares://FluentIcons.Avalonia.Fluent/Assets#Fluent System Icons");
internal static readonly Typeface Seagull = new("avares://FluentIcons.Avalonia.Fluent/Assets#Seagull Fluent Icons");
internal static bool UseSegoeMetricsDefaultValue = false;

public static readonly StyledProperty<Symbol> SymbolProperty =
AvaloniaProperty.Register<SymbolIcon, Symbol>(nameof(Symbol), Symbol.Home);
Expand All @@ -29,6 +30,11 @@ public partial class SymbolIcon : FAIconElement
private bool _suspendCreate = true;
private TextLayout? _textLayout;

public SymbolIcon()
{
UseSegoeMetrics = UseSegoeMetricsDefaultValue;
}

public Symbol Symbol
{
get => GetValue(SymbolProperty);
Expand All @@ -55,14 +61,15 @@ public double FontSize

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
if (change.Property == TextElement.FontSizeProperty)
if (change.Property == FontSizeProperty)
{
InvalidateMeasure();
InvalidateText();
}
else if (change.Property == TextElement.ForegroundProperty ||
change.Property == SymbolProperty ||
change.Property == IsFilledProperty)
change.Property == IsFilledProperty ||
change.Property == UseSegoeMetricsProperty)
{
InvalidateText();
}
Expand Down
88 changes: 64 additions & 24 deletions FluentIcons.Avalonia.Fluent/SymbolIconSource.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Avalonia;
using Avalonia.Media;
Expand All @@ -10,26 +11,25 @@
namespace FluentIcons.Avalonia.Fluent
{
[TypeConverter(typeof(SymbolIconSourceConverter))]
public class SymbolIconSource : PathIconSource
public class SymbolIconSource : FontIconSource
{
private static readonly IGlyphTypeface _system = SymbolIcon.System.GlyphTypeface;
private static readonly IGlyphTypeface _seagull = SymbolIcon.Seagull.GlyphTypeface;

public static readonly StyledProperty<Symbol> SymbolProperty = SymbolIcon.SymbolProperty.AddOwner<SymbolIconSource>();
public static readonly StyledProperty<bool> IsFilledProperty = SymbolIcon.IsFilledProperty.AddOwner<SymbolIconSource>();
public static readonly StyledProperty<bool> UseSegoeMetricsProperty = SymbolIcon.UseSegoeMetricsProperty.AddOwner<SymbolIconSource>();
public static readonly StyledProperty<FlowDirection> FlowDirectionProperty = Visual.FlowDirectionProperty.AddOwner<SymbolIconSource>();
public static readonly StyledProperty<double> FontSizeProperty = SymbolIcon.FontSizeProperty.AddOwner<SymbolIconSource>();
public static new readonly StyledProperty<double> FontSizeProperty = SymbolIcon.FontSizeProperty.AddOwner<SymbolIconSource>();

private Geometry _data;
private string _glyph;

#pragma warning disable CS8618
public SymbolIconSource()
{
Stretch = Stretch.None;
InvalidateData();
UseSegoeMetrics = SymbolIcon.UseSegoeMetricsDefaultValue;
base.FontSize = FontSize;
FontFamily = UseSegoeMetrics ? SymbolIcon.Seagull.FontFamily : SymbolIcon.System.FontFamily;
FontStyle = FontStyle.Normal;
FontWeight = FontWeight.Regular;
InvalidateGlyph();
}
#pragma warning restore CS8618

public Symbol Symbol
{
Expand All @@ -55,36 +55,76 @@ public FlowDirection FlowDirection
set => SetValue(FlowDirectionProperty, value);
}

public double FontSize
public new double FontSize
{
get => GetValue(FontSizeProperty);
set => SetValue(FontSizeProperty, value);
}

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);

if (change.Property == SymbolProperty || change.Property == IsFilledProperty || change.Property == FontSizeProperty)
if (change.Property == SymbolProperty
|| change.Property == IsFilledProperty
|| change.Property == UseSegoeMetricsProperty
|| change.Property == FontSizeProperty)
{
InvalidateGlyph();
return;
}
else if (change.Property == FontSizeProperty)
{
base.FontSize = FontSize;
return;
}
else if (change.Property == FontIconSource.FontSizeProperty)
{
InvalidateData();
if (base.FontSize != FontSize)
{
base.FontSize = FontSize;
return;
}
}
else if (change.Property == DataProperty || _data != change.NewValue as Geometry)
else if (change.Property == GlyphProperty)
{
Data = _data;
if (Glyph != _glyph)
{
Glyph = _glyph;
return;
}
}
else if (change.Property == StretchProperty || Stretch.None != (Stretch)change.NewValue)
else if (change.Property == FontFamilyProperty)
{
Stretch = Stretch.None;
var ff = UseSegoeMetrics ? SymbolIcon.Seagull.FontFamily : SymbolIcon.System.FontFamily;
if (FontFamily != ff)
{
FontFamily = ff;
return;
}
}
else if (change.Property == FontStyleProperty)
{
if (FontStyle != FontStyle.Normal)
{
FontStyle = FontStyle.Normal;
return;
}
}
else if (change.Property == FontWeightProperty)
{
if (FontWeight != FontWeight.Regular)
{
FontWeight = FontWeight.Regular;
return;
}
}

base.OnPropertyChanged(change);
}

private void InvalidateData()
[MemberNotNull(nameof(_glyph))]
private void InvalidateGlyph()
{
var codepoint = Symbol.ToChar(IsFilled, FlowDirection == FlowDirection.RightToLeft);
var typeface = UseSegoeMetrics ? _seagull : _system;
using var glyphRun = new GlyphRun(typeface, FontSize, new[] { codepoint }, new[] { typeface.GetGlyph(codepoint) });
Data = _data = glyphRun.BuildGeometry();
Glyph = _glyph = Symbol.ToString(IsFilled, FlowDirection == FlowDirection.RightToLeft);
}
}

Expand Down
1 change: 0 additions & 1 deletion FluentIcons.Avalonia/Assets/FluentSystemIcons.ttf

This file was deleted.

1 change: 0 additions & 1 deletion FluentIcons.Avalonia/Assets/SeagullFluentIcons.ttf

This file was deleted.

2 changes: 1 addition & 1 deletion FluentIcons.Avalonia/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static class Extensions
{
public static AppBuilder UseSegoeMetrics(this AppBuilder builder)
{
SymbolIcon.UseSegoeMetricsProperty.OverrideDefaultValue(typeof(SymbolIcon), true);
SymbolIcon.UseSegoeMetricsDefaultValue = true;
return builder;
}
}
Expand Down
8 changes: 6 additions & 2 deletions FluentIcons.Avalonia/FluentIcons.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@

<ItemGroup>
<ProjectReference Include="..\FluentIcons.Common\FluentIcons.Common.csproj" ExactVersion="true" />
<SharedAssets Include="../seagull-icons/assets/*.ttf" />
</ItemGroup>

<Target Name="CopySharedAssets" BeforeTargets="AddAvaloniaResources">
<Copy SourceFiles="@(SharedAssets)" DestinationFolder="Assets" UseHardlinksIfPossible="true" />
</Target>

<ItemGroup>
<AvaloniaResource Include="Assets\FluentSystemIcons.ttf" />
<AvaloniaResource Include="Assets\SeagullFluentIcons.ttf" />
<AvaloniaResource Include="Assets\*.ttf" />
</ItemGroup>

</Project>
21 changes: 14 additions & 7 deletions FluentIcons.Avalonia/SymbolIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ namespace FluentIcons.Avalonia
[TypeConverter(typeof(SymbolIconConverter))]
public class SymbolIcon : IconElement
{
private static readonly Typeface _system = new(new FontFamily("avares://FluentIcons.Avalonia/Assets#Fluent System Icons"));
private static readonly Typeface _seagull = new(new FontFamily("avares://FluentIcons.Avalonia/Assets#Seagull Fluent Icons"));

private bool _suspendCreate = true;
private TextLayout? _textLayout;
private static readonly Typeface _system = new("avares://FluentIcons.Avalonia/Assets#Fluent System Icons");
private static readonly Typeface _seagull = new("avares://FluentIcons.Avalonia/Assets#Seagull Fluent Icons");
internal static bool UseSegoeMetricsDefaultValue = false;

public static readonly StyledProperty<Symbol> SymbolProperty =
AvaloniaProperty.Register<SymbolIcon, Symbol>(nameof(Symbol), Symbol.Home);
Expand All @@ -29,6 +27,14 @@ public class SymbolIcon : IconElement
public static readonly new StyledProperty<double> FontSizeProperty =
AvaloniaProperty.Register<SymbolIcon, double>(nameof(FontSize), 20d, false);

private bool _suspendCreate = true;
private TextLayout? _textLayout;

public SymbolIcon()
{
UseSegoeMetrics = UseSegoeMetricsDefaultValue;
}

public Symbol Symbol
{
get => GetValue(SymbolProperty);
Expand Down Expand Up @@ -62,11 +68,12 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
}
else if (change.Property == TextElement.ForegroundProperty ||
change.Property == SymbolProperty ||
change.Property == IsFilledProperty)
change.Property == IsFilledProperty ||
change.Property == UseSegoeMetricsProperty)
{
InvalidateText();
}

base.OnPropertyChanged(change);
}

Expand Down
5 changes: 0 additions & 5 deletions FluentIcons.Common/Internals/SymbolConversion.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System;
using System.Linq;
using System.Runtime.CompilerServices;

namespace FluentIcons.Common.Internals
{
internal static class SymbolConversion
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static char ToChar(this Symbol symbol, bool isFilled, bool isRtl)
=> char.ConvertFromUtf32((int)symbol + Convert.ToInt32(isFilled) + (Convert.ToInt32(isRtl) << 1)).Single();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static string ToString(this Symbol symbol, bool isFilled, bool isRtl)
=> char.ConvertFromUtf32((int)symbol + Convert.ToInt32(isFilled) + (Convert.ToInt32(isRtl) << 1));
Expand Down
2 changes: 1 addition & 1 deletion FluentIcons.WPF/SymbolIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private void InvalidateText()
return;

_formattedText = new FormattedText(
Symbol.ToString(IsFilled, FlowDirection == FlowDirection.LeftToRight),
Symbol.ToString(IsFilled, FlowDirection == FlowDirection.RightToLeft),
CultureInfo.CurrentCulture,
FlowDirection,
UseSegoeMetrics ? _seagull : _system,
Expand Down
2 changes: 1 addition & 1 deletion FluentIcons.WinUI/FluentIcons.WinUI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) or '$(EnableWindowsTargeting)' == 'true'">$(TargetFrameworks);net6.0-windows10.0.17763.0;net7.0-windows10.0.17763.0</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);net7.0;net7.0-ios;net7.0-maccatalyst;net7.0-android</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst;net7.0-macos</TargetFrameworks>
<Description>FluentUI System Icons wrapper for WinUI.</Description>
<PackageTags>$(PackageTags);WinUI</PackageTags>
<RootNamespace>FluentIcons.WinUI</RootNamespace>
Expand Down
4 changes: 2 additions & 2 deletions FluentIcons.WinUI/SymbolIconSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public SymbolIconSource()
FontFamily = UseSegoeMetrics ? SymbolIcon.Seagull : SymbolIcon.System;
FontStyle = Windows.UI.Text.FontStyle.Normal;
FontWeight = FontWeights.Normal;
Glyph = _glyph = Symbol.ToString(IsFilled, FlowDirection == FlowDirection.LeftToRight);
Glyph = _glyph = Symbol.ToString(IsFilled, FlowDirection == FlowDirection.RightToLeft);
IsTextScaleFactorEnabled = false;
MirroredWhenRightToLeft = false;

Expand Down Expand Up @@ -73,7 +73,7 @@ private static void OnSymbolPropertiesChanged(DependencyObject d, DependencyProp
if (d is SymbolIconSource inst)
{
inst.FontFamily = inst.UseSegoeMetrics ? SymbolIcon.Seagull : SymbolIcon.System;
inst.Glyph = inst._glyph = inst.Symbol.ToString(inst.IsFilled, inst.FlowDirection == FlowDirection.LeftToRight);
inst.Glyph = inst._glyph = inst.Symbol.ToString(inst.IsFilled, inst.FlowDirection == FlowDirection.RightToLeft);
}
}

Expand Down
Binary file modified seagull-icons/assets/FluentSystemIcons.ttf
Binary file not shown.
Binary file modified seagull-icons/assets/SeagullFluentIcons.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions seagull-icons/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ try {

python "$PSScriptRoot/patch.py" "$PSScriptRoot/obj/FluentSystemIcons.ttf" "$PSScriptRoot/obj/codepoints.json"
python "$PSScriptRoot/patch.py" "$PSScriptRoot/obj/SeagullFluentIcons.ttf" "$PSScriptRoot/obj/codepoints.json"

ttx -m "$PSScriptRoot/obj/FluentSystemIcons.ttf" -o "$PSScriptRoot/obj/FluentSystemIcons.ttf" "$PSScriptRoot/obj/colr/colr.ttx"
ttx -m "$PSScriptRoot/obj/SeagullFluentIcons.ttf" -o "$PSScriptRoot/obj/SeagullFluentIcons.ttf" "$PSScriptRoot/obj/colr/colr.ttx"

Expand Down

0 comments on commit 69d2b30

Please sign in to comment.