Cannot get font metrics



Hi all,
 
I'm attempting to update OpenMotif to render text using Pango 1.14 and am having difficulties with font metrics.  I can successfully specify a font description via string, such as Sans 15, and render the text (looks awesome).  When I try to get the PangoFontMetrics (in order to get the average width, ascender, and descender) it appears to work on my one virtual machine but not on another, nor on a physical machine.  All three machines are RHEL 5.2.
 
 
I'm only storing the PangoFontDescription * and try to use it later, as follows:
 
PangoFontMetrics * MY_GetFontMetrics( Display * display,
                      PangoFontDescription * font )
    PangoFontMetrics * metrics = 0;
    PangoFontMap * fontmap = pango_cairo_font_map_get_default();                                      
    if( fontmap )
    {  
        PangoContext * context
            = pango_cairo_font_map_create_context( (PangoCairoFontMap *)fontmap );
        if( context )
        {  
            pango_context_set_font_description( context, font );
            PangoLanguage * lang = pango_language_from_string( "en_US" );  // also tried lang = NULL; same result
            metrics = (PangoFontMetrics *)pango_context_get_metrics( context, font, lang );
            g_object_unref( context );
        }  
    }  
    return metrics;
}
 
 
Here's the error:
 
(process:6605): Pango-CRITICAL **: pango_font_map_load_fontset: assertion `fontmap != NULL' failed
 
(process:6605): Pango-CRITICAL **: pango_fontset_foreach: assertion `PANGO_IS_FONTSET (fontset)' failed
 
(process:6605): Pango-CRITICAL **: pango_font_map_load_fontset: assertion `fontmap != NULL' failed
 
(process:6605): GLib-GObject-CRITICAL **: g_object_get_qdata: assertion `G_IS_OBJECT (object)' failed
 
(process:6605): GLib-GObject-CRITICAL **: g_object_set_qdata_full: assertion `G_IS_OBJECT (object)' failed
 
(process:6605): Pango-CRITICAL **: pango_font_map_get_shape_engine_type: assertion `PANGO_IS_FONT_MAP (fontmap)' failed
 
(process:6605): GLib-CRITICAL **: g_quark_from_string: assertion `string != NULL' failed
Segmentation fault (core dumped)
 
Here's the backtrace:
 
(gdb) where
#0  0x001a6aca in strcmp () from /lib/libc.so.6
#1  0x06277585 in pango_map_get_engine () from /usr/lib/libpango-1.0.so.0
#2  0x0627775d in pango_find_map () from /usr/lib/libpango-1.0.so.0
#3  0x0627a94a in pango_context_get_font_description () from /usr/lib/libpango-1.0.so.0
#4  0x0627ab09 in pango_context_get_font_description () from /usr/lib/libpango-1.0.so.0
#5  0x0627b688 in pango_context_get_metrics () from /usr/lib/libpango-1.0.so.0
#6  0x00e6f979 in LoadFontMetrics (tf=0x9eac7f8) at TextF.c:6995
#7  0x00e70500 in InitializeTextStruct (tf=0x9eac7f8) at TextF.c:7316
#8  0x00e71540 in Initialize (request=0xbfcf8fb0, new_w=0x9eac7f8, args=0xbfcf9480, num_args=0xbfcf8f64)
    at TextF.c:7837
#9  0x06c23538 in XtCvtStringToCommandArgArray () from /usr/lib/libXt.so.6
#10 0x06c23fa4 in _XtCreateHookObj () from /usr/lib/libXt.so.6
#11 0x06c248bf in _XtCreateWidget () from /usr/lib/libXt.so.6
#12 0x06c24c64 in XtCreateWidget () from /usr/lib/libXt.so.6
#13 0x00e76a00 in XmCreateTextField (parent=0x9eb1650, name=0x9eb1650 "0", arglist=0x9eb1650, argcount=166401616)
    at TextF.c:10665
#14 0x08048c4c in main (argc=1, argv=0xbfcf95a4) at XTest.C:97
(gdb)
 
Hopefully, I just don't know what I'm doing and there's something I am overlooking.  Is there something else I need to retain in order to call these functions?  Any ideas?
 
Thanks!
 
Sincerely,
 
 
 
Chad Moore


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