[pango/pango2] layout: Fix indent
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2] layout: Fix indent
- Date: Sun, 11 Sep 2022 01:10:08 +0000 (UTC)
commit 6a320f7acb2912a5f2af7cd7c113e0a8a7b2b88e
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 2 13:16:25 2022 -0400
layout: Fix indent
With multiple paragraphs, we need to indent
not just the first one, but all of them.
pango2/pango-layout.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/pango2/pango-layout.c b/pango2/pango-layout.c
index 19d3bdc47..4429c2c78 100644
--- a/pango2/pango-layout.c
+++ b/pango2/pango-layout.c
@@ -641,6 +641,7 @@ ensure_lines (Pango2Layout *layout)
Pango2AttrList *attrs;
int x, y, width;
int line_no;
+ gboolean at_paragraph_start;
check_context_changed (layout);
@@ -664,6 +665,7 @@ ensure_lines (Pango2Layout *layout)
x = y = 0;
line_no = 0;
+ at_paragraph_start = TRUE;
while (pango2_line_breaker_has_line (breaker))
{
Pango2Line *line;
@@ -672,10 +674,13 @@ ensure_lines (Pango2Layout *layout)
Pango2EllipsizeMode ellipsize = PANGO2_ELLIPSIZE_NONE;
Pango2LeadingTrim trim = PANGO2_LEADING_TRIM_NONE;
- if ((line_no == 0) == (layout->indent > 0))
+ if (at_paragraph_start == (layout->indent > 0))
{
x = abs (layout->indent);
- width = layout->width - x;
+ if (layout->width == -1)
+ width = -1;
+ else
+ width = layout->width - x;
}
else
{
@@ -689,6 +694,8 @@ ensure_lines (Pango2Layout *layout)
retry:
line = pango2_line_breaker_next_line (breaker, x, width, layout->wrap, ellipsize);
+ at_paragraph_start = line->ends_paragraph;
+
if (line->starts_paragraph)
trim |= PANGO2_LEADING_TRIM_START;
if (line->ends_paragraph)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]