Fwd: Avoid x advance in PangoLayout



Is it the wrong list? Is it a trivial question?

Please, I need feedback ...


----------  Forwarded Message  ----------

Subject: Avoid x advance in PangoLayout
Date: Thursday 14 September 2006 20:05
From: Fontana Nicola <ntd users sourceforge net>
To: gtk-i18n-list gnome org

Hi,

I'm using Pango to render technical quotes.
A text such as "20.65+0.05 -0.05", for example, must be (well, approximately)
rendered as:

	+0.05
20.65	-0.05

Diving in the Pango documentation, I found a really bad solution.


  PangoAttrList *attr_list;
  PangoAttribute *attribute;

  pango_layout_set_text (layout, "20.65+0.05 -0.05", -1);

  attr_list = pango_attr_list_new ();
  pango_layout_set_attributes (layout, attr_list);
  pango_attr_list_unref (attr_list);

  attribute = pango_attr_size_new (16 * PANGO_SCALE);
  attribute->start_index = 0;
  attribute->end_index = G_MAXUINT;
  pango_attr_list_insert (attr_list, attribute);

  /* Up tolerance */
  attribute = pango_attr_size_new (8 * PANGO_SCALE);
  attribute->start_index = 5;
  attribute->end_index = 10;
  pango_attr_list_insert (attr_list, attribute);

  attribute = pango_attr_rise_new (18 * PANGO_SCALE);
  attribute->start_index = 5;
  attribute->end_index = 10;
  pango_attr_list_insert (attr_list, attribute);

  /* Dirty hack */
  PangoRectangle turnback = { 0, 0,  -36 * PANGO_SCALE, 0 };
  attribute = pango_attr_shape_new (&turnback, &turnback);
  attribute->start_index = 10;
  attribute->end_index = 11;
  pango_attr_list_insert (attr_list, attribute);

  /* Down tolerance */
  attribute = pango_attr_rise_new (6 * PANGO_SCALE);
  attribute->start_index = 11;
  attribute->end_index = G_MAXUINT;
  pango_attr_list_insert (attr_list, attribute);

  attribute = pango_attr_size_new (8 * PANGO_SCALE);
  attribute->start_index = 11;
  attribute->end_index = G_MAXUINT;
  pango_attr_list_insert (attr_list, attribute);


The problem is every text fragments advances the x position.

There is a way to render text without advancing in the x axis?
Or something to modify the x position in the mid of a string?

I know I can split the string in three items, but keeping them as a unit can
avoid me future hangovers.

--
Nicola

-------------------------------------------------------



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