Re: Font Sizes



Here is my code:


PangoContext *context;
PangoFontMetrics *metrics;
PangoFontDescription *font_desc = NULL;
GtkTextTag *tag;
GtkTextBuffer *buffer;

buffer = gtk_text_view_get_buffer(view);
    
tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer),
                                "Normal");

g_object_get(G_OBJECT(tag), "font-desc", &font_desc, NULL);
context = gtk_widget_get_pango_context(GTK_WIDGET(view));
metrics = pango_context_get_metrics(context, font_desc,
                                    pango_context_get_language(context));



And when the pango_context_get_metrics function is run, my program
dies, complaining:


glkfoo (pid:1069): ** WARNING **: Couldn't load font "monospace" falling back to "Sans"

glkfoo (pid:1069): ** WARNING **: Couldn't load font "Sans" falling back to "Sans"

glkfoo (pid:1069): ** WARNING **: All font failbacks failed!!!!



Clearly the necessary fonts are available, because if I don't measure
the metrics and just make bad guesses for the size of the textview,
everything displays fine.  What do I need to do to make pango
cooperate?

Here's the values in those structures as reported by gdb right before
asking for the metrics, if this is of any help:

(gdb) p *context
$1 = {parent_instance = {g_type_instance = {g_class = 0x10058dd8}, 
    ref_count = 1, qdata = 0x1001e078}, language = 0x10059c78, 
  base_dir = PANGO_DIRECTION_LTR, font_desc = 0x10087098, 
  font_map = 0x100145c0}
(gdb) p *font_desc
$2 = {family_name = 0x100842c0 "monospace", style = PANGO_STYLE_NORMAL, 
  variant = PANGO_VARIANT_NORMAL, weight = PANGO_WEIGHT_NORMAL, 
  stretch = PANGO_STRETCH_NORMAL, mask = 11, static_family = 0, size = 0}
(gdb) p *tag
$3 = {parent_instance = {g_type_instance = {g_class = 0x1007d600}, 
    ref_count = 2, qdata = 0x0}, table = 0x100835e0, 
  name = 0x10085980 "Normal", priority = 0, values = 0x100858f0, 
  bg_color_set = 0, bg_stipple_set = 0, fg_color_set = 0, scale_set = 1, 
  fg_stipple_set = 0, justification_set = 1, left_margin_set = 1, 
  indent_set = 0, rise_set = 0, strikethrough_set = 0, right_margin_set = 0, 
  pixels_above_lines_set = 0, pixels_below_lines_set = 0, 
  pixels_inside_wrap_set = 0, tabs_set = 0, underline_set = 0, 
  wrap_mode_set = 0, bg_full_height_set = 0, invisible_set = 0, 
  editable_set = 1, language_set = 0, pad1 = 0, pad2 = 0, pad3 = 0}
(gdb) p *view->layout
$4 = {parent_instance = {g_type_instance = {g_class = 0x100555e8}, 
    ref_count = 1, qdata = 0x0}, screen_width = 599, width = 0, height = 20, 
  buffer = 0x100841c0, default_style = 0x10086e30, ltr_context = 0x10086da0, 
  rtl_context = 0x10086de0, one_style_cache = 0x0, 
  one_display_cache = 0x100855f0, wrap_loop_count = 0, cursor_visible = 0, 
  cursor_direction = 0, preedit_string = 0x0, preedit_attrs = 0x0, 
  preedit_len = 0, preedit_cursor = 0}





I have another problem too.

I wanted paned widgets which work using proportions instead of pixel
distances.  So, back with gtk 1.3.9, I copied gtkpaned.c, gtkhpaned.c,
gtkvpaned.c, and hacked them up a bit to get them to work.  Since then
apparently gtk has changed a bit, so my hacked-up versions don't work
as well (dragging the handle is broken).  I can go through and copy
the new version and fix it up again, but this will get tedious if I
have to do this every few versions...

gtk is *supposed* to have object-oriented stuff, but I can't figure
out how to do simple inheritence stuff with it (mostly I just want to
add a "percent" property and replace gtk_paned_compute_position)...

What's the recommended way to do this and not have maintenance
nightmares?  I suppose I could use lots of preprocessor stuff instead
of search-replace to make applying patches easier, but that's not much
of a solution... and having to copy an entire widget to make one minor
change doesn't seem very elegant.



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