Problem: Javanese Script (using Google's Noto Sans Javanese font) rendered and "combined" properly on HTML, but not on Windows Forms Application (C# .NET, Visual Studio 2017).
Edit: My computer uses Windows 7, 64-bit.
Noto Sans Javanese direct download link (.zip)
Glyphs Used
There are many cases to show that the glyphs are not combined properly, but here's one example I used:
Javanese Script Unicode Specification direct download link (.pdf)
Correct/desired behaviour
Four of these glyphs should be "combined", becoming one character
HTML code:
<html>
<head>
<meta charset="utf-8">
<style>
.javanese {
font-family: "Noto Sans Javanese";
font-size: 66px;
}
</style>
</head>
<body>
<div class="javanese">ꦤ꧀ꦠꦼ</div>
<div class="javanese">ꦤ꧀ꦠꦼ</div>
</body>
</html>
HTML result:
Incorrect rendering on Windows Forms (C# .NET)
I am using Visual Studio 2017 Community, creating a Windows Forms Desktop Application.
Label components are using the "Noto Sans Javenese" font.
C# code:
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.label1.Text = "\uA9A4\uA9C0\uA9A0\uA9BC";
this.label2.Text = "ꦤ꧀ꦠꦼ"; // Copied from HTML
// this one is rendered correctly
// Thai character "ko kai" (U+0E01) and combining characters "mai tho" (U+0E49).
this.label3.Text = "\u0E01\u0E49\u0E49\u0E49\u0E49\u0E49\u0E49\u0E49\u0E49";
}
}
}
C# result:
Questions
Thank you very much!
I have gotten few options and insights to help resolve this problem. Apparently, this is only a problem with Windows Forms on Windows 7.
So far, my options are:
Here are the sources, credits goes to all respective authors:
Since Win7 has Unicode 5.1 support only and the character \uA9A4 falls in Unicode 5.2 range, the GDI+ text rendering function may not be able to handle the glyph hints correctly. (I'm not expert on i18n issues, so don't know whether special glyph hint support is needed)
Since IE and other web browsers such as Chrome and Firefox all comes with their own font rendering engine, they're not subject to GDI+ rendering limitations.
Btw, also tested setting "UseCompatibleTextRendering" to true does not help either.
On the other hand, WPF forms does render the text correctly. So consider changing it to WPF application, or replace necessary controls with WinForm hosted WPF controls.
Font shaping (Bidirectionality, Context-based shaping, ligatures, positioning & reordering) is a very, very complex topic. Although I'd be surprised, it may be that Windows Forms do not support font shaping.
A workaround would be to use a library like HarfBuzz, render the result to a bitmap and then display that bitmap. See http://behdad.org/text/ for details.
In fact, your problem is described here on page 8: http://www.panl10n.net/Presentations/Cambodia/Pema/LocalizationofLinux(Bhutan).pdf