[gtk/pango-line-breaker] Port to pango2 api




commit 3f05313ec3d3a98db666e347133528bbd62022f0
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 23 12:07:49 2022 -0500

    Port to pango2 api

 demos/gtk-demo/fontify.c          |   8 ++
 demos/gtk-demo/fontrendering.c    |  12 +--
 demos/gtk-demo/printing.c         |  17 ++--
 demos/gtk-demo/rotated_text.c     |   7 +-
 demos/print-editor/print-editor.c |  14 ++--
 gtk/a11y/gtkatspipango.c          |   3 +-
 gtk/gskpango.c                    |  24 +++---
 gtk/gtkcellrendererprogress.c     |   6 +-
 gtk/gtkcellrenderertext.c         |  72 +++++++++--------
 gtk/gtkcolorbutton.c              |   3 +-
 gtk/gtkemojichooser.c             |  10 +--
 gtk/gtkglarea.c                   |   7 +-
 gtk/gtklabel.c                    |  83 +++++++++++---------
 gtk/gtkpango.c                    |   7 ++
 gtk/gtkprintunixdialog.c          |   8 +-
 gtk/gtkstylecontext.c             |   2 +-
 gtk/gtktext.c                     |  73 +++++++++--------
 gtk/gtktextbuffer.c               |   8 ++
 gtk/gtktextlayout.c               | 161 ++++++++++++++++++++++----------------
 gtk/gtktextutil.c                 |  45 ++++++-----
 gtk/gtktextview.c                 |   8 +-
 gtk/inspector/fpsoverlay.c        |   9 ++-
 tests/rendernode-create-tests.c   |  17 ++--
 tests/testgtk.c                   | 154 ++++++++++++++++++------------------
 tests/testprintfileoperation.c    |  36 ++++-----
 25 files changed, 442 insertions(+), 352 deletions(-)
---
diff --git a/demos/gtk-demo/fontify.c b/demos/gtk-demo/fontify.c
index cdbdf654d3..888890e194 100644
--- a/demos/gtk-demo/fontify.c
+++ b/demos/gtk-demo/fontify.c
@@ -275,6 +275,10 @@ insert_tags_for_attributes (GtkTextBuffer     *buffer,
         case PANGO_ATTR_ABSOLUTE_LINE_HEIGHT:
           break;
 
+        case PANGO_ATTR_LINE_SPACING:
+          INT_ATTR (pixels_inside_wrap);
+          break;
+
         case PANGO_ATTR_WORD:
           VOID_ATTR (word);
           break;
@@ -283,6 +287,10 @@ insert_tags_for_attributes (GtkTextBuffer     *buffer,
           VOID_ATTR (sentence);
           break;
 
+        case PANGO_ATTR_PARAGRAPH:
+          VOID_ATTR (paragraph);
+          break;
+
         case PANGO_ATTR_BASELINE_SHIFT:
           INT_ATTR (baseline_shift);
           break;
diff --git a/demos/gtk-demo/fontrendering.c b/demos/gtk-demo/fontrendering.c
index 283523f481..410ca3fe3d 100644
--- a/demos/gtk-demo/fontrendering.c
+++ b/demos/gtk-demo/fontrendering.c
@@ -95,8 +95,8 @@ update_image (void)
       layout = pango_layout_new (context);
       pango_layout_set_font_description (layout, desc);
       pango_layout_set_text (layout, text, -1);
-      pango_layout_get_extents (layout, &ink, &logical);
-      baseline = pango_layout_get_baseline (layout);
+      pango_lines_get_extents (pango_layout_get_lines (layout), &ink, &logical);
+      baseline = pango_lines_get_baseline (pango_layout_get_lines (layout));
 
       pango_extents_to_pixels (&ink, NULL);
 
@@ -208,6 +208,7 @@ update_image (void)
     {
       PangoLayoutIter *iter;
       PangoLayoutRun *run;
+      PangoGlyphString *glyphs;
       PangoGlyphInfo *g;
       int i, j;
       GString *str;
@@ -230,7 +231,7 @@ update_image (void)
       pango_layout_set_font_description (layout, desc);
       pango_layout_set_text (layout, str->str, -1);
       g_string_free (str, TRUE);
-      pango_layout_get_extents (layout, &ink, &logical);
+      pango_lines_get_extents (pango_layout_get_lines (layout), &ink, &logical);
       pango_extents_to_pixels (&logical, NULL);
 
       surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, logical.width * 3 / 2, 4*logical.height);
@@ -240,11 +241,12 @@ update_image (void)
 
       iter = pango_layout_get_iter (layout);
       run = pango_layout_iter_get_run (iter);
+      glyphs = pango_layout_run_get_glyphs (run);
 
       cairo_set_source_rgb (cr, 0, 0, 0);
       for (i = 0; i < 4; i++)
         {
-          g = &(run->glyphs->glyphs[2*i]);
+          g = &(glyphs->glyphs[2*i]);
           g->geometry.width = PANGO_UNITS_ROUND (g->geometry.width * 3 / 2);
         }
 
@@ -252,7 +254,7 @@ update_image (void)
         {
           for (i = 0; i < 4; i++)
             {
-              g = &(run->glyphs->glyphs[2*i]);
+              g = &(glyphs->glyphs[2*i]);
               g->geometry.x_offset = i * (PANGO_SCALE / 4);
               g->geometry.y_offset = j * (PANGO_SCALE / 4);
             }
diff --git a/demos/gtk-demo/printing.c b/demos/gtk-demo/printing.c
index beef569f25..2633f8a3aa 100644
--- a/demos/gtk-demo/printing.c
+++ b/demos/gtk-demo/printing.c
@@ -60,7 +60,7 @@ draw_page (GtkPrintOperation *operation,
   PrintData *data = (PrintData *)user_data;
   cairo_t *cr;
   PangoLayout *layout;
-  int text_width, text_height;
+  PangoRectangle ext;
   double width;
   int line, i;
   PangoFontDescription *desc;
@@ -85,16 +85,18 @@ draw_page (GtkPrintOperation *operation,
   pango_font_description_free (desc);
 
   pango_layout_set_text (layout, data->resourcename, -1);
-  pango_layout_get_pixel_size (layout, &text_width, &text_height);
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+  pango_extents_to_pixels (&ext, NULL);
 
-  if (text_width > width)
+  if (ext.width > width)
     {
       pango_layout_set_width (layout, width);
       pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_START);
-      pango_layout_get_pixel_size (layout, &text_width, &text_height);
+      pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+      pango_extents_to_pixels (&ext, NULL);
     }
 
-  cairo_move_to (cr, (width - text_width) / 2,  (HEADER_HEIGHT - text_height) / 2);
+  cairo_move_to (cr, (width - ext.width) / 2,  (HEADER_HEIGHT - ext.height) / 2);
   pango_cairo_show_layout (cr, layout);
 
   page_str = g_strdup_printf ("%d/%d", page_nr + 1, data->num_pages);
@@ -102,8 +104,9 @@ draw_page (GtkPrintOperation *operation,
   g_free (page_str);
 
   pango_layout_set_width (layout, -1);
-  pango_layout_get_pixel_size (layout, &text_width, &text_height);
-  cairo_move_to (cr, width - text_width - 4, (HEADER_HEIGHT - text_height) / 2);
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+  pango_extents_to_pixels (&ext, NULL);
+  cairo_move_to (cr, width - ext.width - 4, (HEADER_HEIGHT - ext.height) / 2);
   pango_cairo_show_layout (cr, layout);
 
   g_object_unref (layout);
diff --git a/demos/gtk-demo/rotated_text.c b/demos/gtk-demo/rotated_text.c
index 4f2c3f9513..16a7131705 100644
--- a/demos/gtk-demo/rotated_text.c
+++ b/demos/gtk-demo/rotated_text.c
@@ -142,13 +142,14 @@ rotated_text_draw (GtkDrawingArea *da,
   /* Draw the layout N_WORDS times in a circle */
   for (i = 0; i < N_WORDS; i++)
     {
-      int layout_width, layout_height;
+      PangoRectangle ext;
 
       /* Inform Pango to re-layout the text with the new transformation matrix */
       pango_cairo_update_layout (cr, layout);
 
-      pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
-      cairo_move_to (cr, - layout_width / 2, - RADIUS * .9);
+      pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+      pango_extents_to_pixels (&ext, NULL);
+      cairo_move_to (cr, - ext.width / 2, - RADIUS * .9);
       pango_cairo_show_layout (cr, layout);
 
       /* Rotate for the next turn */
diff --git a/demos/print-editor/print-editor.c b/demos/print-editor/print-editor.c
index bfadd5e494..6282a4178a 100644
--- a/demos/print-editor/print-editor.c
+++ b/demos/print-editor/print-editor.c
@@ -212,6 +212,7 @@ begin_print (GtkPrintOperation *operation,
             PrintData *print_data)
 {
   PangoFontDescription *desc;
+  PangoLines *lines;
   PangoLayoutLine *layout_line;
   double width, height;
   double page_height;
@@ -232,18 +233,19 @@ begin_print (GtkPrintOperation *operation,
 
   pango_layout_set_text (print_data->layout, print_data->text, -1);
 
-  num_lines = pango_layout_get_line_count (print_data->layout);
+  lines = pango_layout_get_lines (print_data->layout);
+  num_lines = pango_lines_get_line_count (lines);
 
   page_breaks = NULL;
   page_height = 0;
 
   for (line = 0; line < num_lines; line++)
     {
-      PangoRectangle ink_rect, logical_rect;
+      PangoRectangle logical_rect;
       double line_height;
 
-      layout_line = pango_layout_get_line (print_data->layout, line);
-      pango_layout_line_get_extents (layout_line, &ink_rect, &logical_rect);
+      layout_line = pango_lines_get_line (lines, line, NULL, NULL);
+      pango_layout_line_get_extents (layout_line, NULL, &logical_rect);
 
       line_height = logical_rect.height / 1024.0;
 
@@ -284,7 +286,7 @@ draw_page (GtkPrintOperation *operation,
 
   pagebreak = g_list_nth (print_data->page_breaks, page_nr);
   if (pagebreak == NULL)
-    end = pango_layout_get_line_count (print_data->layout);
+    end = pango_lines_get_line_count (pango_layout_get_lines (print_data->layout));
   else
     end = GPOINTER_TO_INT (pagebreak->data);
 
@@ -306,7 +308,7 @@ draw_page (GtkPrintOperation *operation,
          line = pango_layout_iter_get_line (iter);
 
          pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
-         baseline = pango_layout_iter_get_baseline (iter);
+         baseline = pango_layout_iter_get_line_baseline (iter);
 
          if (i == start)
            start_pos = logical_rect.y / 1024.0;
diff --git a/gtk/a11y/gtkatspipango.c b/gtk/a11y/gtkatspipango.c
index 729d5d4987..7fa37ad7b4 100644
--- a/gtk/a11y/gtkatspipango.c
+++ b/gtk/a11y/gtkatspipango.c
@@ -137,8 +137,9 @@ pango_align_to_string (PangoAlignment align)
       return "center";
     case PANGO_ALIGN_RIGHT:
       return "right";
+    case PANGO_ALIGN_NATURAL:
+      return "natural";
     case PANGO_ALIGN_JUSTIFY:
-    case PANGO_ALIGN_JUSTIFY_ALL:
       return "fill";
     default:
       g_assert_not_reached ();
diff --git a/gtk/gskpango.c b/gtk/gskpango.c
index 6807ada46d..773bb6d3d7 100644
--- a/gtk/gskpango.c
+++ b/gtk/gskpango.c
@@ -139,16 +139,17 @@ gsk_pango_renderer_draw_trapezoid (PangoRenderer   *renderer,
                                    double           x22)
 {
   GskPangoRenderer *crenderer = (GskPangoRenderer *) (renderer);
-  PangoLayout *layout;
+  PangoLines *lines;
   PangoRectangle ink_rect;
   cairo_t *cr;
   double x, y;
 
-  layout = pango_renderer_get_layout (renderer);
-  if (!layout)
+  lines = pango_renderer_get_lines (renderer);
+  if (!lines)
     return;
 
-  pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
+  pango_lines_get_extents (lines, &ink_rect, NULL);
+  pango_extents_to_pixels (&ink_rect, NULL);
   cr = gtk_snapshot_append_cairo (crenderer->snapshot,
                                   &GRAPHENE_RECT_INIT (ink_rect.x, ink_rect.y,
                                                        ink_rect.width, ink_rect.height));
@@ -214,7 +215,7 @@ gsk_pango_renderer_draw_shape (PangoRenderer  *renderer,
                                int             y)
 {
   GskPangoRenderer *crenderer = (GskPangoRenderer *) (renderer);
-  PangoLayout *layout;
+  PangoLines *lines;
   PangoCairoShapeRendererFunc shape_renderer;
   gpointer shape_renderer_data;
   double base_x = (double)x / PANGO_SCALE;
@@ -245,15 +246,16 @@ gsk_pango_renderer_draw_shape (PangoRenderer  *renderer,
       cairo_t *cr;
       PangoRectangle ink_rect;
 
-      layout = pango_renderer_get_layout (renderer);
-      if (!layout)
+      lines = pango_renderer_get_lines (renderer);
+      if (!lines)
         return;
 
-      pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
+      pango_lines_get_extents (lines, &ink_rect, NULL);
+      pango_extents_to_pixels (&ink_rect, NULL);
       cr = gtk_snapshot_append_cairo (crenderer->snapshot,
                                       &GRAPHENE_RECT_INIT (ink_rect.x, ink_rect.y,
                                                            ink_rect.width, ink_rect.height));
-      shape_renderer = pango_cairo_context_get_shape_renderer (pango_layout_get_context (layout),
+      shape_renderer = pango_cairo_context_get_shape_renderer (pango_renderer_get_context (renderer),
                                                                &shape_renderer_data);
 
       if (!shape_renderer)
@@ -326,7 +328,7 @@ gsk_pango_renderer_prepare_run (PangoRenderer  *renderer,
 
   PANGO_RENDERER_CLASS (gsk_pango_renderer_parent_class)->prepare_run (renderer, run);
 
-  appearance = get_item_appearance (run->item);
+  appearance = get_item_appearance (pango_layout_run_get_item (run));
 
   if (appearance == NULL)
     return;
@@ -476,7 +478,7 @@ gtk_snapshot_append_layout (GtkSnapshot   *snapshot,
   crenderer->snapshot = snapshot;
   crenderer->fg_color = color;
 
-  pango_renderer_draw_layout (PANGO_RENDERER (crenderer), layout, 0, 0);
+  pango_renderer_draw_lines (PANGO_RENDERER (crenderer), pango_layout_get_lines (layout), 0, 0);
 
   gsk_pango_renderer_release (crenderer);
 }
diff --git a/gtk/gtkcellrendererprogress.c b/gtk/gtkcellrendererprogress.c
index 8139a3b058..b89d799533 100644
--- a/gtk/gtkcellrendererprogress.c
+++ b/gtk/gtkcellrendererprogress.c
@@ -289,7 +289,8 @@ compute_dimensions (GtkCellRenderer *cell,
   int xpad, ypad;
 
   layout = gtk_widget_create_pango_layout (widget, text);
-  pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &logical_rect);
+  pango_extents_to_pixels (&logical_rect, NULL);
 
   gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
 
@@ -506,7 +507,8 @@ gtk_cell_renderer_progress_snapshot (GtkCellRenderer      *cell,
       float text_xalign;
 
       layout = gtk_widget_create_pango_layout (widget, priv->label);
-      pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+      pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &logical_rect);
+      pango_extents_to_pixels (&logical_rect, NULL);
 
       if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
        text_xalign = 1.0 - priv->text_xalign;
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index a7f347d72d..d4980ec6d7 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -237,7 +237,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class)
   GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
 
   object_class->finalize = gtk_cell_renderer_text_finalize;
-  
+
   object_class->get_property = gtk_cell_renderer_text_get_property;
   object_class->set_property = gtk_cell_renderer_text_set_property;
 
@@ -720,7 +720,7 @@ gtk_cell_renderer_text_get_property (GObject        *object,
     case PROP_FONT:
         g_value_take_string (value, pango_font_description_to_string (priv->font));
       break;
-      
+
     case PROP_FONT_DESC:
       g_value_set_boxed (value, priv->font);
       break;
@@ -756,7 +756,7 @@ gtk_cell_renderer_text_get_property (GObject        *object,
     case PROP_SCALE:
       g_value_set_double (value, priv->font_scale);
       break;
-      
+
     case PROP_EDITABLE:
       g_value_set_boolean (value, priv->editable);
       break;
@@ -771,7 +771,7 @@ gtk_cell_renderer_text_get_property (GObject        *object,
 
     case PROP_RISE:
       g_value_set_int (value, priv->rise);
-      break;  
+      break;
 
     case PROP_LANGUAGE:
       g_value_set_static_string (value, pango_language_to_string (priv->language));
@@ -780,7 +780,7 @@ gtk_cell_renderer_text_get_property (GObject        *object,
     case PROP_ELLIPSIZE:
       g_value_set_enum (value, priv->ellipsize);
       break;
-      
+
     case PROP_WRAP_MODE:
       g_value_set_enum (value, priv->wrap_mode);
       break;
@@ -788,7 +788,7 @@ gtk_cell_renderer_text_get_property (GObject        *object,
     case PROP_WRAP_WIDTH:
       g_value_set_int (value, priv->wrap_width);
       break;
-      
+
     case PROP_ALIGN:
       g_value_set_enum (value, priv->align);
       break;
@@ -810,14 +810,14 @@ gtk_cell_renderer_text_get_property (GObject        *object,
       {
        PangoFontMask mask = get_property_font_set_mask (param_id);
        g_value_set_boolean (value, (pango_font_description_get_set_fields (priv->font) & mask) != 0);
-       
+
        break;
       }
 
     case PROP_SCALE_SET:
       g_value_set_boolean (value, priv->scale_set);
       break;
-      
+
     case PROP_EDITABLE_SET:
       g_value_set_boolean (value, priv->editable_set);
       break;
@@ -845,14 +845,14 @@ gtk_cell_renderer_text_get_property (GObject        *object,
     case PROP_ALIGN_SET:
       g_value_set_boolean (value, priv->align_set);
       break;
-      
+
     case PROP_WIDTH_CHARS:
       g_value_set_int (value, priv->width_chars);
-      break;  
+      break;
 
     case PROP_MAX_WIDTH_CHARS:
       g_value_set_int (value, priv->max_width_chars);
-      break;  
+      break;
 
     case PROP_PLACEHOLDER_TEXT:
       g_value_set_string (value, priv->placeholder_text);
@@ -925,7 +925,7 @@ set_font_desc_fields (PangoFontDescription *desc,
                      PangoFontMask         to_set)
 {
   PangoFontMask changed_mask = 0;
-  
+
   if (to_set & PANGO_FONT_MASK_FAMILY)
     {
       const char *family = pango_font_description_get_family (desc);
@@ -953,7 +953,7 @@ set_font_desc_fields (PangoFontDescription *desc,
          size = 10 * PANGO_SCALE;
          changed_mask |= PANGO_FONT_MASK_SIZE;
        }
-      
+
       pango_font_description_set_size (desc, size);
     }
 
@@ -1387,7 +1387,7 @@ gtk_cell_renderer_text_set_property (GObject      *object,
 
 /**
  * gtk_cell_renderer_text_new:
- * 
+ *
  * Creates a new `GtkCellRendererText`. Adjust how text is drawn using
  * object properties. Object properties can be
  * set globally (with g_object_set()). Also, with `GtkTreeViewColumn`,
@@ -1395,7 +1395,7 @@ gtk_cell_renderer_text_set_property (GObject      *object,
  * you can bind the “text” property on the cell renderer to a string
  * value in the model, thus rendering a different string in each row
  * of the `GtkTreeView`.
- * 
+ *
  * Returns: the new cell renderer
  **/
 GtkCellRenderer *
@@ -1419,7 +1419,7 @@ add_attr (PangoAttrList  *attr_list,
 {
   attr->start_index = 0;
   attr->end_index = G_MAXINT;
-  
+
   pango_attr_list_insert (attr_list, attr);
 }
 
@@ -1446,16 +1446,16 @@ get_layout (GtkCellRendererText *celltext,
   else
     attr_list = pango_attr_list_new ();
 
-  pango_layout_set_single_paragraph_mode (layout, priv->single_paragraph);
+  pango_layout_set_single_paragraph (layout, priv->single_paragraph);
 
   if (!placeholder_layout && cell_area)
     {
       /* Add options that affect appearance but not size */
-      
+
       /* note that background doesn't go here, since it affects
        * background_area not the PangoLayout area
        */
-      
+
       if (priv->foreground_set
          && (flags & GTK_CELL_RENDERER_SELECTED) == 0)
         {
@@ -1560,7 +1560,7 @@ get_layout (GtkCellRendererText *celltext,
       PangoRectangle rect;
       int            width, text_width;
 
-      pango_layout_get_extents (layout, NULL, &rect);
+      pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &rect);
       text_width = rect.width;
 
       if (cell_area)
@@ -1592,7 +1592,7 @@ get_layout (GtkCellRendererText *celltext,
 
       pango_layout_set_alignment (layout, align);
     }
-  
+
   return layout;
 }
 
@@ -1649,7 +1649,7 @@ get_size (GtkCellRenderer    *cell,
       gtk_cell_renderer_set_fixed_size (cell,
                                        cell_width, 2 * ypad +
                                        priv->fixed_height_rows * PANGO_PIXELS (row_height));
-      
+
       if (height)
        {
          *height = cell_height;
@@ -1660,7 +1660,8 @@ get_size (GtkCellRenderer    *cell,
        return;
     }
 
-  pango_layout_get_pixel_extents (layout, NULL, &rect);
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &rect);
+  pango_extents_to_pixels (&rect, NULL);
 
   gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);
 
@@ -1725,7 +1726,8 @@ gtk_cell_renderer_text_snapshot (GtkCellRenderer      *cell,
   else if (priv->wrap_width == -1)
     pango_layout_set_width (layout, -1);
 
-  pango_layout_get_pixel_extents (layout, NULL, &rect);
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &rect);
+  pango_extents_to_pixels (&rect, NULL);
   x_offset = x_offset - rect.x;
 
   gtk_snapshot_push_clip (snapshot,
@@ -1826,7 +1828,7 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer      *cell,
   if (priv->text)
     gtk_editable_set_text (GTK_EDITABLE (priv->entry), priv->text);
   g_object_set_data_full (G_OBJECT (priv->entry), I_(GTK_CELL_RENDERER_TEXT_PATH), g_strdup (path), g_free);
-  
+
   gtk_editable_select_region (GTK_EDITABLE (priv->entry), 0, -1);
 
   priv->in_entry_menu = FALSE;
@@ -1849,7 +1851,7 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer      *cell,
  * gtk_cell_renderer_text_set_fixed_height_from_font:
  * @renderer: A `GtkCellRendererText`
  * @number_of_rows: Number of rows of text each cell renderer is allocated, or -1
- * 
+ *
  * Sets the height of a renderer to explicitly be determined by the “font” and
  * “y_pad” property set on it.  Further changes in these properties do not
  * affect the height, so they must be accompanied by a subsequent call to this
@@ -1911,7 +1913,7 @@ gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell,
 
   /* Fetch the length of the complete unwrapped text */
   pango_layout_set_width (layout, -1);
-  pango_layout_get_extents (layout, NULL, &rect);
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &rect);
   text_width = rect.width;
 
   /* Fetch the average size of a character */
@@ -1952,7 +1954,7 @@ gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell,
   if (priv->max_width_chars > 0)
     {
       int max_width = xpad * 2 + PANGO_PIXELS (char_width) * priv->max_width_chars;
-      
+
       min_width = MIN (min_width, max_width);
       nat_width = MIN (nat_width, max_width);
     }
@@ -1972,21 +1974,23 @@ gtk_cell_renderer_text_get_preferred_height_for_width (GtkCellRenderer *cell,
                                                        int             *natural_height)
 {
   GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (cell);
-  PangoLayout         *layout;
-  int                  text_height, xpad, ypad;
+  PangoLayout *layout;
+  int xpad, ypad;
+  PangoRectangle ext;
 
   gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
 
   layout = get_layout (celltext, widget, NULL, 0);
 
   pango_layout_set_width (layout, (width - xpad * 2) * PANGO_SCALE);
-  pango_layout_get_pixel_size (layout, NULL, &text_height);
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+  pango_extents_to_pixels (&ext, NULL);
 
   if (minimum_height)
-    *minimum_height = text_height + ypad * 2;
+    *minimum_height = ext.height + ypad * 2;
 
   if (natural_height)
-    *natural_height = text_height + ypad * 2;
+    *natural_height = ext.height + ypad * 2;
 
   g_object_unref (layout);
 }
@@ -2024,7 +2028,7 @@ gtk_cell_renderer_text_get_aligned_area (GtkCellRenderer       *cell,
   int y_offset = 0;
 
   layout = get_layout (celltext, widget, cell_area, flags);
-  get_size (cell, widget, cell_area, layout, &x_offset, &y_offset, 
+  get_size (cell, widget, cell_area, layout, &x_offset, &y_offset,
            &aligned_area->width, &aligned_area->height);
 
   aligned_area->x = cell_area->x + x_offset;
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
index 71289e3433..357bf4a220 100644
--- a/gtk/gtkcolorbutton.c
+++ b/gtk/gtkcolorbutton.c
@@ -301,7 +301,8 @@ gtk_color_button_init (GtkColorButton *button)
   gtk_widget_set_can_focus (button->swatch, FALSE);
   gtk_widget_remove_css_class (button->swatch, "activatable");
   layout = gtk_widget_create_pango_layout (GTK_WIDGET (button), "Black");
-  pango_layout_get_pixel_extents (layout, NULL, &rect);
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &rect);
+  pango_extents_to_pixels (&rect, NULL);
   g_object_unref (layout);
 
   gtk_widget_set_size_request (button->swatch, rect.width, rect.height);
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index 810072c146..c7f1edba3f 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -573,10 +573,10 @@ add_emoji (GtkWidget    *box,
   pango_attr_list_unref (attrs);
 
   layout = gtk_label_get_layout (GTK_LABEL (label));
-  pango_layout_get_extents (layout, &rect, NULL);
+  pango_lines_get_extents (pango_layout_get_lines (layout), &rect, NULL);
 
   /* Check for fallback rendering that generates too wide items */
-  if (pango_layout_get_unknown_glyphs_count (layout) > 0 ||
+  if (pango_lines_get_unknown_glyphs_count (pango_layout_get_lines (layout)) > 0 ||
       rect.width >= 1.5 * chooser->emoji_max_width)
     {
       g_object_ref_sink (label);
@@ -866,7 +866,7 @@ filter_func (GtkFlowBoxChild *child,
     goto out;
 
   term_tokens = g_str_tokenize_and_fold (text, "en", NULL);
-  
+
   g_variant_get_child (emoji_data, 1, "&s", &name);
   name_tokens = g_str_tokenize_and_fold (name, "en", NULL);
   g_variant_get_child (emoji_data, 2, "^a&s", &keywords);
@@ -993,7 +993,7 @@ gtk_emoji_chooser_init (GtkEmojiChooser *chooser)
     pango_layout_set_attributes (layout, attrs);
     pango_attr_list_unref (attrs);
 
-    pango_layout_get_extents (layout, &rect, NULL);
+    pango_lines_get_extents (pango_layout_get_lines (layout), &rect, NULL);
     chooser->emoji_max_width = rect.width;
 
     g_object_unref (layout);
@@ -1278,7 +1278,7 @@ gtk_emoji_chooser_class_init (GtkEmojiChooserClass *klass)
    * @direction: 1 to scroll forward, -1 to scroll back
    *
    * Scrolls to the next or previous section.
-   */ 
+   */
   gtk_widget_class_install_action (widget_class, "scroll.section", "i",
                                    gtk_emoji_chooser_scroll_section);
 
diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
index af4d46ec91..cb6b7df200 100644
--- a/gtk/gtkglarea.c
+++ b/gtk/gtkglarea.c
@@ -652,17 +652,18 @@ gtk_gl_area_draw_error_screen (GtkGLArea   *area,
 {
   GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
   PangoLayout *layout;
-  int layout_height;
+  PangoRectangle ext;
 
   layout = gtk_widget_create_pango_layout (GTK_WIDGET (area),
                                            priv->error->message);
   pango_layout_set_width (layout, width * PANGO_SCALE);
   pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
-  pango_layout_get_pixel_size (layout, NULL, &layout_height);
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+  pango_extents_to_pixels (&ext, NULL);
 
   gtk_snapshot_render_layout (snapshot,
                               gtk_widget_get_style_context (GTK_WIDGET (area)),
-                              0, (height - layout_height) / 2,
+                              0, (height - ext.height) / 2,
                               layout);
 
   g_object_unref (layout);
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 7560e551fe..af55c21372 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -882,15 +882,16 @@ gtk_label_css_changed (GtkWidget         *widget,
 static PangoDirection
 get_cursor_direction (GtkLabel *self)
 {
-  GSList *l;
+  PangoLines *lines;
 
   g_assert (self->select_info);
 
   gtk_label_ensure_layout (self);
 
-  for (l = pango_layout_get_lines_readonly (self->layout); l; l = l->next)
+  lines = pango_layout_get_lines (self->layout);
+  for (int i = 0; i < pango_lines_get_line_count (lines); i++)
     {
-      PangoLayoutLine *line = l->data;
+      PangoLayoutLine *line = pango_lines_get_line (lines, i, NULL, NULL);
 
       /* If self->select_info->selection_end is at the very end of
        * the line, we don't know if the cursor is on this line or
@@ -972,6 +973,7 @@ gtk_label_get_measuring_layout (GtkLabel    *self,
                                 PangoLayout *existing_layout,
                                 int          width)
 {
+  PangoLines *lines;
   PangoLayout *copy;
 
   if (existing_layout != NULL)
@@ -1009,15 +1011,15 @@ gtk_label_get_measuring_layout (GtkLabel    *self,
    * can just return the current layout, because for measuring purposes, it will be
    * identical.
    */
-  if (!pango_layout_is_wrapped (self->layout) &&
-      !pango_layout_is_ellipsized (self->layout))
+  lines = pango_layout_get_lines (self->layout);
+  if (!pango_lines_wrapped (lines) && !pango_lines_ellipsized (lines))
     {
       PangoRectangle rect;
 
       if (width == -1)
         return g_object_ref (self->layout);
 
-      pango_layout_get_extents (self->layout, NULL, &rect);
+      pango_lines_get_extents (lines, NULL, &rect);
       if (rect.width <= width)
         return g_object_ref (self->layout);
     }
@@ -1096,11 +1098,11 @@ get_static_size (GtkLabel       *self,
 
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
-      pango_layout_get_size (layout, natural, NULL);
+      pango_lines_get_size (pango_layout_get_lines (layout), natural, NULL);
       if (self->ellipsize)
         {
           layout = gtk_label_get_measuring_layout (self, layout, 0);
-          pango_layout_get_size (layout, minimum, NULL);
+          pango_lines_get_size (pango_layout_get_lines (layout), minimum, NULL);
           /* yes, Pango ellipsizes even when that needs more space */
           *minimum = MIN (*minimum, *natural);
         }
@@ -1113,8 +1115,8 @@ get_static_size (GtkLabel       *self,
     }
   else
     {
-      pango_layout_get_size (layout, NULL, minimum);
-      *minimum_baseline = pango_layout_get_baseline (layout);
+      pango_lines_get_size (pango_layout_get_lines (layout), NULL, minimum);
+      *minimum_baseline = pango_lines_get_baseline (pango_layout_get_lines (layout));
 
       *natural = *minimum;
       *natural_baseline = *minimum_baseline;
@@ -1138,16 +1140,16 @@ get_height_for_width (GtkLabel *self,
     {
       /* Minimum height is assuming infinite width */
       layout = gtk_label_get_measuring_layout (self, NULL, -1);
-      pango_layout_get_size (layout, NULL, minimum_height);
-      baseline = pango_layout_get_baseline (layout);
+      pango_lines_get_size (pango_layout_get_lines (layout), NULL, minimum_height);
+      baseline = pango_lines_get_baseline (pango_layout_get_lines (layout));
       *minimum_baseline = baseline;
 
       /* Natural height is assuming natural width */
       get_default_widths (self, NULL, &natural_width);
 
       layout = gtk_label_get_measuring_layout (self, layout, natural_width);
-      pango_layout_get_size (layout, NULL, natural_height);
-      baseline = pango_layout_get_baseline (layout);
+      pango_lines_get_size (pango_layout_get_lines (layout), NULL, natural_height);
+      baseline = pango_lines_get_baseline (pango_layout_get_lines (layout));
       *natural_baseline = baseline;
     }
   else
@@ -1155,12 +1157,12 @@ get_height_for_width (GtkLabel *self,
       /* minimum = natural for any given width */
       layout = gtk_label_get_measuring_layout (self, NULL, width);
 
-      pango_layout_get_size (layout, NULL, &text_height);
+      pango_lines_get_size (pango_layout_get_lines (layout), NULL, &text_height);
 
       *minimum_height = text_height;
       *natural_height = text_height;
 
-      baseline = pango_layout_get_baseline (layout);
+      baseline = pango_lines_get_baseline (pango_layout_get_lines (layout));
       *minimum_baseline = baseline;
       *natural_baseline = baseline;
     }
@@ -1183,7 +1185,7 @@ my_pango_layout_get_width_for_height (PangoLayout *layout,
     {
       mid = (min + max) / 2;
       pango_layout_set_width (layout, mid * PANGO_SCALE);
-      pango_layout_get_size (layout, &text_width, &text_height);
+      pango_lines_get_size (pango_layout_get_lines (layout), &text_width, &text_height);
       text_width = PANGO_PIXELS_CEIL (text_width);
       if (text_width > mid)
         min = text_width;
@@ -1211,12 +1213,12 @@ get_width_for_height (GtkLabel *self,
     {
       /* Minimum width is as many line breaks as possible */
       layout = gtk_label_get_measuring_layout (self, NULL, MAX (minimum_default, 0));
-      pango_layout_get_size (layout, minimum_width, NULL);
+      pango_lines_get_size (pango_layout_get_lines (layout), minimum_width, NULL);
       *minimum_width = MAX (*minimum_width, minimum_default);
 
       /* Natural width is natural width - or as wide as possible */
       layout = gtk_label_get_measuring_layout (self, layout, natural_default);
-      pango_layout_get_size (layout, natural_width, NULL);
+      pango_lines_get_size (pango_layout_get_lines (layout), natural_width, NULL);
       *natural_width = MAX (*natural_width, *minimum_width);
     }
   else
@@ -1234,7 +1236,7 @@ get_width_for_height (GtkLabel *self,
       min = MAX (minimum_default, 0);
 
       pango_layout_set_width (layout, -1);
-      pango_layout_get_size (layout, &max, NULL);
+      pango_lines_get_size (pango_layout_get_lines (layout), &max, NULL);
 
       /* first, do natural width */
       if (self->natural_wrap_mode == GTK_NATURAL_WRAP_NONE)
@@ -1253,7 +1255,7 @@ get_width_for_height (GtkLabel *self,
         {
           g_object_unref (layout);
           layout = gtk_label_get_measuring_layout (self, NULL, MAX (minimum_default, 0));
-          pango_layout_get_size (layout, minimum_width, NULL);
+          pango_lines_get_size (pango_layout_get_lines (layout), minimum_width, NULL);
           *minimum_width = MAX (*minimum_width, minimum_default);
         }
       else if (self->natural_wrap_mode == GTK_NATURAL_WRAP_INHERIT)
@@ -1320,13 +1322,15 @@ get_layout_location (GtkLabel  *self,
   if (_gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
     xalign = 1.0 - xalign;
 
-  pango_layout_get_pixel_extents (self->layout, NULL, &logical);
+  pango_lines_get_extents (pango_layout_get_lines (self->layout), NULL, &logical);
+  pango_extents_to_pixels (&logical, NULL);
+
   x = floor ((xalign * (widget_width - logical.width)) - logical.x);
 
   baseline = gtk_widget_get_allocated_baseline (widget);
   if (baseline != -1)
     {
-      int layout_baseline = pango_layout_get_baseline (self->layout) / PANGO_SCALE;
+      int layout_baseline = pango_lines_get_baseline (pango_layout_get_lines (self->layout)) / PANGO_SCALE;
       /* yalign is 0 because we can't support yalign while baseline aligning */
       y = baseline - layout_baseline;
     }
@@ -1584,7 +1588,7 @@ range_is_in_ellipsis_full (GtkLabel *self,
 
   gtk_label_ensure_layout (self);
 
-  if (!pango_layout_is_ellipsized (self->layout))
+  if (!pango_lines_ellipsized (pango_layout_get_lines (self->layout)))
     return FALSE;
 
   iter = pango_layout_get_iter (self->layout);
@@ -1594,7 +1598,7 @@ range_is_in_ellipsis_full (GtkLabel *self,
   do {
     PangoLayoutRun *run;
 
-    run = pango_layout_iter_get_run_readonly (iter);
+    run = pango_layout_iter_get_run (iter);
     if (run)
       {
         PangoItem *item;
@@ -1690,7 +1694,7 @@ get_layout_index (GtkLabel *self,
   int trailing = 0;
   const char *cluster;
   const char *cluster_end;
-  gboolean inside;
+  PangoLayoutLine *line;
   int lx, ly;
 
   *index = 0;
@@ -1705,9 +1709,9 @@ get_layout_index (GtkLabel *self,
   x *= PANGO_SCALE;
   y *= PANGO_SCALE;
 
-  inside = pango_layout_xy_to_index (self->layout,
-                                     x, y,
-                                     index, &trailing);
+  line = pango_lines_pos_to_index (pango_layout_get_lines (self->layout),
+                                   x, y,
+                                   index, &trailing);
 
   cluster = self->text + *index;
   cluster_end = cluster;
@@ -1719,7 +1723,7 @@ get_layout_index (GtkLabel *self,
 
   *index += (cluster_end - cluster);
 
-  return inside;
+  return line != NULL;
 }
 
 static gboolean
@@ -4157,8 +4161,7 @@ gtk_label_ensure_layout (GtkLabel *self)
       align = PANGO_ALIGN_CENTER;
       break;
     case GTK_JUSTIFY_FILL:
-      align = rtl ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
-      pango_layout_set_justify (self->layout, TRUE);
+      align = PANGO_ALIGN_JUSTIFY;
       break;
     default:
       g_assert_not_reached();
@@ -4167,7 +4170,7 @@ gtk_label_ensure_layout (GtkLabel *self)
   pango_layout_set_alignment (self->layout, align);
   pango_layout_set_ellipsize (self->layout, self->ellipsize);
   pango_layout_set_wrap (self->layout, self->wrap_mode);
-  pango_layout_set_single_paragraph_mode (self->layout, self->single_line_mode);
+  pango_layout_set_single_paragraph (self->layout, self->single_line_mode);
   if (self->lines > 0)
     pango_layout_set_height (self->layout, - self->lines);
 
@@ -4223,7 +4226,7 @@ gtk_label_move_forward_word (GtkLabel *self,
 
       gtk_label_ensure_layout (self);
 
-      log_attrs = pango_layout_get_log_attrs_readonly (self->layout, &n_attrs);
+      log_attrs = pango_layout_get_log_attrs (self->layout, &n_attrs);
 
       /* Find the next word end */
       new_pos++;
@@ -4247,7 +4250,7 @@ gtk_label_move_backward_word (GtkLabel *self,
 
       gtk_label_ensure_layout (self);
 
-      log_attrs = pango_layout_get_log_attrs_readonly (self->layout, &n_attrs);
+      log_attrs = pango_layout_get_log_attrs (self->layout, &n_attrs);
 
       new_pos -= 1;
 
@@ -5371,7 +5374,7 @@ get_better_cursor (GtkLabel *self,
 
   gtk_label_ensure_layout (self);
 
-  pango_layout_get_cursor_pos (self->layout, index,
+  pango_lines_get_cursor_pos (pango_layout_get_lines (self->layout), NULL, index,
                                &strong_pos, &weak_pos);
 
   if (split_cursor)
@@ -5412,7 +5415,7 @@ gtk_label_move_logically (GtkLabel *self,
 
       length = g_utf8_strlen (self->text, -1);
 
-      log_attrs = pango_layout_get_log_attrs_readonly (self->layout, &n_attrs);
+      log_attrs = pango_layout_get_log_attrs (self->layout, &n_attrs);
 
       while (count > 0 && offset < length)
         {
@@ -5479,12 +5482,14 @@ gtk_label_move_visually (GtkLabel *self,
 
       if (count > 0)
         {
-          pango_layout_move_cursor_visually (self->layout, strong, index, 0, 1, &new_index, &new_trailing);
+          pango_lines_move_cursor (pango_layout_get_lines (self->layout), strong,
+                                   NULL, index, 0, 1, NULL, &new_index, &new_trailing);
           count--;
         }
       else
         {
-          pango_layout_move_cursor_visually (self->layout, strong, index, 0, -1, &new_index, &new_trailing);
+          pango_lines_move_cursor (pango_layout_get_lines (self->layout), strong,
+                                   NULL, index, 0, -1, NULL, &new_index, &new_trailing);
           count++;
         }
 
diff --git a/gtk/gtkpango.c b/gtk/gtkpango.c
index 58ee7a3bf2..99e82d2dc6 100644
--- a/gtk/gtkpango.c
+++ b/gtk/gtkpango.c
@@ -257,6 +257,10 @@ attribute_from_text (GtkBuilder  *builder,
       if (gtk_builder_value_from_string_type (builder, G_TYPE_INT, value, &val, error))
         attribute = pango_attr_line_height_new_absolute (g_value_get_int (&val) * PANGO_SCALE);
       break;
+    case PANGO_ATTR_LINE_SPACING:
+      if (gtk_builder_value_from_string_type (builder, G_TYPE_INT, value, &val, error))
+        attribute = pango_attr_line_spacing_new (g_value_get_int (&val) * PANGO_SCALE);
+      break;
     case PANGO_ATTR_TEXT_TRANSFORM:
       if (gtk_builder_value_from_string_type (builder, PANGO_TYPE_TEXT_TRANSFORM, value, &val, error))
         attribute = pango_attr_text_transform_new (g_value_get_enum (&val));
@@ -267,6 +271,9 @@ attribute_from_text (GtkBuilder  *builder,
     case PANGO_ATTR_SENTENCE:
       attribute = pango_attr_sentence_new ();
       break;
+    case PANGO_ATTR_PARAGRAPH:
+      attribute = pango_attr_paragraph_new ();
+      break;
     case PANGO_ATTR_BASELINE_SHIFT:
       if (gtk_builder_value_from_string_type (builder, PANGO_TYPE_BASELINE_SHIFT, value, &val, NULL))
         attribute = pango_attr_baseline_shift_new (g_value_get_enum (&val));
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index 6c1ff5c260..123706c697 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -2611,7 +2611,7 @@ draw_page (GtkDrawingArea *da,
             text = g_strdup_printf ("%d", i++);
             pango_layout_set_text (layout, text, -1);
             g_free (text);
-            pango_layout_get_size (layout, &layout_w, &layout_h);
+            pango_lines_get_size (pango_layout_get_lines (layout), &layout_w, &layout_h);
             cairo_save (cr);
             cairo_translate (cr,
                              x * page_width,
@@ -2629,7 +2629,7 @@ draw_page (GtkDrawingArea *da,
             text = g_strdup_printf ("%d", i++);
             pango_layout_set_text (layout, text, -1);
             g_free (text);
-            pango_layout_get_size (layout, &layout_w, &layout_h);
+            pango_lines_get_size (pango_layout_get_lines (layout), &layout_w, &layout_h);
             cairo_save (cr);
             cairo_translate (cr,
                              x * page_width,
@@ -2696,7 +2696,7 @@ draw_page (GtkDrawingArea *da,
 
       pango_layout_set_text (layout, text, -1);
       g_free (text);
-      pango_layout_get_size (layout, &layout_w, &layout_h);
+      pango_lines_get_size (pango_layout_get_lines (layout), &layout_w, &layout_h);
 
       ltr = gtk_widget_get_direction (GTK_WIDGET (dialog)) == GTK_TEXT_DIR_LTR;
 
@@ -2720,7 +2720,7 @@ draw_page (GtkDrawingArea *da,
 
       pango_layout_set_text (layout, text, -1);
       g_free (text);
-      pango_layout_get_size (layout, &layout_w, &layout_h);
+      pango_lines_get_size (pango_layout_get_lines (layout), &layout_w, &layout_h);
 
       cairo_translate (cr, (width - layout_w / PANGO_SCALE) / 2,
                            pos_y + h + 2 * RULER_DISTANCE);
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 4554a4dd1b..1273c6a959 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -1167,7 +1167,7 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot     *snapshot,
         keyboard_direction = gdk_device_get_direction (keyboard);
     }
 
-  pango_layout_get_caret_pos (layout, index, &strong_pos, &weak_pos);
+  pango_lines_get_caret_pos (pango_layout_get_lines (layout), NULL, index, &strong_pos, &weak_pos);
 
   direction2 = PANGO_DIRECTION_NEUTRAL;
 
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index b4767f7c13..635efd879c 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -2313,7 +2313,7 @@ gtk_text_get_selection_bound_location (GtkText *self)
   layout = gtk_text_ensure_layout (self, FALSE);
   text = pango_layout_get_text (layout);
   index = g_utf8_offset_to_pointer (text, priv->selection_bound) - text;
-  pango_layout_index_to_pos (layout, index, &pos);
+  pango_lines_index_to_pos (pango_layout_get_lines (layout), NULL, index, &pos);
 
   if (gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL)
     x = (pos.x + pos.width) / PANGO_SCALE;
@@ -2426,12 +2426,13 @@ gtk_text_measure (GtkWidget      *widget,
       if (priv->propagate_text_width)
         {
           PangoLayout *layout;
-          int act;
+          PangoRectangle ext;
 
           layout = gtk_text_ensure_layout (self, TRUE);
-          pango_layout_get_pixel_size (layout, &act, NULL);
+          pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+          pango_extents_to_pixels (&ext, NULL);
 
-          nat = MIN (act, nat);
+          nat = MIN (ext.width, nat);
         }
 
       nat = MAX (min, nat);
@@ -2453,17 +2454,19 @@ gtk_text_measure (GtkWidget      *widget,
     {
       int height, baseline;
       PangoLayout *layout;
+      PangoRectangle ext;
 
       layout = gtk_text_ensure_layout (self, TRUE);
 
       priv->ascent = pango_font_metrics_get_ascent (metrics);
       priv->descent = pango_font_metrics_get_descent (metrics);
 
-      pango_layout_get_pixel_size (layout, NULL, &height);
+      pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+      pango_extents_to_pixels (&ext, NULL);
 
-      height = MAX (height, PANGO_PIXELS (priv->ascent + priv->descent));
+      height = MAX (ext.height, PANGO_PIXELS (priv->ascent + priv->descent));
 
-      baseline = pango_layout_get_baseline (layout) / PANGO_SCALE;
+      baseline = pango_lines_get_baseline (pango_layout_get_lines (layout)) / PANGO_SCALE;
 
       *minimum = *natural = height;
 
@@ -2604,17 +2607,18 @@ gtk_text_get_pixel_ranges (GtkText  *self,
   if (priv->selection_bound != priv->current_pos)
     {
       PangoLayout *layout = gtk_text_ensure_layout (self, TRUE);
-      PangoLayoutLine *line = pango_layout_get_lines_readonly (layout)->data;
+      PangoLines *lines = pango_layout_get_lines (layout);
+      PangoLayoutLine *line = pango_lines_get_line (lines, 0, NULL, NULL);
       const char *text = pango_layout_get_text (layout);
       int start_index = g_utf8_offset_to_pointer (text, priv->selection_bound) - text;
       int end_index = g_utf8_offset_to_pointer (text, priv->current_pos) - text;
       int real_n_ranges, i;
 
-      pango_layout_line_get_x_ranges (line,
-                                      MIN (start_index, end_index),
-                                      MAX (start_index, end_index),
-                                      ranges,
-                                      &real_n_ranges);
+      pango_lines_get_x_ranges (lines, line,
+                                NULL, MIN (start_index, end_index),
+                                NULL, MAX (start_index, end_index),
+                                ranges,
+                                &real_n_ranges);
 
       if (ranges)
         {
@@ -3502,7 +3506,7 @@ find_invisible_char (GtkWidget *widget)
       len = g_unichar_to_utf8 (invisible_chars[i], text);
       pango_layout_set_text (layout, text, len);
 
-      count = pango_layout_get_unknown_glyphs_count (layout);
+      count = pango_lines_get_unknown_glyphs_count (pango_layout_get_lines (layout));
 
       if (count == 0)
         {
@@ -3778,7 +3782,7 @@ get_better_cursor_x (GtkText *self,
                 "gtk-split-cursor", &split_cursor,
                 NULL);
 
-  pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos);
+  pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, index, &strong_pos, &weak_pos);
 
   if (split_cursor)
     return strong_pos.x / PANGO_SCALE;
@@ -4057,7 +4061,7 @@ gtk_text_backspace (GtkText *self)
       const PangoLogAttr *log_attrs;
       int n_attrs;
 
-      log_attrs = pango_layout_get_log_attrs_readonly (layout, &n_attrs);
+      log_attrs = pango_layout_get_log_attrs (layout, &n_attrs);
 
       /* Deleting parts of characters */
       if (log_attrs[priv->current_pos].backspace_deletes_character)
@@ -4456,7 +4460,7 @@ gtk_text_create_layout (GtkText  *self,
   guint n_bytes;
 
   layout = gtk_widget_create_pango_layout (widget, NULL);
-  pango_layout_set_single_paragraph_mode (layout, TRUE);
+  pango_layout_set_single_paragraph (layout, TRUE);
 
   tmp_attrs = gtk_css_style_get_pango_attributes (gtk_css_node_get_style (gtk_widget_get_css_node (widget)));
   if (!tmp_attrs)
@@ -4572,15 +4576,17 @@ get_layout_position (GtkText *self,
   GtkTextPrivate *priv = gtk_text_get_instance_private (self);
   const int text_height = gtk_widget_get_height (GTK_WIDGET (self));
   PangoLayout *layout;
+  PangoLines *lines;
   PangoRectangle logical_rect;
   int y_pos, area_height;
   PangoLayoutLine *line;
 
   layout = gtk_text_ensure_layout (self, TRUE);
+  lines = pango_layout_get_lines (layout);
 
   area_height = PANGO_SCALE * text_height;
 
-  line = pango_layout_get_lines_readonly (layout)->data;
+  line = pango_lines_get_line (lines, 0, NULL, NULL);
   pango_layout_line_get_extents (line, NULL, &logical_rect);
 
   /* Align primarily for locale's ascent/descent */
@@ -4588,7 +4594,7 @@ get_layout_position (GtkText *self,
     y_pos = ((area_height - priv->ascent - priv->descent) / 2 +
              priv->ascent + logical_rect.y);
   else
-    y_pos = PANGO_SCALE * priv->text_baseline - pango_layout_get_baseline (layout);
+    y_pos = PANGO_SCALE * priv->text_baseline - pango_lines_get_baseline (lines);
 
   /* Now see if we need to adjust to fit in actual drawn string */
   if (logical_rect.height > area_height)
@@ -4860,7 +4866,7 @@ gtk_text_find_position (GtkText *self,
   text = pango_layout_get_text (layout);
   cursor_index = g_utf8_offset_to_pointer (text, priv->current_pos) - text;
 
-  line = pango_layout_get_lines_readonly (layout)->data;
+  line = pango_lines_get_line (pango_layout_get_lines (layout), 0, NULL, NULL);
   pango_layout_line_x_to_index (line, x * PANGO_SCALE, &index, &trailing);
 
   if (index >= cursor_index && priv->preedit_length)
@@ -4906,7 +4912,7 @@ gtk_text_get_cursor_locations (GtkText   *self,
 
       index = g_utf8_offset_to_pointer (text, priv->current_pos + priv->preedit_cursor) - text;
 
-      pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos);
+      pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, index, &strong_pos, &weak_pos);
 
       if (strong_x)
         *strong_x = strong_pos.x / PANGO_SCALE;
@@ -4943,7 +4949,7 @@ gtk_text_get_scroll_limits (GtkText *self,
   int text_width, width;
 
   layout = gtk_text_ensure_layout (self, TRUE);
-  line = pango_layout_get_lines_readonly (layout)->data;
+  line = pango_lines_get_line (pango_layout_get_lines (layout), 0, NULL, NULL);
 
   pango_layout_line_get_extents (line, NULL, &logical_rect);
 
@@ -5088,12 +5094,16 @@ gtk_text_move_visually (GtkText *self,
 
       if (count > 0)
         {
-          pango_layout_move_cursor_visually (layout, strong, index, 0, 1, &new_index, &new_trailing);
+          pango_lines_move_cursor (pango_layout_get_lines (layout), strong,
+                                   NULL, index, 0, 1,
+                                   NULL, &new_index, &new_trailing);
           count--;
         }
       else
         {
-          pango_layout_move_cursor_visually (layout, strong, index, 0, -1, &new_index, &new_trailing);
+          pango_lines_move_cursor (pango_layout_get_lines (layout), strong,
+                                   NULL, index, 0, -1,
+                                   NULL, &new_index, &new_trailing);
           count++;
         }
 
@@ -5130,7 +5140,7 @@ gtk_text_move_logically (GtkText *self,
       const PangoLogAttr *log_attrs;
       int n_attrs;
 
-      log_attrs = pango_layout_get_log_attrs_readonly (layout, &n_attrs);
+      log_attrs = pango_layout_get_log_attrs (layout, &n_attrs);
 
       while (count > 0 && new_pos < length)
         {
@@ -5174,7 +5184,7 @@ gtk_text_move_forward_word (GtkText  *self,
       const PangoLogAttr *log_attrs;
       int n_attrs;
 
-      log_attrs = pango_layout_get_log_attrs_readonly (layout, &n_attrs);
+      log_attrs = pango_layout_get_log_attrs (layout, &n_attrs);
 
       /* Find the next word boundary */
       new_pos++;
@@ -5205,7 +5215,7 @@ gtk_text_move_backward_word (GtkText  *self,
       const PangoLogAttr *log_attrs;
       int n_attrs;
 
-      log_attrs = pango_layout_get_log_attrs_readonly (layout, &n_attrs);
+      log_attrs = pango_layout_get_log_attrs (layout, &n_attrs);
 
       new_pos = start - 1;
 
@@ -5227,7 +5237,7 @@ gtk_text_delete_whitespace (GtkText *self)
   int n_attrs;
   int start, end;
 
-  log_attrs = pango_layout_get_log_attrs_readonly (layout, &n_attrs);
+  log_attrs = pango_layout_get_log_attrs (layout, &n_attrs);
 
   start = end = priv->current_pos;
 
@@ -7167,9 +7177,10 @@ gtk_text_compute_cursor_extents (GtkText         *self,
   position = CLAMP (position, 0, g_utf8_strlen (text, -1));
   index = g_utf8_offset_to_pointer (text, position) - text;
 
-  pango_layout_get_cursor_pos (layout, index,
-                               strong ? &pango_strong_pos : NULL,
-                               weak ? &pango_weak_pos : NULL);
+  pango_lines_get_cursor_pos (pango_layout_get_lines (layout),
+                              NULL, index,
+                              strong ? &pango_strong_pos : NULL,
+                              weak ? &pango_weak_pos : NULL);
   gtk_text_get_layout_offsets (self, &offset_x, &offset_y);
 
   if (strong)
diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c
index c2cd148868..73cc17652a 100644
--- a/gtk/gtktextbuffer.c
+++ b/gtk/gtktextbuffer.c
@@ -4710,6 +4710,10 @@ insert_tags_for_attributes (GtkTextBuffer     *buffer,
           FLOAT_ATTR (line_height);
           break;
 
+        case PANGO_ATTR_LINE_SPACING:
+          INT_ATTR (pixels_inside_wrap);
+          break;
+
         case PANGO_ATTR_ABSOLUTE_LINE_HEIGHT:
           break;
 
@@ -4741,6 +4745,10 @@ insert_tags_for_attributes (GtkTextBuffer     *buffer,
           VOID_ATTR (sentence);
           break;
 
+        case PANGO_ATTR_PARAGRAPH:
+          VOID_ATTR (paragraph);
+          break;
+
         case PANGO_ATTR_BASELINE_SHIFT:
           INT_ATTR (baseline_shift);
           break;
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index ad0570b6b1..6adbe2a2d3 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -1073,7 +1073,9 @@ gtk_text_layout_wrap (GtkTextLayout   *layout,
   line_data->width = display->width;
   line_data->height = display->height;
   line_data->valid = TRUE;
-  pango_layout_get_pixel_extents (display->layout, &ink_rect, &logical_rect);
+  pango_lines_get_extents (pango_layout_get_lines (display->layout), &ink_rect, &logical_rect);
+  pango_extents_to_pixels (&ink_rect, NULL);
+  pango_extents_to_pixels (&logical_rect, NULL);
   line_data->top_ink = MAX (0, logical_rect.x - ink_rect.x);
   line_data->bottom_ink = MAX (0, logical_rect.x + logical_rect.width - ink_rect.x - ink_rect.width);
   gtk_text_line_display_unref (display);
@@ -1245,17 +1247,14 @@ set_para_values (GtkTextLayout      *layout,
   switch (style->justification)
     {
     case GTK_JUSTIFY_LEFT:
-      pango_align = (base_dir == PANGO_DIRECTION_LTR) ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT;
-      break;
     case GTK_JUSTIFY_RIGHT:
-      pango_align = (base_dir == PANGO_DIRECTION_LTR) ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
+      pango_align = PANGO_ALIGN_NATURAL;
       break;
     case GTK_JUSTIFY_CENTER:
       pango_align = PANGO_ALIGN_CENTER;
       break;
     case GTK_JUSTIFY_FILL:
-      pango_align = (base_dir == PANGO_DIRECTION_LTR) ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT;
-      pango_layout_set_justify (display->layout, TRUE);
+      pango_align = GTK_JUSTIFY_FILL;
       break;
     default:
       g_assert_not_reached ();
@@ -1263,8 +1262,7 @@ set_para_values (GtkTextLayout      *layout,
     }
 
   pango_layout_set_alignment (display->layout, pango_align);
-  pango_layout_set_spacing (display->layout,
-                            style->pixels_inside_wrap * PANGO_SCALE);
+  pango_layout_set_spacing (display->layout, style->pixels_inside_wrap * PANGO_SCALE);
 
   if (style->tabs)
     pango_layout_set_tabs (display->layout, style->tabs);
@@ -1904,16 +1902,14 @@ add_cursor (GtkTextLayout      *layout,
 static gboolean
 is_shape (PangoLayoutRun *run)
 {
-  GSList *tmp_list = run->item->analysis.extra_attrs;
+  PangoItem *item = pango_layout_run_get_item (run);
 
-  while (tmp_list)
+  for (GSList *l = item->analysis.extra_attrs; l; l = l->next)
     {
-      PangoAttribute *attr = tmp_list->data;
+      PangoAttribute *attr = l->data;
 
       if (attr->klass->type == PANGO_ATTR_SHAPE)
         return TRUE;
-
-      tmp_list = tmp_list->next;
     }
 
   return FALSE;
@@ -1929,7 +1925,7 @@ allocate_child_widgets (GtkTextLayout      *text_layout,
   run_iter = pango_layout_get_iter (layout);
   do
     {
-      PangoLayoutRun *run = pango_layout_iter_get_run_readonly (run_iter);
+      PangoLayoutRun *run = pango_layout_iter_get_run (run_iter);
 
       if (run && is_shape (run))
         {
@@ -2578,7 +2574,7 @@ gtk_text_layout_create_display (GtkTextLayout *layout,
   g_slist_free (cursor_byte_offsets);
   g_slist_free (cursor_segs);
 
-  pango_layout_get_extents (display->layout, NULL, &extents);
+  pango_lines_get_extents (pango_layout_get_lines (display->layout), NULL, &extents);
 
   text_pixel_width = PIXEL_BOUND (extents.width);
 
@@ -2606,6 +2602,17 @@ gtk_text_layout_create_display (GtkTextLayout *layout,
         case PANGO_ALIGN_RIGHT:
           display->x_offset += excess;
           break;
+        case PANGO_ALIGN_NATURAL:
+          {
+            PangoLayoutLine *first_line;
+
+            first_line = pango_lines_get_line (pango_layout_get_lines (display->layout), 0, NULL, NULL);
+            if (first_line && pango_layout_line_get_resolved_direction (first_line) == PANGO_DIRECTION_RTL)
+              display->x_offset += excess;
+          }
+          break;
+        case PANGO_ALIGN_JUSTIFY:
+          break;
         }
     }
 
@@ -2824,12 +2831,13 @@ gtk_text_layout_get_iter_at_position (GtkTextLayout *layout,
     }
   else
     {
-       /* Ignore the "outside" return value from pango. Pango is doing
+       /* Ignore the return value from pango. Pango is doing
         * the right thing even if we are outside the layout in the
         * x-direction.
         */
-      inside = pango_layout_xy_to_index (display->layout, x * PANGO_SCALE, y * PANGO_SCALE,
-                                         &byte_index, trailing);
+      pango_lines_pos_to_index (pango_layout_get_lines (display->layout),
+                                x * PANGO_SCALE, y * PANGO_SCALE,
+                                &byte_index, trailing);
     }
 
   line_display_index_to_iter (layout, display, target_iter, byte_index, 0);
@@ -2887,9 +2895,9 @@ gtk_text_layout_get_cursor_locations (GtkTextLayout  *layout,
   if (gtk_text_iter_equal (iter, &insert_iter))
     index += layout->preedit_cursor - layout->preedit_len;
 
-  pango_layout_get_cursor_pos (display->layout, index,
-                              strong_pos ? &pango_strong_pos : NULL,
-                              weak_pos ? &pango_weak_pos : NULL);
+  pango_lines_get_cursor_pos (pango_layout_get_lines (display->layout), NULL, index,
+                              strong_pos ? &pango_strong_pos : NULL,
+                              weak_pos ? &pango_weak_pos : NULL);
 
   if (strong_pos)
     {
@@ -3034,7 +3042,7 @@ gtk_text_layout_get_iter_location (GtkTextLayout     *layout,
 
   byte_index = gtk_text_iter_get_line_index (iter);
 
-  pango_layout_index_to_pos (display->layout, byte_index, &pango_rect);
+  pango_lines_index_to_pos (pango_layout_get_lines (display->layout), NULL, byte_index, &pango_rect);
 
   rect->x = PANGO_PIXELS (x_offset + pango_rect.x);
   rect->y += PANGO_PIXELS (pango_rect.y) + display->top_margin;
@@ -3082,8 +3090,9 @@ find_display_line_below (GtkTextLayout *layout,
 
       do
         {
-          int first_y, last_y;
-          PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter);
+          PangoRectangle ext;
+
+          PangoLayoutLine *layout_line = pango_layout_iter_get_line (layout_iter);
 
           found_byte = pango_layout_line_get_start_index (layout_line);
 
@@ -3093,8 +3102,9 @@ find_display_line_below (GtkTextLayout *layout,
               break;
             }
 
-          pango_layout_iter_get_line_yrange (layout_iter, &first_y, &last_y);
-          line_top += (last_y - first_y) / PANGO_SCALE;
+          pango_layout_iter_get_line_extents (layout_iter, NULL, &ext);
+          pango_extents_to_pixels (&ext, NULL);
+          line_top += ext.height;
         }
       while (pango_layout_iter_next_line (layout_iter));
 
@@ -3154,19 +3164,21 @@ find_display_line_above (GtkTextLayout *layout,
 
       do
         {
-          int first_y, last_y;
-          PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter);
+          PangoRectangle ext;
+
+          PangoLayoutLine *layout_line = pango_layout_iter_get_line (layout_iter);
 
           found_byte = pango_layout_line_get_start_index (layout_line);
 
-          pango_layout_iter_get_line_yrange (layout_iter, &first_y, &last_y);
+          pango_layout_iter_get_line_extents (layout_iter, NULL, &ext);
+          pango_extents_to_pixels (&ext, NULL);
 
-          tmp_top -= (last_y - first_y) / PANGO_SCALE;
+          tmp_top -= ext.height;
 
           if (tmp_top < y)
             {
               found_line = line;
-             pango_layout_iter_free (layout_iter);
+              pango_layout_iter_free (layout_iter);
               goto done;
             }
         }
@@ -3248,10 +3260,10 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
   GtkTextLine *line;
   GtkTextLineDisplay *display;
   int line_byte;
-  GSList *tmp_list;
   PangoLayoutLine *layout_line;
   GtkTextIter orig;
   gboolean update_byte = FALSE;
+  int line_no;
 
   g_return_val_if_fail (GTK_IS_TEXT_LAYOUT (layout), FALSE);
   g_return_val_if_fail (iter != NULL, FALSE);
@@ -3285,15 +3297,15 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
       update_byte = TRUE;
     }
 
-  tmp_list = pango_layout_get_lines_readonly (display->layout);
-  layout_line = tmp_list->data;
+  line_no = 0;
+  layout_line = pango_lines_get_line (pango_layout_get_lines (display->layout), line_no, NULL, NULL);
 
   if (update_byte)
     {
       line_byte = pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length 
(layout_line);
     }
 
-  if (line_byte < pango_layout_line_get_length (layout_line) || !tmp_list->next) /* first line of paragraph 
*/
+  if (line_byte < pango_layout_line_get_length (layout_line) || line_no + 1 == pango_lines_get_line_count 
(pango_layout_get_lines (display->layout))) /* first line of paragraph */
     {
       GtkTextLine *prev_line;
 
@@ -3311,8 +3323,8 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
 
           if (display->height > 0)
             {
-              tmp_list = g_slist_last (pango_layout_get_lines_readonly (display->layout));
-              layout_line = tmp_list->data;
+              PangoLines *lines = pango_layout_get_lines (display->layout);
+              layout_line = pango_lines_get_line (lines, pango_lines_get_line_count (lines) - 1, NULL, NULL);
 
               line_display_index_to_iter (layout, display, iter,
                                           pango_layout_line_get_start_index (layout_line) + 
pango_layout_line_get_length (layout_line), 0);
@@ -3326,20 +3338,20 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
     {
       int prev_offset = pango_layout_line_get_start_index (layout_line);
 
-      tmp_list = tmp_list->next;
-      while (tmp_list)
+      line_no++;
+      while (line_no < pango_lines_get_line_count (pango_layout_get_lines (display->layout)))
         {
-          layout_line = tmp_list->data;
+          layout_line = pango_lines_get_line (pango_layout_get_lines (display->layout), line_no, NULL, NULL);
 
           if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length 
(layout_line) ||
-              !tmp_list->next)
+              line_no + 1 == pango_lines_get_line_count (pango_layout_get_lines (display->layout)))
             {
              line_display_index_to_iter (layout, display, iter, prev_offset, 0);
               break;
             }
 
           prev_offset = pango_layout_line_get_start_index (layout_line);
-          tmp_list = tmp_list->next;
+          line_no++;
         }
     }
 
@@ -3372,6 +3384,8 @@ gtk_text_layout_move_iter_to_next_line (GtkTextLayout *layout,
   gboolean found = FALSE;
   gboolean found_after = FALSE;
   gboolean first = TRUE;
+  PangoLines *lines;
+  int line_no;
 
   g_return_val_if_fail (GTK_IS_TEXT_LAYOUT (layout), FALSE);
   g_return_val_if_fail (iter != NULL, FALSE);
@@ -3382,8 +3396,6 @@ gtk_text_layout_move_iter_to_next_line (GtkTextLayout *layout,
 
   while (line && !found_after)
     {
-      GSList *tmp_list;
-
       display = gtk_text_layout_get_line_display (layout, line, FALSE);
 
       if (display->height == 0)
@@ -3397,10 +3409,11 @@ gtk_text_layout_move_iter_to_next_line (GtkTextLayout *layout,
       else
        line_byte = 0;
 
-      tmp_list = pango_layout_get_lines_readonly (display->layout);
-      while (tmp_list && !found_after)
+      lines = pango_layout_get_lines (display->layout);
+      line_no = 0;
+      while (line_no < pango_lines_get_line_count (lines) && !found_after)
         {
-          PangoLayoutLine *layout_line = tmp_list->data;
+          PangoLayoutLine *layout_line = pango_lines_get_line (lines, line_no, NULL, NULL);
 
           if (found)
             {
@@ -3408,10 +3421,10 @@ gtk_text_layout_move_iter_to_next_line (GtkTextLayout *layout,
                                           pango_layout_line_get_start_index (layout_line), 0);
               found_after = TRUE;
             }
-          else if (line_byte < pango_layout_line_get_start_index (layout_line) + 
pango_layout_line_get_length (layout_line) || !tmp_list->next)
+          else if (line_byte < pango_layout_line_get_start_index (layout_line) + 
pango_layout_line_get_length (layout_line) || line_no + 1 == pango_lines_get_line_count (lines))
             found = TRUE;
 
-          tmp_list = tmp_list->next;
+          line_no++;
         }
 
     next:
@@ -3445,8 +3458,9 @@ gtk_text_layout_move_iter_to_line_end (GtkTextLayout *layout,
   GtkTextLine *line;
   GtkTextLineDisplay *display;
   int line_byte;
-  GSList *tmp_list;
   GtkTextIter orig;
+  PangoLines *lines;
+  int line_no;
 
   g_return_val_if_fail (GTK_IS_TEXT_LAYOUT (layout), FALSE);
   g_return_val_if_fail (iter != NULL, FALSE);
@@ -3457,12 +3471,14 @@ gtk_text_layout_move_iter_to_line_end (GtkTextLayout *layout,
   display = gtk_text_layout_get_line_display (layout, line, FALSE);
   line_byte = line_display_iter_to_index (layout, display, iter);
 
-  tmp_list = pango_layout_get_lines_readonly (display->layout);
-  while (tmp_list)
+  lines = pango_layout_get_lines (display->layout);
+  line_no = 0;
+
+  while (line_no < pango_lines_get_line_count (lines))
     {
-      PangoLayoutLine *layout_line = tmp_list->data;
+      PangoLayoutLine *layout_line = pango_lines_get_line (lines, line_no, NULL, NULL);
 
-      if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length 
(layout_line) || !tmp_list->next)
+      if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length 
(layout_line) || line_no + 1 == pango_lines_get_line_count (lines))
         {
          line_display_index_to_iter (layout, display, iter,
                                      direction < 0 ? pango_layout_line_get_start_index (layout_line) : 
pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line),
@@ -3479,7 +3495,7 @@ gtk_text_layout_move_iter_to_line_end (GtkTextLayout *layout,
           break;
         }
 
-      tmp_list = tmp_list->next;
+      line_no++;
     }
 
   gtk_text_line_display_unref (display);
@@ -3504,7 +3520,8 @@ gtk_text_layout_iter_starts_line (GtkTextLayout       *layout,
   GtkTextLine *line;
   GtkTextLineDisplay *display;
   int line_byte;
-  GSList *tmp_list;
+  PangoLines *lines;
+  int line_no;
 
   g_return_val_if_fail (GTK_IS_TEXT_LAYOUT (layout), FALSE);
   g_return_val_if_fail (iter != NULL, FALSE);
@@ -3513,13 +3530,14 @@ gtk_text_layout_iter_starts_line (GtkTextLayout       *layout,
   display = gtk_text_layout_get_line_display (layout, line, FALSE);
   line_byte = line_display_iter_to_index (layout, display, iter);
 
-  tmp_list = pango_layout_get_lines_readonly (display->layout);
-  while (tmp_list)
+  lines = pango_layout_get_lines (display->layout);
+  line_no = 0;
+  while (line_no < pango_lines_get_line_count (lines))
     {
-      PangoLayoutLine *layout_line = tmp_list->data;
+      PangoLayoutLine *layout_line = pango_lines_get_line (lines, line_no, NULL, NULL);
 
       if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length 
(layout_line) ||
-          !tmp_list->next)
+          line_no + 1 == pango_lines_get_line_count (lines))
         {
           /* We're located on this line or the para delimiters before
            * it
@@ -3532,7 +3550,7 @@ gtk_text_layout_iter_starts_line (GtkTextLayout       *layout,
             return FALSE;
         }
 
-      tmp_list = tmp_list->next;
+      line_no++;
     }
 
   g_assert_not_reached ();
@@ -3581,7 +3599,7 @@ gtk_text_layout_move_iter_to_x (GtkTextLayout *layout,
 
   do
     {
-      PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter);
+      PangoLayoutLine *layout_line = pango_layout_iter_get_line (layout_iter);
 
       if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length 
(layout_line) ||
           pango_layout_iter_at_last_line (layout_iter))
@@ -3665,12 +3683,16 @@ gtk_text_layout_move_iter_visually (GtkTextLayout *layout,
 
       if (count > 0)
         {
-          pango_layout_move_cursor_visually (display->layout, strong, line_byte, 0, 1, &new_index, 
&new_trailing);
+          pango_lines_move_cursor (pango_layout_get_lines (display->layout), strong,
+                                   NULL, line_byte, 0, 1,
+                                   NULL, &new_index, &new_trailing);
           count--;
         }
       else
         {
-          pango_layout_move_cursor_visually (display->layout, strong, line_byte, 0, -1, &new_index, 
&new_trailing);
+          pango_lines_move_cursor (pango_layout_get_lines (display->layout), strong,
+                                   NULL, line_byte, 0, -1,
+                                   NULL, &new_index, &new_trailing);
           count++;
         }
 
@@ -3870,16 +3892,19 @@ render_para (GskPangoRenderer   *crenderer,
 
   do
     {
-      PangoLayoutLine *line = pango_layout_iter_get_line_readonly (iter);
+      PangoLayoutLine *line = pango_layout_iter_get_line (iter);
       int selection_y, selection_height;
+      PangoRectangle ext;
       int first_y, last_y;
       PangoRectangle line_rect;
       int baseline;
       gboolean at_last_line;
 
       pango_layout_iter_get_line_extents (iter, NULL, &line_rect);
-      baseline = pango_layout_iter_get_baseline (iter);
-      pango_layout_iter_get_line_yrange (iter, &first_y, &last_y);
+      baseline = pango_layout_iter_get_line_baseline (iter);
+      pango_layout_iter_get_line_extents (iter, NULL, &ext);
+      first_y = ext.y;
+      last_y = ext.y + ext.height;
 
       /* Adjust for margins */
 
@@ -3954,7 +3979,7 @@ render_para (GskPangoRenderer   *crenderer,
               int *ranges = NULL;
               int n_ranges, i;
 
-              pango_layout_line_get_x_ranges (line, selection_start_index, selection_end_index, &ranges, 
&n_ranges);
+              pango_lines_get_x_ranges (pango_layout_iter_get_lines (iter), line, NULL, 
selection_start_index, NULL, selection_end_index, &ranges, &n_ranges);
 
               gsk_pango_renderer_set_state (crenderer, GSK_PANGO_RENDERER_SELECTED);
 
diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c
index 75f081732a..c86ad7c327 100644
--- a/gtk/gtktextutil.c
+++ b/gtk/gtktextutil.c
@@ -42,18 +42,21 @@
 #define ELLIPSIS_CHARACTER "\xe2\x80\xa6"
 
 static void
-append_n_lines (GString *str, const char *text, GSList *lines, int n_lines)
+append_n_lines (GString    *str,
+                const char *text,
+                PangoLines *lines,
+                int         first,
+                int         n_lines)
 {
   PangoLayoutLine *line;
   int i;
 
-  for (i = 0; i < n_lines; i++)
+  for (i = first; i < first + n_lines; i++)
     {
-      line = lines->data;
+      line = pango_lines_get_line (lines, i, NULL, NULL);
       g_string_append_len (str,
                            &text[pango_layout_line_get_start_index (line)],
                            pango_layout_line_get_length (line));
-      lines = lines->next;
     }
 }
 
@@ -61,29 +64,25 @@ static void
 limit_layout_lines (PangoLayout *layout)
 {
   const char *text;
-  GString     *str;
-  GSList      *lines, *elem;
-  int          n_lines;
+  GString *str;
+  PangoLines *lines;
+  int n_lines;
 
-  n_lines = pango_layout_get_line_count (layout);
+  lines = pango_layout_get_lines (layout);
+  n_lines = pango_lines_get_line_count (pango_layout_get_lines (layout));
 
   if (n_lines >= DRAG_ICON_MAX_LINES)
     {
-      text  = pango_layout_get_text (layout);
-      str   = g_string_new (NULL);
-      lines = pango_layout_get_lines_readonly (layout);
+      text = pango_layout_get_text (layout);
+      str = g_string_new (NULL);
 
       /* get first lines */
-      elem = lines;
-      append_n_lines (str, text, elem,
-                      DRAG_ICON_MAX_LINES / 2);
+      append_n_lines (str, text, lines, 0, DRAG_ICON_MAX_LINES / 2);
 
       g_string_append (str, "\n" ELLIPSIS_CHARACTER "\n");
 
       /* get last lines */
-      elem = g_slist_nth (lines, n_lines - DRAG_ICON_MAX_LINES / 2);
-      append_n_lines (str, text, elem,
-                      DRAG_ICON_MAX_LINES / 2);
+      append_n_lines (str, text, lines , n_lines - DRAG_ICON_MAX_LINES / 2, DRAG_ICON_MAX_LINES / 2);
 
       pango_layout_set_text (layout, str->str, -1);
       g_string_free (str, TRUE);
@@ -123,7 +122,7 @@ gtk_text_util_create_drag_icon (GtkWidget *widget,
 
   pango_layout_set_text (layout, text, len);
   pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
-  pango_layout_get_size (layout, &layout_width, NULL);
+  pango_lines_get_size (pango_layout_get_lines (layout), &layout_width, NULL);
 
   layout_width = MIN (layout_width, DRAG_ICON_MAX_WIDTH * PANGO_SCALE);
   pango_layout_set_width (layout, layout_width);
@@ -146,7 +145,7 @@ gtk_text_util_create_drag_icon (GtkWidget *widget,
         bg_widget = gtk_widget_get_parent (widget);
       else
         bg_widget = widget;
-      pango_layout_get_size (layout, &layout_width, &layout_height);
+      pango_lines_get_size (pango_layout_get_lines (layout), &layout_width, &layout_height);
       gtk_snapshot_render_background (snapshot,
                                       gtk_widget_get_style_context (bg_widget),
                                       0, 0, layout_width / PANGO_SCALE,
@@ -336,7 +335,7 @@ _gtk_text_util_get_block_cursor_location (PangoLayout    *layout,
   g_return_val_if_fail (index >= 0, FALSE);
   g_return_val_if_fail (pos != NULL, FALSE);
 
-  pango_layout_index_to_pos (layout, index, pos);
+  pango_lines_index_to_pos (pango_layout_get_lines (layout), NULL, index, pos);
 
   if (pos->width != 0)
     {
@@ -351,8 +350,8 @@ _gtk_text_util_get_block_cursor_location (PangoLayout    *layout,
       return TRUE;
     }
 
-  pango_layout_index_to_line_x (layout, index, FALSE, &line_no, NULL);
-  layout_line = pango_layout_get_line_readonly (layout, line_no);
+  layout_line = NULL;
+  pango_lines_index_to_line (pango_layout_get_lines (layout), index, &layout_line, &line_no, NULL, NULL);
   g_return_val_if_fail (layout_line != NULL, FALSE);
 
   text = pango_layout_get_text (layout);
@@ -375,7 +374,7 @@ _gtk_text_util_get_block_cursor_location (PangoLayout    *layout,
    * be on the left or on the right depending on text direction, or it
    * even could be in the middle of visual layout in bidi text. */
 
-  pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos);
+  pango_lines_get_cursor_pos (pango_layout_get_lines (layout), NULL, index, &strong_pos, &weak_pos);
 
   if (strong_pos.x != weak_pos.x)
     {
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 5f8bb14ffb..e831fdfbc4 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -4566,6 +4566,7 @@ gtk_text_view_size_allocate (GtkWidget *widget,
 {
   GtkTextView *text_view;
   GtkTextViewPrivate *priv;
+  PangoRectangle ext;
   int width, height;
   GdkRectangle text_rect;
   GdkRectangle left_rect;
@@ -4661,10 +4662,11 @@ gtk_text_view_size_allocate (GtkWidget *widget,
 
   /* Optimize display cache size */
   layout = gtk_widget_create_pango_layout (widget, "X");
-  pango_layout_get_pixel_size (layout, &width, &height);
-  if (height > 0)
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+  pango_extents_to_pixels (&ext, NULL);
+  if (ext.height > 0)
     {
-      mru_size = SCREEN_HEIGHT (widget) / height * 3;
+      mru_size = SCREEN_HEIGHT (widget) / ext.height * 3;
       gtk_text_layout_set_mru_size (priv->layout, mru_size);
     }
   g_object_unref (layout);
diff --git a/gtk/inspector/fpsoverlay.c b/gtk/inspector/fpsoverlay.c
index 1329738a0d..859ebdf5b9 100644
--- a/gtk/inspector/fpsoverlay.c
+++ b/gtk/inspector/fpsoverlay.c
@@ -97,8 +97,8 @@ gtk_fps_overlay_snapshot (GtkInspectorOverlay *overlay,
   char *fps_string;
   graphene_rect_t bounds;
   gboolean has_bounds;
-  int width, height;
   double overlay_opacity;
+  PangoRectangle ext;
 
   now = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
   info = g_hash_table_lookup (self->infos, widget);
@@ -157,16 +157,17 @@ gtk_fps_overlay_snapshot (GtkInspectorOverlay *overlay,
   pango_attr_list_insert (attrs, pango_attr_font_features_new ("tnum=1"));
   pango_layout_set_attributes (layout, attrs);
   pango_attr_list_unref (attrs);
-  pango_layout_get_pixel_size (layout, &width, &height);
+  pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+  pango_extents_to_pixels (&ext, NULL);
 
   gtk_snapshot_save (snapshot);
   if (has_bounds)
-    gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (bounds.origin.x + bounds.size.width - width, 
bounds.origin.y));
+    gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (bounds.origin.x + bounds.size.width - ext.width, 
bounds.origin.y));
   if (overlay_opacity < 1.0)
     gtk_snapshot_push_opacity (snapshot, overlay_opacity);
   gtk_snapshot_append_color (snapshot,
                              &(GdkRGBA) { 0, 0, 0, 0.5 },
-                             &GRAPHENE_RECT_INIT (-1, -1, width + 2, height + 2));
+                             &GRAPHENE_RECT_INIT (-1, -1, ext.width + 2, ext.height + 2));
   gtk_snapshot_append_layout (snapshot,
                               layout,
                               &(GdkRGBA) { 1, 1, 1, 1 });
diff --git a/tests/rendernode-create-tests.c b/tests/rendernode-create-tests.c
index 2bd7a3876b..8b58fe9376 100644
--- a/tests/rendernode-create-tests.c
+++ b/tests/rendernode-create-tests.c
@@ -399,7 +399,8 @@ text (guint n)
       PangoLayoutIter *iter;
       PangoLayoutRun *run;
       GdkRGBA color;
-      int x, y, width, height;
+      PangoRectangle ext;
+      int x, y;
 
       pango_layout_set_text (layout, words[g_random_int_range (0, n_words)], -1);
       if (g_random_boolean ())
@@ -413,9 +414,11 @@ text (guint n)
       font = pango_context_load_font (context, desc);
       pango_layout_set_font_description (layout, desc);
 
-      pango_layout_get_pixel_size (layout, &width, &height);
-      x = width >= 1000 ? 0 : g_random_int_range (0, 1000 - width);
-      y = height >= 1000 ? 0 : g_random_int_range (0, 1000 - height);
+      pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);
+      pango_extents_to_pixels (&ext, NULL);
+
+      x = ext.width >= 1000 ? 0 : g_random_int_range (0, 1000 - ext.width);
+      y = ext.height >= 1000 ? 0 : g_random_int_range (0, 1000 - ext.height);
       hsv_to_rgb (&color, g_random_double (), g_random_double_range (0.5, 1.0), g_random_double_range (0.15, 
0.75));
 
       iter = pango_layout_get_iter (layout);
@@ -424,9 +427,11 @@ text (guint n)
           run = pango_layout_iter_get_run (iter);
           if (run != NULL)
             {
+              PangoGlyphString *glyphs;
               GskRenderNode *node;
-              
-              node = gsk_text_node_new (font, run->glyphs, &color, &GRAPHENE_POINT_INIT (x, y));
+
+              glyphs = pango_layout_run_get_glyphs (run);
+              node = gsk_text_node_new (font, glyphs, &color, &GRAPHENE_POINT_INIT (x, y));
               if (node)
                 g_ptr_array_add (nodes, node);
             }
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 1b8cbf4cbe..bc5b2f63ea 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -19,7 +19,7 @@
  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  */
 
 
@@ -103,12 +103,12 @@ build_option_menu (const char           *items[],
   omenu = gtk_combo_box_text_new ();
   g_signal_connect (omenu, "changed",
                    G_CALLBACK (func), data);
-      
+
   for (i = 0; i < num_items; i++)
       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (omenu), items[i]);
 
   gtk_combo_box_set_active (GTK_COMBO_BOX (omenu), history);
-  
+
   return omenu;
 }
 
@@ -198,7 +198,7 @@ create_alpha_window (GtkWidget *widget)
       GtkWidget *label;
       GdkDisplay *display;
       GtkCssProvider *provider;
-      
+
       window = gtk_dialog_new_with_buttons ("Alpha Window",
                                            GTK_WINDOW (gtk_widget_get_root (widget)), 0,
                                            "_Close", 0,
@@ -401,16 +401,16 @@ create_widget_grid (gboolean group)
   GtkWidget *grid;
   GtkWidget *group_widget = NULL;
   int i, j;
-  
+
   grid = gtk_grid_new ();
-  
+
   for (i = 0; i < 5; i++)
     {
       for (j = 0; j < 5; j++)
        {
          GtkWidget *widget;
          char *tmp;
-         
+
          if (i == 0 && j == 0)
            {
              widget = NULL;
@@ -438,7 +438,7 @@ create_widget_grid (gboolean group)
                     gtk_check_button_set_group (GTK_CHECK_BUTTON (widget), GTK_CHECK_BUTTON (group_widget));
                }
            }
-         
+
          if (widget)
            gtk_grid_attach (GTK_GRID (grid), widget, i, j, 1, 1);
        }
@@ -460,7 +460,7 @@ create_check_buttons (GtkWidget *widget)
   GtkWidget *button;
   GtkWidget *separator;
   GtkWidget *table;
-  
+
   if (!window)
     {
       window = gtk_dialog_new_with_buttons ("Check Buttons",
@@ -469,7 +469,7 @@ create_check_buttons (GtkWidget *widget)
                                             GTK_RESPONSE_NONE,
                                             NULL);
 
-      gtk_window_set_display (GTK_WINDOW (window), 
+      gtk_window_set_display (GTK_WINDOW (window),
                               gtk_widget_get_display (widget));
       g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
       g_signal_connect (window, "response",
@@ -612,7 +612,7 @@ new_pixbuf (const char *filename,
 
   if (pixbuf == NULL)
     pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) openfile);
-  
+
   widget = gtk_image_new_from_pixbuf (pixbuf);
 
   g_object_unref (pixbuf);
@@ -680,12 +680,12 @@ statusbar_contexts (GtkStatusbar *statusbar)
   g_print ("GtkStatusBar: context=\"%s\", context_id=%d\n",
           string,
           gtk_statusbar_get_context_id (statusbar, string));
-  
+
   string = "idle messages";
   g_print ("GtkStatusBar: context=\"%s\", context_id=%d\n",
           string,
           gtk_statusbar_get_context_id (statusbar, string));
-  
+
   string = "some text";
   g_print ("GtkStatusBar: context=\"%s\", context_id=%d\n",
           string,
@@ -790,7 +790,7 @@ create_statusbar (GtkWidget *widget)
     gtk_window_destroy (GTK_WINDOW (window));
 }
 
-/* 
+/*
  * Label Demo
  */
 static void
@@ -806,11 +806,11 @@ create_sensitivity_control (GtkWidget *widget)
 {
   GtkWidget *button;
 
-  button = gtk_toggle_button_new_with_label ("Sensitive");  
+  button = gtk_toggle_button_new_with_label ("Sensitive");
 
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
                                 gtk_widget_is_sensitive (widget));
-  
+
   g_signal_connect (button,
                     "toggled",
                     G_CALLBACK (sensitivity_toggled),
@@ -849,11 +849,11 @@ create_selectable_control (GtkWidget *widget)
 {
   GtkWidget *button;
 
-  button = gtk_toggle_button_new_with_label ("Selectable");  
+  button = gtk_toggle_button_new_with_label ("Selectable");
 
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
                                 FALSE);
-  
+
   g_signal_connect (button,
                     "toggled",
                     G_CALLBACK (selectable_toggled),
@@ -1109,7 +1109,7 @@ on_rotated_text_draw (GtkDrawingArea *drawing_area,
   desc = pango_font_description_from_string ("Sans Bold 30");
   pango_layout_set_font_description (layout, desc);
   pango_font_description_free (desc);
-    
+
   n_words = G_N_ELEMENTS (words);
   for (i = 0; i < n_words; i++)
     {
@@ -1121,14 +1121,14 @@ on_rotated_text_draw (GtkDrawingArea *drawing_area,
       pango_cairo_update_layout (cr, layout);
 
       pango_layout_set_text (layout, words[i], -1);
-      pango_layout_get_size (layout, &layout_width, &layout_height);
+      pango_lines_get_size (pango_layout_get_lines (layout), &layout_width, &layout_height);
 
       cairo_move_to (cr, - layout_width / 2 / PANGO_SCALE, - DEFAULT_TEXT_RADIUS);
       pango_cairo_show_layout (cr, layout);
 
       cairo_restore (cr);
     }
-  
+
   g_object_unref (layout);
 }
 
@@ -1379,9 +1379,9 @@ create_image (GtkWidget *widget)
     {
       GtkWidget *vbox;
       GdkPixbuf *pixbuf;
-        
+
       window = gtk_window_new ();
-      
+
       gtk_window_set_display (GTK_WINDOW (window),
                              gtk_widget_get_display (widget));
 
@@ -1399,7 +1399,7 @@ create_image (GtkWidget *widget)
       pack_image (vbox, "Stock Warning Dialog", gtk_image_new_from_icon_name ("dialog-warning"));
 
       pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) openfile);
-      
+
       pack_image (vbox, "Pixbuf",
                   gtk_image_new_from_pixbuf (pixbuf));
 
@@ -1601,9 +1601,9 @@ cmw_color (GtkWidget *widget, GtkWidget *parent)
                      G_CALLBACK (cmw_destroy_cb), NULL);
     g_signal_connect (csd, "response",
                       G_CALLBACK (gtk_window_destroy), NULL);
-    
+
     /* wait until destroy calls gtk_main_quit */
-    gtk_widget_show (csd);    
+    gtk_widget_show (csd);
     while (!done)
       g_main_context_iteration (NULL, TRUE);
 }
@@ -1717,7 +1717,7 @@ make_message_dialog (GdkDisplay     *display,
                            "response",
                            G_CALLBACK (gtk_window_destroy),
                            *dialog);
-  
+
   g_object_add_weak_pointer (G_OBJECT (*dialog), (gpointer)dialog);
 
   gtk_dialog_set_default_response (GTK_DIALOG (*dialog), default_response);
@@ -1805,9 +1805,9 @@ scrolled_windows_remove (GtkWidget *dialog, int response, GtkWidget *scrollwin)
       sw_float_parent = gtk_window_new ();
       gtk_window_set_display (GTK_WINDOW (sw_float_parent),
                              gtk_widget_get_display (dialog));
-      
+
       gtk_window_set_default_size (GTK_WINDOW (sw_float_parent), 200, 200);
-      
+
       g_object_ref (scrollwin);
       gtk_box_remove (GTK_BOX (gtk_widget_get_parent (scrollwin)), scrollwin);
       gtk_window_set_child (GTK_WINDOW (sw_float_parent), scrollwin);
@@ -2192,7 +2192,7 @@ create_size_group_window (GdkDisplay   *display,
   gtk_widget_set_halign (main_button, GTK_ALIGN_CENTER);
   gtk_widget_set_valign (main_button, GTK_ALIGN_CENTER);
   gtk_grid_attach (GTK_GRID (grid), main_button, 0, 0, 1, 1);
-  
+
   gtk_size_group_add_widget (master_size_group, main_button);
   gtk_size_group_add_widget (hgroup1, main_button);
   gtk_size_group_add_widget (vgroup1, main_button);
@@ -3017,7 +3017,7 @@ create_color_selection (GtkWidget *widget)
       gtk_widget_set_margin_start (hbox, 5);
       gtk_widget_set_margin_end (hbox, 5);
       gtk_window_set_child (GTK_WINDOW (window), hbox);
-      
+
       label = gtk_label_new ("Pick a color");
       gtk_box_append (GTK_BOX (hbox), label);
 
@@ -3173,7 +3173,7 @@ create_font_selection (GtkWidget *widget)
       GtkWidget *picker;
       GtkWidget *hbox;
       GtkWidget *label;
-      
+
       window = gtk_window_new ();
       gtk_window_set_display (GTK_WINDOW (window),
                               gtk_widget_get_display (widget));
@@ -3187,7 +3187,7 @@ create_font_selection (GtkWidget *widget)
       gtk_widget_set_margin_start (hbox, 8);
       gtk_widget_set_margin_end (hbox, 8);
       gtk_window_set_child (GTK_WINDOW (window), hbox);
-      
+
       label = gtk_label_new ("Pick a font");
       gtk_box_append (GTK_BOX (hbox), label);
 
@@ -3195,7 +3195,7 @@ create_font_selection (GtkWidget *widget)
       gtk_font_button_set_use_font (GTK_FONT_BUTTON (picker), TRUE);
       gtk_box_append (GTK_BOX (hbox), picker);
     }
-  
+
   if (!gtk_widget_get_visible (window))
     gtk_widget_show (window);
   else
@@ -3253,7 +3253,7 @@ create_dialog (GtkWidget *widget)
        * dialogs than this. Don't use testgtk for example code,
        * use gtk-demo ;-)
        */
-      
+
       dialog_window = gtk_dialog_new ();
       gtk_window_set_display (GTK_WINDOW (dialog_window),
                               gtk_widget_get_display (widget));
@@ -3268,7 +3268,7 @@ create_dialog (GtkWidget *widget)
       gtk_dialog_add_button (GTK_DIALOG (dialog_window),
                              "Toggle",
                              GTK_RESPONSE_APPLY);
-      
+
       g_signal_connect (dialog_window, "response",
                        G_CALLBACK (dialog_response_cb),
                        NULL);
@@ -3280,7 +3280,7 @@ create_dialog (GtkWidget *widget)
     gtk_window_destroy (GTK_WINDOW (dialog_window));
 }
 
-/* Display & Screen test 
+/* Display & Screen test
  */
 
 typedef struct
@@ -3299,10 +3299,10 @@ screen_display_check (GtkWidget *widget, ScreenDisplaySelection *data)
   GtkWidget *dialog;
   GdkDisplay *new_display = NULL;
   GdkDisplay *current_display = gtk_widget_get_display (widget);
-  
+
   display_name = gtk_editable_get_text (GTK_EDITABLE (data->entry));
   display = gdk_display_open (display_name);
-      
+
   if (!display)
     {
       dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (widget)),
@@ -3361,15 +3361,15 @@ create_display_screen (GtkWidget *widget)
                         "display", display,
                         "title", "Screen or Display selection",
                          NULL);
-  g_signal_connect (window, "destroy", 
+  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_window_destroy), NULL);
 
   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
   gtk_window_set_child (GTK_WINDOW (window), vbox);
-  
+
   frame = gtk_frame_new ("Select display");
   gtk_box_append (GTK_BOX (vbox), frame);
-  
+
   grid = gtk_grid_new ();
   gtk_grid_set_row_spacing (GTK_GRID (grid), 3);
   gtk_grid_set_column_spacing (GTK_GRID (grid), 3);
@@ -3402,9 +3402,9 @@ create_display_screen (GtkWidget *widget)
   scr_dpy_data->toplevel = GTK_WIDGET (gtk_widget_get_root (widget));
   scr_dpy_data->dialog_window = window;
 
-  g_signal_connect (cancelb, "clicked", 
+  g_signal_connect (cancelb, "clicked",
                    G_CALLBACK (screen_display_destroy_diag), window);
-  g_signal_connect (applyb, "clicked", 
+  g_signal_connect (applyb, "clicked",
                    G_CALLBACK (screen_display_check), scr_dpy_data);
   gtk_widget_show (window);
 }
@@ -3584,7 +3584,7 @@ set_page_image (GtkNotebook *notebook, int page_num, GdkPixbuf *pixbuf)
 
   pixwid = g_object_get_data (G_OBJECT (page_widget), "tab_pixmap");
   gtk_image_set_from_pixbuf (GTK_IMAGE (pixwid), pixbuf);
-  
+
   pixwid = g_object_get_data (G_OBJECT (page_widget), "menu_pixmap");
   gtk_image_set_from_pixbuf (GTK_IMAGE (pixwid), pixbuf);
 }
@@ -3594,7 +3594,7 @@ page_switch (GtkWidget *widget, gpointer *page, int page_num)
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   int old_page_num = gtk_notebook_get_current_page (notebook);
- 
+
   if (page_num == old_page_num)
     return;
 
@@ -3707,7 +3707,7 @@ show_all_pages (GtkButton   *button,
   int i;
 
   for (i = 0; i < gtk_notebook_get_n_pages (notebook); i++)
-    gtk_widget_show (gtk_notebook_get_nth_page (notebook, i)); 
+    gtk_widget_show (gtk_notebook_get_nth_page (notebook, i));
 }
 
 static void
@@ -3749,7 +3749,7 @@ notebook_type_changed (GtkWidget *optionmenu,
       gtk_notebook_set_show_border (notebook, FALSE);
       break;
 
-    case SCROLLABLE:  
+    case SCROLLABLE:
       /* scrollable */
       gtk_notebook_set_show_tabs (notebook, TRUE);
       gtk_notebook_set_show_border (notebook, TRUE);
@@ -3796,7 +3796,7 @@ create_notebook (GtkWidget *widget)
     "Borderless",
     "Scrollable"
   };
-  
+
   if (!window)
     {
       window = gtk_window_new ();
@@ -3934,13 +3934,13 @@ create_pane_options (GtkPaned    *paned,
   child2 = gtk_paned_get_end_child (paned);
 
   frame = gtk_frame_new (frame_label);
-  
+
   grid = gtk_grid_new ();
   gtk_frame_set_child (GTK_FRAME (frame), grid);
-  
+
   label = gtk_label_new (label1);
   gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
-  
+
   check_button = gtk_check_button_new_with_label ("Resize");
   gtk_grid_attach (GTK_GRID (grid), check_button, 0, 1, 1, 1);
   g_signal_connect (check_button, "toggled",
@@ -3957,7 +3957,7 @@ create_pane_options (GtkPaned    *paned,
 
   label = gtk_label_new (label2);
   gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1);
-  
+
   check_button = gtk_check_button_new_with_label ("Resize");
   gtk_grid_attach (GTK_GRID (grid), check_button, 1, 1, 1, 1);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
@@ -4009,7 +4009,7 @@ create_panes (GtkWidget *widget)
       frame = gtk_frame_new (NULL);
       gtk_widget_set_size_request (frame, 60, 60);
       gtk_paned_set_start_child (GTK_PANED (hpaned), frame);
-      
+
       button = gtk_button_new_with_label ("Hi there");
       gtk_frame_set_child (GTK_FRAME (frame), button);
 
@@ -4072,7 +4072,7 @@ paned_keyboard_window1 (GtkWidget *widget)
 
   window1 = gtk_window_new ();
   gtk_window_set_title (GTK_WINDOW (window1), "Basic paned navigation");
-  gtk_window_set_display (GTK_WINDOW (window1), 
+  gtk_window_set_display (GTK_WINDOW (window1),
                          gtk_widget_get_display (widget));
 
   hpaned1 = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
@@ -4161,7 +4161,7 @@ paned_keyboard_window2 (GtkWidget *widget)
   window2 = gtk_window_new ();
   gtk_window_set_title (GTK_WINDOW (window2), "\"button 10\" is not inside the horizontal pane");
 
-  gtk_window_set_display (GTK_WINDOW (window2), 
+  gtk_window_set_display (GTK_WINDOW (window2),
                          gtk_widget_get_display (widget));
 
   hpaned2 = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
@@ -4393,7 +4393,7 @@ create_paned_keyboard_navigation (GtkWidget *widget)
   static GtkWidget *window3 = NULL;
   static GtkWidget *window4 = NULL;
 
-  if (window1 && 
+  if (window1 &&
      (gtk_widget_get_display (window1) != gtk_widget_get_display (widget)))
     {
       gtk_window_destroy (GTK_WINDOW (window1));
@@ -4401,7 +4401,7 @@ create_paned_keyboard_navigation (GtkWidget *widget)
       gtk_window_destroy (GTK_WINDOW (window3));
       gtk_window_destroy (GTK_WINDOW (window4));
     }
-  
+
   if (!window1)
     {
       window1 = paned_keyboard_window1 (widget);
@@ -4703,7 +4703,7 @@ create_surface_states (GtkWidget *widget)
       g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
 
       gtk_window_set_title (GTK_WINDOW (window), "Surface states");
-      
+
       box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
       gtk_window_set_child (GTK_WINDOW (window), box1);
 
@@ -4711,7 +4711,7 @@ create_surface_states (GtkWidget *widget)
 
       gtk_window_set_display (GTK_WINDOW (iconified),
                              gtk_widget_get_display (widget));
-      
+
       g_signal_connect_object (iconified, "destroy",
                               G_CALLBACK (gtk_window_destroy),
                               window,
@@ -4720,21 +4720,21 @@ create_surface_states (GtkWidget *widget)
       gtk_window_set_title (GTK_WINDOW (iconified), "Minimized initially");
       controls = get_state_controls (iconified);
       gtk_window_set_child (GTK_WINDOW (iconified), controls);
-      
+
       normal = gtk_window_new ();
 
       gtk_window_set_display (GTK_WINDOW (normal),
                              gtk_widget_get_display (widget));
-      
+
       g_signal_connect_object (normal, "destroy",
                               G_CALLBACK (gtk_window_destroy),
                               window,
                               G_CONNECT_SWAPPED);
-      
+
       gtk_window_set_title (GTK_WINDOW (normal), "Unminimized initially");
       controls = get_state_controls (normal);
       gtk_window_set_child (GTK_WINDOW (normal), controls);
-      
+
       gtk_widget_realize (iconified);
       gtk_widget_realize (normal);
 
@@ -4786,7 +4786,7 @@ set_default_size_callback (GtkWidget *widget,
                            gpointer   data)
 {
   int w, h;
-  
+
   get_ints (data, &w, &h);
 
   gtk_window_set_default_size (g_object_get_data (data, "target"),
@@ -4806,7 +4806,7 @@ set_size_request_callback (GtkWidget *widget,
                           gpointer   data)
 {
   int w, h;
-  
+
   get_ints (data, &w, &h);
 
   gtk_widget_set_size_request (g_object_get_data (data, "target"),
@@ -4831,18 +4831,18 @@ window_controls (GtkWidget *window)
   GtkWidget *button;
   GtkWidget *spin;
   GtkAdjustment *adjustment;
-  
+
   control_window = gtk_window_new ();
 
   gtk_window_set_display (GTK_WINDOW (control_window),
                          gtk_widget_get_display (window));
 
   gtk_window_set_title (GTK_WINDOW (control_window), "Size controls");
-  
+
   g_object_set_data (G_OBJECT (control_window),
                      "target",
                      window);
-  
+
   g_signal_connect_object (control_window,
                           "destroy",
                           G_CALLBACK (gtk_window_destroy),
@@ -4942,7 +4942,7 @@ create_window_sizing (GtkWidget *widget)
   if (!target_window)
     {
       GtkWidget *label;
-      
+
       target_window = gtk_window_new ();
       gtk_window_set_display (GTK_WINDOW (target_window),
                              gtk_widget_get_display (widget));
@@ -4962,7 +4962,7 @@ create_window_sizing (GtkWidget *widget)
   /* don't show target window by default, we want to allow testing
    * of behavior on first show.
    */
-  
+
   if (!gtk_widget_get_visible (window))
     gtk_widget_show (window);
   else
@@ -5050,7 +5050,7 @@ progressbar_toggle_orientation (GtkWidget *widget, gpointer data)
     gtk_orientable_set_orientation (GTK_ORIENTABLE (pdata->pbar), GTK_ORIENTATION_HORIZONTAL);
   else
     gtk_orientable_set_orientation (GTK_ORIENTABLE (pdata->pbar), GTK_ORIENTATION_VERTICAL);
- 
+
   if (i == 1 || i == 2)
     gtk_progress_bar_set_inverted (GTK_PROGRESS_BAR (pdata->pbar), TRUE);
   else
@@ -5136,7 +5136,7 @@ create_progress_bar (GtkWidget *widget)
     "Middle",   // PANGO_ELLIPSIZE_MIDDLE,
     "End",      // PANGO_ELLIPSIZE_END
   };
-  
+
   if (!pdata)
     pdata = g_new0 (ProgressData, 1);
 
@@ -5203,7 +5203,7 @@ create_progress_bar (GtkWidget *widget)
                                         progressbar_toggle_orientation,
                                         pdata);
       gtk_grid_attach (GTK_GRID (grid), pdata->omenu1, 1, 0, 1, 1);
-      
+
       check = gtk_check_button_new_with_label ("Running");
       g_signal_connect (check, "toggled",
                        G_CALLBACK (toggle_running),
@@ -5833,7 +5833,7 @@ create_main_window (void)
   gtk_widget_set_margin_end (scrolled_window, 10);
   gtk_widget_set_vexpand (scrolled_window, TRUE);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
-                                 GTK_POLICY_NEVER, 
+                                 GTK_POLICY_NEVER,
                                   GTK_POLICY_AUTOMATIC);
   gtk_box_append (GTK_BOX (box1), scrolled_window);
 
@@ -5967,7 +5967,7 @@ do_bench (char* what, int num)
              break;
            }
        }
-      
+
       if (!fn)
        g_print ("Can't bench: \"%s\" not found.\n", what);
       else
@@ -6028,7 +6028,7 @@ main (int argc, char *argv[])
          char *nextarg;
          char *what;
          char *count;
-         
+
          nextarg = strchr (argv[i], '=');
          if (nextarg)
            nextarg++;
diff --git a/tests/testprintfileoperation.c b/tests/testprintfileoperation.c
index bbd27c40bc..af636d38e0 100644
--- a/tests/testprintfileoperation.c
+++ b/tests/testprintfileoperation.c
@@ -13,9 +13,9 @@ static void
 test_print_file_operation_finalize (GObject *object)
 {
   TestPrintFileOperation *op = TEST_PRINT_FILE_OPERATION (object);
-  
+
   g_free (op->filename);
-  
+
   G_OBJECT_CLASS (test_print_file_operation_parent_class)->finalize (object);
 }
 
@@ -34,10 +34,10 @@ test_print_file_operation_new (const char *filename)
   op = g_object_new (TEST_TYPE_PRINT_FILE_OPERATION, NULL);
 
   op->filename = g_strdup (filename);
-  
+
   return op;
-}  
-  
+}
+
 void
 test_print_file_operation_set_font_size (TestPrintFileOperation *op,
                                         double points)
@@ -54,9 +54,9 @@ test_print_file_operation_begin_print (GtkPrintOperation *operation, GtkPrintCon
   double height;
 
   height = gtk_print_context_get_height (context) - HEADER_HEIGHT - HEADER_GAP;
-  
+
   op->lines_per_page = floor (height / op->font_size);
-  
+
   g_file_get_contents (op->filename,
                       &contents,
                       NULL, NULL);
@@ -67,7 +67,7 @@ test_print_file_operation_begin_print (GtkPrintOperation *operation, GtkPrintCon
   i = 0;
   while (op->lines[i] != NULL)
     i++;
-  
+
   op->num_lines = i;
   op->num_pages = (op->num_lines - 1) / op->lines_per_page + 1;
   gtk_print_operation_set_n_pages (operation, op->num_pages);
@@ -90,10 +90,10 @@ test_print_file_operation_draw_page (GtkPrintOperation *operation,
   width = gtk_print_context_get_width (context);
 
   cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT);
-  
+
   cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
   cairo_fill_preserve (cr);
-  
+
   cairo_set_source_rgb (cr, 0, 0, 0);
   cairo_set_line_width (cr, 1);
   cairo_stroke (cr);
@@ -107,8 +107,8 @@ test_print_file_operation_draw_page (GtkPrintOperation *operation,
   pango_layout_set_text (layout, op->filename, -1);
   pango_layout_set_width (layout, width);
   pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
-                             
-  pango_layout_get_size (layout, NULL, &layout_height);
+
+  pango_lines_get_size (pango_layout_get_lines (layout), NULL, &layout_height);
   text_height = (double)layout_height / PANGO_SCALE;
 
   cairo_move_to (cr, width / 2,  (HEADER_HEIGHT - text_height) / 2);
@@ -118,19 +118,19 @@ test_print_file_operation_draw_page (GtkPrintOperation *operation,
   pango_layout_set_text (layout, page_str, -1);
   g_free (page_str);
   pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
-                             
+
   cairo_move_to (cr, width - 2, (HEADER_HEIGHT - text_height) / 2);
   pango_cairo_show_layout (cr, layout);
-  
+
   g_object_unref (layout);
-  
+
   layout = gtk_print_context_create_pango_layout (context);
-  
+
   desc = pango_font_description_from_string ("mono");
   pango_font_description_set_size (desc, op->font_size * PANGO_SCALE);
   pango_layout_set_font_description (layout, desc);
   pango_font_description_free (desc);
-  
+
   cairo_move_to (cr, 0, HEADER_HEIGHT + HEADER_GAP);
   line = page_nr * op->lines_per_page;
   for (i = 0; i < op->lines_per_page && line < op->num_lines; i++, line++) {
@@ -159,5 +159,5 @@ test_print_file_operation_class_init (TestPrintFileOperationClass *class)
   print_class->begin_print = test_print_file_operation_begin_print;
   print_class->draw_page = test_print_file_operation_draw_page;
   print_class->end_print = test_print_file_operation_end_print;
-  
+
 }


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