[cairo] Pango / Cairo problems on Win32

Gerdus van Zyl gerdusvanzyl at gmail.com
Sun Sep 2 06:17:02 PDT 2007


The only font that does not give the error is "Sans 8" but just adding
bold like "Sans Bold 8" results in the error.

Sorry about leaving the code out, see below:

    def showText(self,ctx,x = None,y = None,txt = None):
        if txt == None:
            try:
                txt = self.text
            except:
                return #no text

        if len(txt) == 0:
            return

        setColour(ctx, str(self.style.color) )


        if x and y:
            ctx.move_to(x,y)
        else:
            ctx.move_to(0,0)

        style = self.style

        #padding
        ctx.rel_move_to( int(str(style.padding_left))
,int(str(style.padding_top)) )

        width = self.width
        #txt = self.text

        #ctx.show_text(txt)
        #return

        cr = pangocairo.CairoContext(ctx)
        #cr = ctx

        if not width == -1:
            width = width * pango.SCALE

        #gives pango error
        #FONT = "Georgia 10"
        #FONT = "Sans Bold 27"
        #FONT = "Tahoma 12"
        #FONT = "Sans, Bold 8"
        #FONT = "Segoe UI,8"
        #FONT = "Arial Bold 8"

        #does not give pango error
        FONT = "Sans 8"

        #FONT = str(style.font_family) + ", " + str(style.font_weight)
+ " " + str(style.font_size)
        #FONT = str(style.font_family) + ", " + str(style.font_size)

        print FONT,self

        layout = cr.create_layout()

        layout.set_width(width)

        if self.style.text_align == 'Right':
            layout.set_alignment(pango.ALIGN_RIGHT)
        elif self.style.text_align == 'Center':
            layout.set_alignment(pango.ALIGN_CENTER)
        else:
            layout.set_alignment(pango.ALIGN_LEFT)


        layout.set_text(txt)
        layout.set_font_description(pango.FontDescription(FONT))

        #cr.update_layout(layout)

        cr.show_layout(layout)

--------------------------------------------------------------------------------------------------------------------------

On 02/09/07, Behdad Esfahbod <behdad at behdad.org> wrote:
> On Sat, 2007-09-01 at 13:14 -0400, Gerdus van Zyl wrote:
> > I tried to convert all my text rendering from the cairo "toy" api to
> > pango/cairo. But in some instances I get the following:
> >
> > C:\uxpython\src\uxGUI\controls\uBase.py:1472: PangoWarning:
> > pango_shape called with bad font, expect ugly output
> >   cr.show_layout(layout)
> > C:\uxpython\src\uxGUI\controls\uBase.py:1472: PangoWarning:
> > pango_font_get_glyph_extents called with bad font, expect ugly output
> >   cr.show_layout(layout)
> > C:\uxpython\src\uxGUI\controls\uBase.py:1472: PangoWarning:
> > _pango_cairo_font_install called with bad font, expect ugly output
> >   cr.show_layout(layout)
> >
> > followed by multiple:
> > cairo_win32_scaled_font_select_font:SelectObject: The parameter is incorrect.
> >
> > I get this error on most runs of my programs (sometimes does work
> > right) but not on my other programs that have more text. Font
> > selection has absolutely no effect, even using default "sans" or
> > "mono" gives the exact same.
>
> Hi,
>
> There's no way we can help you without seeing the code.
>
> behdad
>
>
>
> --
> behdad
> http://behdad.org/


More information about the cairo mailing list