pango r2577 - in trunk: . pango



Author: behdad
Date: Tue Feb 26 01:30:58 2008
New Revision: 2577
URL: http://svn.gnome.org/viewvc/pango?rev=2577&view=rev

Log:
2008-02-25  Behdad Esfahbod  <behdad gnome org>

        Bug 511172 â pango_layout_set_height() with positive height always
        shows at least two lines

        * pango/pango-layout.c (should_ellipsize_current_line),
        (pango_layout_check_lines),
        (pango_layout_get_empty_extents_at_index),
        (pango_layout_line_get_empty_extents):
        Initialize line_height using empty-line extents.



Modified:
   trunk/ChangeLog
   trunk/pango/pango-layout.c

Modified: trunk/pango/pango-layout.c
==============================================================================
--- trunk/pango/pango-layout.c	(original)
+++ trunk/pango/pango-layout.c	Tue Feb 26 01:30:58 2008
@@ -177,6 +177,10 @@
 static void pango_layout_get_item_properties (PangoItem      *item,
 					      ItemProperties *properties);
 
+static void pango_layout_get_empty_extents_at_index (PangoLayout    *layout,
+						     int             index,
+						     PangoRectangle *logical_rect);
+
 static void pango_layout_finalize    (GObject          *object);
 
 G_DEFINE_TYPE (PangoLayout, pango_layout, G_TYPE_OBJECT)
@@ -396,6 +400,10 @@
  * paragraph.  That is, the total number of lines shown may well be more than
  * this value if the layout contains multiple paragraphs of text.
  * The default value of -1 means that first line of each paragraph is ellipsized.
+ * This behvaior may be changed in the future to act per layout instead of per
+ * paragraph.  File a bug against pango at <ulink
+ * url="http://bugzilla.gnome.org/";>http://bugzilla.gnome.org/</ulink> if your
+ * code relies on this behavior.
  *
  * Height setting only has effect if a positive width is set on
  * @layout and ellipsization mode of @layout is not %PANGO_ELLIPSIZE_NONE.
@@ -3389,7 +3397,7 @@
     }
   else
     {
-      /* -layout->height is numbre of lines per paragraph to show */
+      /* -layout->height is number of lines per paragraph to show */
       return state->line_of_par == - layout->height;
     }
 }
@@ -3705,6 +3713,12 @@
   /* these are only used if layout->height >= 0 */
   state.remaining_height = layout->height;
   state.line_height = -1;
+  if (layout->height >= 0)
+    {
+      PangoRectangle logical;
+      pango_layout_get_empty_extents_at_index (layout, 0, &logical);
+      state.line_height = logical.height;
+    }
 
   do
     {
@@ -4257,21 +4271,16 @@
 }
 
 static void
-pango_layout_line_get_empty_extents (PangoLayoutLine *line,
-				     PangoRectangle  *logical_rect)
+pango_layout_get_empty_extents_at_index (PangoLayout    *layout,
+					 int             index,
+					 PangoRectangle *logical_rect)
 {
   if (logical_rect)
     {
-      char *line_start;
-      int index;
-      PangoLayout *layout = line->layout;
       PangoFont *font;
       PangoFontDescription *font_desc = NULL;
       gboolean free_font_desc = FALSE;
 
-      pango_layout_line_get_range (line, &line_start, NULL);
-      index = line_start - layout->text;
-
       /* Find the font description for this line
        */
       if (layout->attrs)
@@ -4353,6 +4362,13 @@
 }
 
 static void
+pango_layout_line_get_empty_extents (PangoLayoutLine *line,
+				     PangoRectangle  *logical_rect)
+{
+  pango_layout_get_empty_extents_at_index (line->layout, line->start_index, logical_rect);
+}
+
+static void
 pango_layout_run_get_extents (PangoLayoutRun *run,
 			      PangoRectangle *run_ink,
 			      PangoRectangle *run_logical)



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