fontconfig substitutes not considered by libgdiplus

Bug #1578749 reported by Mingye Wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Libgdiplus
Unknown
Unknown
libgdiplus (Ubuntu)
New
Undecided
Unassigned

Bug Description

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 when fc-match satisfies the said conditions:
(Consider changing "Sans" to non-CJK fonts like "Liberation Sans" for stable reproduction. "Sans" is usually easier to mess with (by specifying LC_ALL, for example) though.)

```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.)

Mingye Wang (artoria2e5)
description: updated
Mingye Wang (artoria2e5)
description: updated
description: updated
Revision history for this message
Mingye Wang (artoria2e5) wrote :

Regarding that test case, consider resizing the button explicitly or just use the CJK string "我是方框。", since the button by default has a fixed size.

In https://github.com/AOSC-Dev/aosc-os-abbs/issues/224, JeffBai (github:MingcongBai) found out that using pango does fix the problem. The pango linking LDFLAGS in configure was a little bit off however -- we appended '-lm -lpangoft2-1.0' to LDFLAGS explicitly after configure to deal with link failures.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.