Public bug reported:

libgdiplus' cairo backend only takes the fontconfig *match* to render
glyphs in cairo, with zero considerations for substitutes. This causes
significant problems when a developer using WinForms tries to display
some CJK glyphs in "Sans", while expecting system-like handling for
these bugs. Tofus will show up in such cases if the first candidate
generated from `fc-match Sans` is not a font with CJK glyphs.

This modified version of WinForms 'hello world' should be able to show
this bug:

```C#
using System;
using System.Drawing;
using System.Windows.Forms;

public class HelloWorld : Form
{
    static public void Main ()
    {
        Application.Run (new HelloWorld ());
    }

    public HelloWorld ()
    {
        Button b = new Button ();
        b.Text = "Tofus? → 我是方框。";
        b.Font = new Font("Sans", 11);
        b.Click += new EventHandler (Button_Click);
        Controls.Add (b);
    }

    private void Button_Click (object sender, EventArgs e)
    {
        MessageBox.Show ("Does it taste good?");
    }
}
```

Note this problem is not limited to "Sans", nor CJK chars -- I am just
using these for a common-enough example. In real life developers trying
to do cross-platform Winforms development might instead just use the
default fonts ("MS Sans Serif" or "Tahoma" on Mono), and still bump into
the very same blocks of tofu, perhaps with the emojis sent by their
happy users.

A possible workaround is to try the experimental pango backend, but that
is really very experimental. There is a pending PR at
https://github.com/mono/libgdiplus/pull/39, which is said to be
"basically approved" back in 2009. (Yeah, mono devs are getting tired of
desktop it seems.)

** Affects: libgdiplus
     Importance: Unknown
         Status: Unknown

** Affects: libgdiplus (Ubuntu)
     Importance: Undecided
         Status: New

** Bug watch added: bugzilla.xamarin.com/ #39418
   http://bugzilla.xamarin.com/show_bug.cgi?id=39418

** Also affects: libgdiplus via
   http://bugzilla.xamarin.com/show_bug.cgi?id=39418
   Importance: Unknown
       Status: Unknown

** Description changed:

  libgdiplus' cairo backend only takes the fontconfig *match* to render
  glyphs in cairo, with zero considerations for substitutes. This causes
  significant problems when a developer using WinForms tries to display
  some CJK glyphs in "Sans", while expecting system-like handling for
  these bugs. Tofus will show up in such cases if the first candidate
  generated from `fc-match Sans` is not a font with CJK glyphs.
  
  This modified version of WinForms 'hello world' should be able to show
  this bug:
  
  ```C#
  using System;
  using System.Drawing;
  using System.Windows.Forms;
  
  public class HelloWorld : Form
  {
-     static public void Main ()
-     {
-         Application.Run (new HelloWorld ());
-     }
+     static public void Main ()
+     {
+         Application.Run (new HelloWorld ());
+     }
  
-     public HelloWorld ()
-     {
-         Button b = new Button (); 
-         b.Text = "Tofus? → 我是方框。"; 
-         b.Font = new Font("Sans", 11); 
-         b.Click += new EventHandler (Button_Click);
-         Controls.Add (b);
-     }
+     public HelloWorld ()
+     {
+         Button b = new Button ();
+         b.Text = "Tofus? → 我是方框。";
+         b.Font = new Font("Sans", 11);
+         b.Click += new EventHandler (Button_Click);
+         Controls.Add (b);
+     }
  
-     private void Button_Click (object sender, EventArgs e)
-     {
-         MessageBox.Show ("Button Clicked!");
-     }
+     private void Button_Click (object sender, EventArgs e)
+     {
+         MessageBox.Show ("Does it taste good?");
+     }
  }
  ```
  
  Note this problem is not limited to "Sans", nor CJK chars -- I am just
  using these for a common-enough example. In real life developers trying
  to do cross-platform Winforms development might instead just use the
  default fonts ("MS Sans Serif" or "Tahoma" on Mono), and still bump into
  the very same blocks of tofu, perhaps with the emojis sent by their
  happy users.
  
  A possible workaround is to try the experimental pango backend, but that
  is really very experimental. There is a pending PR at
  https://github.com/mono/libgdiplus/pull/39, which is said to be
  "basically approved" back in 2009. (Yeah, mono devs are getting tired of
  desktop it seems.)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1578749

Title:
  fontconfig substitutes not considered by libgdiplus

To manage notifications about this bug go to:
https://bugs.launchpad.net/libgdiplus/+bug/1578749/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to