Well, besides determining the width of the GtkTextView in
characters, I also need to determine its height in lines, or the number
of visible lines. I've tried a solution with font metrics, but the value
is wrong. The code I'm using is something like this:

  PangoContext         *context;
  PangoFontDescription *fontdesc;
  PangoFontMetrics     *metrics;
  int                   char_height;

  /* Get the size of the text view */
  gtk_text_view_get_visible_rect(gui->txtView, &rect);

  /* Get the Pango context */
  context = gtk_widget_get_pango_context(GTK_WIDGET(gui->txtView));

  /* Load metrics for the font */
  fontdesc = pango_context_get_font_description(context);
  metrics = pango_context_get_metrics(context,
                                      fontdesc,
                                      NULL);

  /* Determine character height */
  char_height = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics)
                             + pango_font_metrics_get_descent(metrics));

  lines = rect.height / char_height;


But the character height is returned as 29 pixels. I've counted with
xmag and the real height of a line (including possibly some inter-line
spacing not accounted for in that code) is something like 16 or 17 pixels.

-- 
  A verbal contract isn't worth the paper it's written on. Include
  me out. -Samuel Goldwyn

Eduardo M KALINOWSKI
[EMAIL PROTECTED]
http://move.to/hpkb

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

Reply via email to