picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.68k stars 334 forks source link

Mac: Font from stream is weirdly broken #2681

Open psyGamer opened 2 months ago

psyGamer commented 2 months ago

Expected Behavior

Creating a font like this should give the same result as new Font("JetBrainsMono", size, style) when it's installed on the system:

var asm = Assembly.GetExecutingAssembly();
var builtinFontFamily = FontFamily.FromStreams(asm.GetManifestResourceNames()
    .Where(name => name.StartsWith("JetBrainsMono/"))
    .Select(name => asm.GetManifestResourceStream(name)));

return new Font(builtinFontFamily, size, style);

Those embedded resources are .ttf files directly pulled from an installed font on macOS.

Actual Behavior

Some characters are sometimes missing. Weirdly this only seems to happen when rendering them directly in a Drawable. Label, etc. seem to work fine from testing with the example app. Additionally it also sometimes crashes inside Eto.Drawing.Font.GetHashCode() by using a Font as a Dictionary key. Note that this doesn't appear to happen on WPF or GTK.

Steps to Reproduce the Problem

  1. Load font from stream
  2. Use that font inside a drawable
  3. Have it sometimes not render characters

Code that Demonstrates the Problem

This issue can be seen in my project: Celeste Studio (Note that after commit abefee a workaround with "Monaco" is used). Under Setting > Font... changing between the built-in JetBrainsMono and a system install of it, the issue should become obvious after a bit of scrolling. (Just paste this into it to get some file-content)

https://github.com/user-attachments/assets/7134ab1f-473c-438b-9af7-7ad161aa99ff

Specifications