icsharpcode / AvaloniaILSpy

Avalonia-based .NET Decompiler (port of ILSpy)
1.52k stars 171 forks source link

Can't open in Linux: System.InvalidOperationException: Default font family name can't be null or empty. Trhown when executing #84

Open zryogi opened 2 years ago

zryogi commented 2 years ago

Steps to reproduce

  1. Download release from https://github.com/icsharpcode/AvaloniaILSpy/releases/tag/v7.0-rc2 linux-x64.zip
  2. Unzip files
  3. Brwose artifacts/linux-64 folder
  4. Execute ./ILSpy
  5. Get:
Sorry, we crashed
Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "ICSharpCode.ILSpy.TextView.DecompilerTextView".
 ---> System.InvalidOperationException: Default font family name can't be null or empty.
   at Avalonia.Media.FontManager..ctor(IFontManagerImpl platformImpl) in /_/src/Avalonia.Visuals/Media/FontManager.cs:line 31
   at Avalonia.Media.FontManager.get_Current() in /_/src/Avalonia.Visuals/Media/FontManager.cs:line 50
   at Avalonia.Skia.FormattedTextImpl..ctor(String text, Typeface typeface, Double fontSize, TextAlignment textAlignment, TextWrapping wrapping, Size constraint, IReadOnlyList`1 spans) in /_/src/Skia/Avalonia.Skia/FormattedTextImpl.cs:line 24
   at Avalonia.Skia.PlatformRenderInterface.CreateFormattedText(String text, Typeface typeface, Double fontSize, TextAlignment textAlignment, TextWrapping wrapping, Size constraint, IReadOnlyList`1 spans) in /_/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs:line 50
   at Avalonia.Media.FormattedText.get_PlatformImpl() in /_/src/Avalonia.Visuals/Media/FormattedText.cs:line 143
   at Avalonia.Media.FormattedText.get_Bounds() in /_/src/Avalonia.Visuals/Media/FormattedText.cs:line 67
   at AvaloniaEdit.Text.TextLineRun.CreateRunForText(StringRange stringRange, TextRun textRun, Double widthLeft, Boolean emergencyWrap, Boolean breakOnTabs)
   at AvaloniaEdit.Text.TextLineRun.Create(TextSource textSource, StringRange stringRange, TextRun textRun, Int32 index, Double widthLeft)
   at AvaloniaEdit.Text.TextLineRun.Create(TextSource textSource, Int32 index, Int32 firstIndex, Double lengthLeft)
   at AvaloniaEdit.Text.TextLineImpl.Create(TextParagraphProperties paragraphProperties, Int32 firstIndex, Int32 paragraphLength, TextSource textSource)
   at AvaloniaEdit.Text.TextFormatter.FormatLine(TextSource textSource, Int32 firstCharIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties)
   at AvaloniaEdit.Rendering.TextView.CalculateDefaultTextMetrics()
   at AvaloniaEdit.Rendering.TextView.get_DefaultLineHeight()
   at AvaloniaEdit.Rendering.TextView.OnDocumentChanged(TextDocument oldValue, TextDocument newValue)
   at AvaloniaEdit.Rendering.TextView.OnDocumentChanged(AvaloniaPropertyChangedEventArgs e)
   at System.Reactive.AnonymousObserver`1.OnNextCore(T value) in /_/Rx.NET/Source/src/System.Reactive/AnonymousObserver.cs:line 67
   at System.Reactive.ObserverBase`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/ObserverBase.cs:line 36
   at System.Reactive.Subjects.Subject`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 147
   at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaPropertyChangedEventArgs`1 change) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 758
   at Avalonia.AvaloniaObject.Avalonia.PropertyStore.IValueSink.ValueChanged[T](AvaloniaPropertyChangedEventArgs`1 change) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 531
   at Avalonia.ValueStore.NotifyValueChanged[T](AvaloniaProperty`1 property, Optional`1 oldValue, BindingValue`1 newValue, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 367
   at Avalonia.ValueStore.SetValue[T](StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 123
   at Avalonia.AvaloniaObject.SetValue[T](StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 368
   at AvaloniaEdit.Rendering.TextView.set_Document(TextDocument value)
   at AvaloniaEdit.Editing.TextArea.OnDocumentChanged(TextDocument oldValue, TextDocument newValue)
   at AvaloniaEdit.Editing.TextArea.OnDocumentChanged(AvaloniaPropertyChangedEventArgs e)
   at System.Reactive.AnonymousObserver`1.OnNextCore(T value) in /_/Rx.NET/Source/src/System.Reactive/AnonymousObserver.cs:line 67
   at System.Reactive.ObserverBase`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/ObserverBase.cs:line 36
   at System.Reactive.Subjects.Subject`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 147
   at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaPropertyChangedEventArgs`1 change) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 758
   at Avalonia.AvaloniaObject.Avalonia.PropertyStore.IValueSink.ValueChanged[T](AvaloniaPropertyChangedEventArgs`1 change) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 531
   at Avalonia.ValueStore.NotifyValueChanged[T](AvaloniaProperty`1 property, Optional`1 oldValue, BindingValue`1 newValue, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 367
   at Avalonia.ValueStore.SetValue[T](StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 123
   at Avalonia.AvaloniaObject.SetValue[T](StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 368
   at AvaloniaEdit.Editing.TextArea.set_Document(TextDocument value)
   at AvaloniaEdit.TextEditor.OnDocumentChanged(TextDocument oldValue, TextDocument newValue)
   at AvaloniaEdit.TextEditor.OnDocumentChanged(AvaloniaPropertyChangedEventArgs e)
   at System.Reactive.AnonymousObserver`1.OnNextCore(T value) in /_/Rx.NET/Source/src/System.Reactive/AnonymousObserver.cs:line 67
   at System.Reactive.ObserverBase`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/ObserverBase.cs:line 36
   at System.Reactive.Subjects.Subject`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 147
   at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaPropertyChangedEventArgs`1 change) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 758
   at Avalonia.AvaloniaObject.Avalonia.PropertyStore.IValueSink.ValueChanged[T](AvaloniaPropertyChangedEventArgs`1 change) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 531
   at Avalonia.ValueStore.NotifyValueChanged[T](AvaloniaProperty`1 property, Optional`1 oldValue, BindingValue`1 newValue, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 367
   at Avalonia.ValueStore.SetValue[T](StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 123
   at Avalonia.AvaloniaObject.SetValue[T](StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 368
   at AvaloniaEdit.TextEditor..ctor(TextArea textArea, TextDocument document)
   at AvaloniaEdit.TextEditor..ctor(TextArea textArea)
   at AvaloniaEdit.TextEditor..ctor()
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.!XamlIlPopulate(IServiceProvider , DecompilerTextView ) in /home/runner/work/AvaloniaILSpy/AvaloniaILSpy/ILSpy.Core/TextView/DecompilerTextView.xaml:line 11
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.!XamlIlPopulateTrampoline(DecompilerTextView )
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.InitializeComponent() in /home/runner/work/AvaloniaILSpy/AvaloniaILSpy/ILSpy.Core/TextView/DecompilerTextView.xaml.cs:line 129
   at ICSharpCode.ILSpy.TextView.DecompilerTextView..ctor() in /home/runner/work/AvaloniaILSpy/AvaloniaILSpy/ILSpy.Core/TextView/DecompilerTextView.xaml.cs:line 91
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState)
   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()
   at Microsoft.VisualStudio.Composition.ExportProvider.<>c__DisplayClass55_0.<CreateExport>b__0()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at Microsoft.VisualStudio.Composition.Export.get_Value()
   at Microsoft.VisualStudio.Composition.ExportProvider.<>c__DisplayClass71_1`2.<GetExports>b__1()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at Microsoft.VisualStudio.Composition.ExportProvider.GetExportedValue[T]()
   at ICSharpCode.ILSpy.MainWindow..ctor() in /home/runner/work/AvaloniaILSpy/AvaloniaILSpy/ILSpy.Core/MainWindow.xaml.cs:line 133
   at ICSharpCode.ILSpy.App.OnFrameworkInitializationCompleted() in /home/runner/work/AvaloniaILSpy/AvaloniaILSpy/ILSpy.Core/App.xaml.cs:line 133
   at Avalonia.Controls.AppBuilderBase`1.Setup() in /_/src/Avalonia.Controls/AppBuilderBase.cs:line 313
   at Avalonia.Controls.AppBuilderBase`1.SetupWithLifetime(IApplicationLifetime lifetime) in /_/src/Avalonia.Controls/AppBuilderBase.cs:line 180
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 148
   at ICSharpCode.ILSpy.Program.Main(String[] args) in /home/runner/work/AvaloniaILSpy/AvaloniaILSpy/ILSpy/Program.cs:line 22

My Machine

uname -a Linux khamsin-legion 5.14.16-arch1-1 #1 SMP PREEMPT Tue, 02 Nov 2021 22:22:59 +0000 x86_64 GNU/Linux

zryogi commented 2 years ago

It seems to be an unsolved issue at Avalonia: https://github.com/AvaloniaUI/Avalonia/issues/4427

brycehalling commented 2 years ago

I had the same issue on arch as well. Installing ttf-dejavu fixed it for me.

VinnieThePooh commented 1 year ago

I had the same issue on arch as well. Installing ttf-dejavu fixed it for me.

Thanks bro. Fix works for me too (on arch as well). Though it worked before, after uninstalling some orphanned packages (probably it was ttf-dejavu) in Pamac it became broken.

passwa11 commented 5 months ago

This issue is also happening when the system language is set to Korean or Japanese and probably any other language with non-Latin characters as well. (tested on a fresh Ubuntu 20.10 VM x86_64)

I can fix this font loading issue by launching my app with a modified locale environment variable:

LC_ALL=C ./YourAvaloniaExecutable

From: https://github.com/AvaloniaUI/Avalonia/issues/4427#issuecomment-761074576

tim-ufer commented 2 months ago

I just encountered this issue on my Fedora 40 machine and unfortunately, neither installing various windows fonts nor overriding the locale fixed the error. Not sure if it compiling it myself should be any different but I tried it anyway as well, without success.

Is there anything else that I can try or will I have to wait for Avalonia to hopefully fix it on their end someday?