Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash (IndexOutOfRangeException) at Avalonia.Media.GlyphRun.CreateGlyphRunMetrics When Selecting "Marlett" font #16145

Open
Natestah opened this issue Jun 26, 2024 · 0 comments

Comments

@Natestah
Copy link

Describe the bug

Added a Font Selector to my "text searching program" and got a crash. on selecting the "Marlett" font.

System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Avalonia.Media.GlyphRun.CreateGlyphRunMetrics()
at Avalonia.Media.GlyphRun.get_Metrics()
at Avalonia.Media.GlyphRun.get_BaselineOrigin()
at Avalonia.Media.GlyphRun.CreateGlyphRunImpl()
at Avalonia.Media.GlyphRun.get_PlatformImpl()
at Avalonia.Media.GlyphRun.get_InkBounds()
at Avalonia.Media.TextFormatting.TextLineImpl.CreateLineMetrics()
at Avalonia.Media.TextFormatting.TextLineImpl.FinalizeLine()
at Avalonia.Media.TextFormatting.TextFormatterImpl.FormatLine(ITe

To Reproduce

I have created a Repository with an immediate repro of this issue in
https://github.com/Natestah/AvaloniaFontCrash

The above repository has all this, just grab that and run it.

Steps I followed:

  1. Create a new Avalonia project
  2. Set the windows Font to "Marlett"
  3. Add a named TextBox
  4. Add the following to the window loaded event:
        StringBuilder textbuilder = new StringBuilder();
        for (int i = 0; i < 256; i++)
        {
            textbuilder.Append((char)i);
        }
        TextBlock.Text = textbuilder.ToString();

Expected behavior

Non standard fonts should do a default behavior (unfound square visual?), but not throw here. I cannot guaranteed that user installed fonts will not crash the same way.

Avalonia version

11.0.6.0 ( this template ), first discovered in 11.1.0.0

OS

Windows

Additional context

Selecting this in the view for Blitz Search means crashing =(

2024-06-26_11-03-20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants