[cairo] cairo Digest, Vol 33, Issue 29

robertk54 at aol.com robertk54 at aol.com
Mon Apr 14 09:02:10 PDT 2008


>>       cairo_rotate (m_pCairo, rotation);
>>       // Get the layout's current context
>>       pPangoContext = pango_layout_get_context (m_pPangoLayout);
>>       // Try to implement vertical text using context gravity
>>       pango_context_set_base_gravity (pPangoContext, gravity);
>>        pango_context_set_gravity_hint (pPangoContext,
>>  PANGO_GRAVITY_HINT_STRONG);
>>       // Let the pango layout know of the context changes above.
>>       pango_layout_context_changed (m_pPangoLayout);

>>I think this should rather be pango_cairo_update_layout() to also tell
>>the transformation to the layout, not just the new options. Now it
>>just rotates the drawing commands, not the layout logic.

>Added the call to pango_cairo_update_layout() in various points above
>but had no observable affect.

I modified my code to use the exact code below.  The result here is 
that the rendered text is all hollow boxes.  Could the issue I am 
having trying to render vertical text be related to the environment 
(Windows vs. Linux)?

<<
  /**
   * Then we'll go wild and use all of them in the same layout
   */
  pango_layout_set_text(m_pPangoLayout,
    "Latin 日本語 فارسی ",
    -1);
   /**
     * Here we set the gravity hint to "strong" to override the natural 
gravity
     * of each script with what we want in order to achieve different 
orientations
    */
   pPangoContext = pango_layout_get_context (m_pPangoLayout);
    pango_context_set_gravity_hint(pPangoContext, 
PANGO_GRAVITY_HINT_STRONG);

   cairo_save(m_pCairo);
   cairo_move_to (m_pCairo, 30, 30);

   /**
    * Rotate 90 degrees clockwise and change the base gravity to east.
    *
    *  Normally, the bases of the glyphs would be on the left edge
    *  of the layout. But since the gravity "pulls" the bases to east
    *  (towards right in the normal orientation), they are rotated back
     *  to their natural orientation while the flow of the text is 
vertical.
    */
   cairo_rotate(m_pCairo, 90 / (180.0 / G_PI));
   pango_context_set_base_gravity (pPangoContext, PANGO_GRAVITY_EAST);
   pango_cairo_update_layout(m_pCairo, m_pPangoLayout);

   pango_cairo_show_layout (m_pCairo, m_pPangoLayout);
   cairo_restore(m_pCairo);
>>


More information about the cairo mailing list