Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Rendering Multiline Text with NVPath Extension and Pango

  1. #1
    Newbie Newbie
    Join Date
    Jul 2015
    Posts
    3

    Question Rendering Multiline Text with NVPath Extension and Pango

    I'm using Pango to layout my text and NV Path extension to render glyphs.

    Having difficulty in finding correct methods for getting per glyph positions. As you can see at the moment I'm calculating this values according to line and glyph indexes.

    But Pango has better methods for this; like per glyph, per line, extent queries. My problem is that this methods got no documentation and I wasn't able to find any samples.

    How can i get correct glyph positions from Pango for this type of application?

    Code :
    std::vector<uint32_t>   glyphs;
    std::vector<GLfloat>    positions;
     
    int lineCount                           = pango_layout_get_line_count( pangoLayout );
     
    for ( int l = 0; l < lineCount; ++l )
    {
        PangoLayoutLine*    line            = pango_layout_get_line_readonly( pangoLayout, l );
        GSList*             runs            = line->runs;
     
        float xOffset                       = 0.0f;
     
        while( runs )
        {
            PangoLayoutRun* run             = static_cast<PangoLayoutRun*>( runs->data );
     
            glyphs.resize( run->glyphs->num_glyphs, 0 );
            positions.resize( run->glyphs->num_glyphs * 2, 0 );
     
            for( int g = 0; g < run->glyphs->num_glyphs; ++g )
            {               
                glyphs[g]                   = run->glyphs->glyphs[g].glyph;
                // Need Correct Values Here
                positions[ g * 2 + 0 ]      = xOffset * NVPATH_DEFUALT_EMSCALE;
                positions[ g * 2 + 1 ]      = (float)l * NVPATH_DEFUALT_EMSCALE;
     
                xOffset                 += PANGO_PIXELS( run->glyphs->glyphs[g].geometry.width ) / getFontSize();
            }
     
            const Font::RefT font           = getFont( pango_font_description_get_family( pango_font_describe( run->item->analysis.font ) ) );
     
            glEnable( GL_STENCIL_TEST );
     
            glStencilFillPathInstancedNV(   run->glyphs->num_glyphs,
                                            GL_UNSIGNED_INT,
                                            &glyphs[0],
                                            font->nvPath,
                                            GL_PATH_FILL_MODE_NV,
                                            0xFF,
                                            GL_TRANSLATE_2D_NV,
                                            &positions[0]
                                            );
     
     
            glStencilFunc( GL_NOTEQUAL, 0, 0xFF );
            glStencilOp( GL_KEEP, GL_KEEP, GL_ZERO );
            glColor3f( 0.0, 0.0, 0.0 );
     
            glCoverFillPathInstancedNV(     run->glyphs->num_glyphs,
                                            GL_UNSIGNED_INT,
                                            &glyphs[0],
                                            font->nvPath,
                                            GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV,
                                            GL_TRANSLATE_2D_NV,
                                            &positions[0]
                                            );
     
            glDisable( GL_STENCIL_TEST );
     
            runs                            = runs->next;
        }
    }

  2. #2
    Newbie Newbie
    Join Date
    Jul 2015
    Posts
    3
    Any help on this so far? Is it posted on wrong forum?

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,595
    Quote Originally Posted by alinakipoglu View Post
    Any help on this so far? Is it posted on wrong forum?
    As it seems like your problems are with Pango, a forum related to Pango might be better.

    As for samples, GTK would be the first place I'd look, as it is Pango's principal target.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •