[cairo] Accented characters and guimette

Nev Delap nev.delap at intelestream.net
Sat Oct 9 10:55:57 PDT 2010


As for the exact version of Cairo that I am using I don't know. I'm using
Mono.Cairo in Mono 2.6.7 on Linux, and the problem shows in Mono 2.6.4 and
2.8 on Windows. But the virtual machine in which I'm running it has 800
other things, so when I test it in clean Windows VM to figure out exactly
what it needs to run on that platform I will have a better idea since I
haven't looked deeper yet.

In case anyone does need a workaround, this is Cobra code (.Net) and extends
Context with a couple of methods that will strip accents and replace
guillemet, which until I investigate Pango makes my app work in Windows.

Cheers.

# $Id: Extension.Mono.Cairo.Context.cobra,v 0197babc4e6f 2010/10/09 09:47:04
nevdelap $
# Reviewed:

use Cairo
use System.Globalization

extend Cairo.Context

    def textExtentsForPlatform(s as String) as TextExtents
        return .textExtents(_transformForPlatform(s))

    def showTextForPlatform(s as String)
        .showText(_transformForPlatform(s))

    def _transformForPlatform(s as String) as String
        """
        On Windows guillemets and accents break
        the context - it cannot output anything
        subsequently. So if it is not Linux I strip
        that stuff out since I don't know what
        Mac OS/X would do so I'm playing it safe.
        """
        # http://www.mono-project.com/FAQ:_Technical
        platform = Environment.osVersion.platform to int
        isRunningOnLinux = platform == 4 or platform == 128
        if not isRunningOnLinux
            s = s.replace("«", "<<")
            s = s.replace("»", ">>")
            s = _stripAccents(s)
        return s

    def _stripAccents(s as String) as String
        # http://www.codeproject.com/KB/cs/UnicodeNormalization.aspx
        stringBuilder = StringBuilder()
        for originalChar in s
            decomposedCharacters =
originalChar.toString.normalize(NormalizationForm.FormKD)
            if decomposedCharacters.length == 1
                stringBuilder.append(decomposedCharacters)
            else
                for decomposedCharacter in decomposedCharacters
                    if decomposedCharacter to int < 128 # If it is ascii
                        stringBuilder.append(decomposedCharacter)
        return stringBuilder.toString

On 9 October 2010 06:06, justi <justi_10 at rediffmail.com> wrote:

> Hi  Nev
> We are woking at present on cairo with openvg backend(ARM linux).
> If yours cairo code uses the same backend please share the code ,we can run
> it on windows and see the nature of problems.
>
> Thanks
> Justi.
>
> ============
> On Sat, 09 Oct 2010 14:00:44 +0530 wrote
>
> >
>
> >
> Hi there,
>
> >
> I am using Cairo in a Mono application on Linux where it works perfectly.
> I'm running the application on Windows (exact same code running in Mono
> still).
>
> >
> My problem is that running on Windows when it either does
> context.TextExtents() or context.ShowText() with guillemets or characters
> with accents, no subsequent output is producted. It doesn't get an
> exception, doesn't write anything to the console, it just doesn't draw
> anything more on that context.
>
> >
> This is only on Windows, on Linux no problem.
>
> >
> So, I want to ask is it a known problem, if so, is there any workaround, if
> not is there something you can suggest to help me track down something
> useful to provide you for debugging? And if I made a minimal Mono
> application that works on Linux and shows the problem on Windows would you
> be able to use that?
>
> >
> Thanks,
>
> >
> Nev
> --
> >cairo mailing list
> >cairo at cairographics.org<http://prism/writemail?&mode=mail_to_individual&email=cairo@cairographics.org&output=web&els=0a23248c7fe46ba46c52f889070eaa55>
> >http://lists.cairographics.org/mailman/listinfo/cairo<http://www.rediffmail.com/cgi-bin/red.cgi?red=http%3A%2F%2Flists%2Ecairographics%2Eorg%2Fmailman%2Flistinfo%2Fcairo>
>
> <http://sigads.rediff.com/RealMedia/ads/click_nx.ads/www.rediffmail.com/signatureline.htm@Middle?>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101009/c82829d6/attachment-0001.htm>


More information about the cairo mailing list