Hi, 

        I am making some tests to try and learn more about Pango.  Right now
        I am trying to step through a layout line by line, run by run, and
        then word by word.

        I was hoping someone might be able to help me out with some
        questions.

        Here is what I am doing.
        
        static char * text = { " flower power "};
        // I get the layout
        PangoLayout *layout;
        layout = pango_layout_new(pango_context);
        pango_layout_set_text(layout, text, -1);
        pango_layout_context_changed(layout);


        // I then get iterators for lines and stuff
        PangoLayoutIter* p_iter = 0;
        p_iter = pango_layout_get_iter(layout);
        PangoLayoutLine* p_line = pango_layout_iter_get_line(p_iter);
        GSList* current_run = p_line->runs;
        PangoLayoutRun* p_run=(PangoLayoutRun*)current_run->data;

        // I then try to get attribute info for this run
        PangoLogAttr * logattrs = (PangoLogAttr *) malloc( 
                        (p_run->item->num_chars +1 ) * sizeof(PangoLogAttr) );
        pango_break(text+ p_run->item->offset, p_run->item->length,
                          &p_run->item->analysis, logattrs,
                          p_run->item->num_chars+1);    

        // Am I doing this wrong?
        // This then gives me a PangoLogAttr for every byte char in the text
        // string, correct?  But, since there could be more than one char for 
        // a glyph, where do I check for word_end?

        // Can someone tell me here what num_chars refers to in the item?
        // is that character bytes? 
        // is that not always the same as item->length?
        // Also, what is the difference between a byte, a character, a glyph,
        // and a cluster in Pango?  In the docs and naming of variables, is
        // it consistently named?

        // Then, I try to step through the run by glyph and logattr to see
        // where words start and end
        // Is this correct? 

   for(int i=0;i<p_run->glyphs->num_glyphs;i++) {
                j=p_run->glyphs->log_clusters[i];
                // I print out some info about the word start and end
                printf("\t\tword_start:%d, ", logattrs[j].is_word_start);
                printf("word_end:%d \n", logattrs[j].is_word_end);
        }


        The funny thing that I notice heres is that the "f" and the "l" in
        "flower" is considered one glyph.  Is that right?


        Sorry if my questions are basic.  I can see how complex type layout
        is now that I am getting my hands dirty.  Any help would be greatly
        appreciated.

        thank you -august.

_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list

Reply via email to