fontconfig substitutes not considered by libgdiplus
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.
public class HelloWorld : Form
{
static public void Main ()
{
}
public HelloWorld ()
{
Button b = new Button ();
b.Text = "Tofus? → 我是方框。";
b.Font = new Font("Sans", 11);
b.Click += new EventHandler (Button_Click);
}
private void Button_Click (object sender, EventArgs e)
{
}
}
```
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:/
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.