[Mono-dev] Complex script / international support in Winforms/libgdiplus

Miguel De Icaza miguel at novell.com
Sat Jan 24 20:04:04 EST 2009

Hello Jonathan,

I was very happy to read about your effort to add support for complex  
scripts to Mono's Windows.Forms implementation.

Getting the rendering in GDI+ is the first stage, as you have already  
discovered.   The second stage is a little bit more complicated as it  
will involve actually extending the text editor controls.    Your  
strategy so far is sound.

> The problem is that the implementation of the TextBox makes some very
> basic assumptions that don't work for complex scripts, i.e. the  
> width of
> a string is not necessarily equal to the sum of the widths of the
> individual characters.  This can even be true for Latin fonts that use
> kerning and ligatures like ae, ff, and fi.  Also, separate code points
> can form one grapheme (one rendered symbol).  All this causes problems
> with selection, caret placement, and line breaking.

Correct, this is an area that will require some extensions.

> Now, all that being said, I've been working on the TextBox as well to
> improve the implementation.  I'm not done yet, so I don't have any  
> good
> code to post here yet.  One of the problems that I'm working against  
> is
> that the gdi+ interface doesn't supply the information needed to do  
> the
> TextBox correctly, that is, if I want to work with libgdiplus to make
> the pango calls, I'll need to add some linux-specific functions that I
> can call for text metrics.  I noticed there are some other functions  
> in
> libgdiplus with "_linux" in the names, so I'm assuming that this won't
> be a huge problem - otherwise, a lot of code for the cairo/pango
> interaction would have to be copied into winforms.

This sounds like a good approach.

> I just wanted to let everyone know that I'm working on this, and I
> wanted to see if the direction I'm taking using TextBoxTextRenderer  
> and
> libgdiplus seemed appropriate.

Both seem correct to me.

> Also, as I'll have a good bit of code
> for both libgdiplus and winforms that will depend on each other,  
> what's
> the best way for me to get it into the project once I've got it  
> working.

I suggest that you start posting your patches to the list.   We will  
usually provide some feedback and code review before the code goes  
into SVN.

Once the code is ready, either one of us will check in the code, or if  
you do not mind, we will give you an SVN account so you can check-in  
and maintain the updated code directly on SVN.

I am looking forward to this.   It is a feature that we always wanted  
to have!


More information about the Mono-devel-list mailing list