[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-app-devel
Subject:    [Pango] Underline attribute does not work with scaled cairo context.
From:       Magicloud Magiclouds <magicloud.magiclouds () gmail ! com>
Date:       2010-04-21 5:28:58
Message-ID: o2p3bd412d41004202228h9587855fh4933633ebcd8a4f () mail ! gmail ! com
[Download RAW message or body]

Hi, I set the attributes for the layout with Underline, Size, Letter
Spacing, Font Description. All others worked fine except the
Underline, worked as there was no scale at all. So when the string
displayed in correct size, the underline on the other hand, displayed
as huge black blocks.

Following is my code, sorry it is in haskell.

  layout <- liftIO $ do
    ctxt <- cairoCreateContext Nothing
    layout <- layoutText ctxt $ show $ day e
    fd <- fontDescriptionFromString "WenQuanYi Micro Hei Mono Bold"
    layoutSetAttributes layout ((if odd $ ceiling x
                                   then case y of
                                     3 -> AttrUnderline 0 2 UnderlineSingle
                                     4 -> AttrUnderline 0 2 UnderlineSingle
                                     5 -> AttrUnderline 0 2 UnderlineSingle
                                     6 -> AttrUnderline 0 2 UnderlineSingle
                                     7 -> AttrUnderline 0 2 UnderlineSingle
                                     8 -> AttrUnderline 0 2 UnderlineDouble
                                     9 -> AttrUnderline 0 2 UnderlineDouble
                                     10 -> AttrUnderline 0 2 UnderlineSingle
                                     11 -> AttrUnderline 0 2 UnderlineSingle
                                     12 -> AttrUnderline 0 2 UnderlineSingle
                                     13 -> AttrUnderline 0 2 UnderlineSingle
                                     14 -> AttrUnderline 0 2 UnderlineSingle
                                     15 -> AttrUnderline 0 2 UnderlineDouble
                                     16 -> AttrUnderline 0 2 UnderlineDouble
                                   else case y of
                                     3 -> AttrUnderline 0 2 UnderlineDouble
                                     4 -> AttrUnderline 0 2 UnderlineDouble
                                     5 -> AttrUnderline 0 2 UnderlineSingle
                                     6 -> AttrUnderline 0 2 UnderlineSingle
                                     7 -> AttrUnderline 0 2 UnderlineSingle
                                     8 -> AttrUnderline 0 2 UnderlineSingle
                                     9 -> AttrUnderline 0 2 UnderlineSingle
                                     10 -> AttrUnderline 0 2 UnderlineDouble
                                     11 -> AttrUnderline 0 2 UnderlineDouble
                                     12 -> AttrUnderline 0 2 UnderlineSingle
                                     13 -> AttrUnderline 0 2 UnderlineSingle
                                     14 -> AttrUnderline 0 2 UnderlineSingle
                                     15 -> AttrUnderline 0 2 UnderlineSingle
                                     16 -> AttrUnderline 0 2 UnderlineSingle) :
                                [ AttrSize 0 2 0.4
                                , AttrLetterSpacing 0 2 (-0.3)
                                , AttrFontDescription 0 2 fd ])
      return layout
  setSourceRGB 0 0 0
  (_, PangoRectangle _ _ w h) <- liftIO $ layoutGetExtents layout
  moveTo (x - 0.5 - w / 2 + 0.05 + 0.1) (y + 0.2)
  showLayout layout

-- 
竹密岂妨流水过
山高哪阻野云飞
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic