[Pango] Underline attribute does not work with scaled cairo context.



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

-- 
çåååææè
åéåééäé



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]