From 577bbe783dd4e6abe72d90fd585cdcc445b30da6 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Thu, 31 Dec 2009 15:27:09 -0800 Subject: [PATCH] Pango: concatenate multiple PangoLayoutLines. If single-line markup contains newlines (either UNIX or DOS style), we still want the markup to be printed on a single line. Since text assigned to a PangoLayout is split, if necessary, into multiple PangoLayoutLine objects, we simply want to concatenate them into a single line. --- lily/pango-font.cc | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/lily/pango-font.cc b/lily/pango-font.cc index 1275e91dfb..1b90dcfed3 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -323,32 +323,37 @@ Pango_font::text_stencil (string str, */ PangoLayout *layout = pango_layout_new (context_); pango_layout_set_text (layout, str.c_str (), -1); - PangoLayoutLine *line = pango_layout_get_line (layout, 0); - GSList *layout_runs = line->runs; + GSList *lines = pango_layout_get_lines (layout); Stencil dest; Real last_x = 0.0; - for (GSList *p = layout_runs; p; p = p->next) + for (GSList *l = lines; l; l = l->next) { - PangoGlyphItem *item = (PangoGlyphItem *) p->data; - Stencil item_stencil = pango_item_string_stencil (item, tight); + PangoLayoutLine *line = (PangoLayoutLine *) l->data; + GSList *layout_runs = line->runs; - item_stencil.translate_axis (last_x, X_AXIS); - last_x = item_stencil.extent (X_AXIS)[RIGHT]; + for (GSList *p = layout_runs; p; p = p->next) + { + PangoGlyphItem *item = (PangoGlyphItem *) p->data; + Stencil item_stencil = pango_item_string_stencil (item, tight); + + item_stencil.translate_axis (last_x, X_AXIS); + last_x = item_stencil.extent (X_AXIS)[RIGHT]; #if 0 // Check extents. - if (!item_stencil.extent_box ()[X_AXIS].is_empty ()) - { - Stencil frame = Lookup::frame (item_stencil.extent_box (), 0.1, 0.1); - Box empty; - empty.set_empty (); - Stencil dimless_frame (empty, frame.expr ()); - dest.add_stencil (frame); - } + if (!item_stencil.extent_box ()[X_AXIS].is_empty ()) + { + Stencil frame = Lookup::frame (item_stencil.extent_box (), 0.1, 0.1); + Box empty; + empty.set_empty (); + Stencil dimless_frame (empty, frame.expr ()); + dest.add_stencil (frame); + } #endif - dest.add_stencil (item_stencil); + dest.add_stencil (item_stencil); + } } string name = get_output_backend_name (); -- 2.39.2