Hi all I've been tracking down a display bug with winforms. Basically, any string drawn that has combining chars (eg accents) doesn't come out right. I've attached a screenshot and a sample test.
In the screenshot the two buttons should look identical. The only difference is that the one on the left has text using a combining accent, and the one on the right has the same text but using pre-combined chars. They're both valid utf-16; that is, it's not an encoding issue. It's caused by libgdiplus using the cairo 'toy' text api to render strings. This API takes each character in turn, draws the glyph from the font, and advances the drawing point by the width of the character in the font. The combining accent has a zero width, but by the time it has come to be drawn the drawing point has already been moved so it misses the character it's supposed to be combining with. I've tried enabling the "experimental and unsupported" pango text rendering support (see attached patch to get around the failed assertion: (process:27402): Pango-CRITICAL **: pango_fc_font_lock_face: assertion `PANGO_IS_FC_FONT (font)' failed) but am having font loading issues when using the 'system' cairo (with or without pango), which the pango support depends on. Is there any reason why the pango support can't be enabled by default? - Dick
<<attachment: screen-capture.png>>
using System; using System.Windows.Forms; using System.Drawing; public class Test: Form { public Test (string tb_text) { Button button1 = new Button (); Button button2 = new Button (); TextBox textbox = new TextBox(); SuspendLayout (); button1.Location = new Point (3, 3); button1.Size = new Size (75, 23); button1.Text = "\x61\x301 \x65\x301 \x69\x301 \x6f\x301 \x75\x301 !"; button2.Location = new Point (82, 3); button2.Size = new Size (75, 23); button2.Text = "\xe1 \xe9 \xed \xf3 \xfa !"; textbox.Location = new Point (3, 30); textbox.Size = new Size (150, 20); textbox.Text = tb_text; ClientSize = new Size (200, 60); Controls.Add (button1); Controls.Add (button2); Controls.Add (textbox); Text = "Test"; ResumeLayout (false); } } public class RunIt { public static void Main (string[] args) { string text = "hello world"; if (args.Length > 0) { text = args[0]; } Application.Run (new Test (text)); } }
--- src/font.c.orig 2011-01-13 22:28:19.000000000 +0000 +++ src/font.c 2011-09-09 15:21:35.000000000 +0100 @@ -626,11 +627,32 @@ PangoContext *context = pango_cairo_font_map_create_context ((PangoCairoFontMap*)map); PangoFont *pf = pango_font_map_load_font (map, context, gdip_get_pango_font_description (font)); +#if 0 FT_Face face = pango_fc_font_lock_face ((PangoFcFont*)pf); +#else + cairo_scaled_font_t* scaled_ft = pango_cairo_font_get_scaled_font ((PangoCairoFont*)pf); + if (!scaled_ft) { + static int flag = 0; + if (flag == 0) { + g_warning ("couldn't lock the font face. this may be due to a missing fonts.conf on the system."); + flag = 1; + } + status = FontFamilyNotFound; + } + + FT_Face face = NULL; + + if (status == Ok) + face = cairo_ft_scaled_font_lock_face (scaled_ft); +#endif if (face) { gdip_get_fontfamily_details_from_freetype (family, face); +#if 0 pango_fc_font_unlock_face ((PangoFcFont*)pf); +#else + cairo_ft_scaled_font_unlock_face (scaled_ft); +#endif } else { status = FontFamilyNotFound; }
_______________________________________________ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list