[pango/pango2: 82/168] Change trimming of extents
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 82/168] Change trimming of extents
- Date: Wed, 8 Jun 2022 10:22:17 +0000 (UTC)
commit 31b0cb6e1a3a1bbd3c534c3d9235d1466c3c7acb
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 24 23:21:54 2022 -0500
Change trimming of extents
Make pango_layout_line_get_extents return untrimmed
extents, and pango_lines_get_extents trim the extents
at the start/end of paragraphs.
pango/pango-line.c | 23 ++++-------------------
pango/pango-lines.c | 10 +++++++++-
2 files changed, 13 insertions(+), 20 deletions(-)
---
diff --git a/pango/pango-line.c b/pango/pango-line.c
index 5782e30c..08179624 100644
--- a/pango/pango-line.c
+++ b/pango/pango-line.c
@@ -909,11 +909,8 @@ pango_line_justify (PangoLine *line,
*
* Gets the extents of the line.
*
- * The logical extents returned by this function always have their leading
- * trimmed according to paragraph boundaries: if the line starts a paragraph,
- * it has its start leading trimmed; if it ends a paragraph, it has its end
- * leading trimmed. If you need other trimming, use
- * [method@Pango.LayoutLine.get_trimmed_extents].
+ * The logical extents returned by this function always include leading.
+ * If you need extents with trimmed leading, use [method@Pango.LayoutLine.get_trimmed_extents].
*
* Note that the origin is at the left end of the baseline.
*/
@@ -924,17 +921,11 @@ pango_line_get_extents (PangoLine *line,
{
PangoRectangle ink = { 0, };
PangoRectangle logical = { 0, };
- PangoLeadingTrim trim = PANGO_LEADING_TRIM_NONE;
-
- if (line->starts_paragraph)
- trim |= PANGO_LEADING_TRIM_START;
- if (line->ends_paragraph)
- trim |= PANGO_LEADING_TRIM_END;
if (line->has_extents)
goto cached;
- compute_extents (line, trim, &ink, &logical);
+ compute_extents (line, PANGO_LEADING_TRIM_NONE, &ink, &logical);
line->ink_rect = ink;
line->logical_rect = logical;
@@ -968,14 +959,8 @@ pango_line_get_trimmed_extents (PangoLine *line,
PangoRectangle *logical_rect)
{
PangoRectangle ink = { 0, };
- PangoLeadingTrim cached_trim = PANGO_LEADING_TRIM_NONE;
-
- if (line->starts_paragraph)
- cached_trim |= PANGO_LEADING_TRIM_START;
- if (line->ends_paragraph)
- cached_trim |= PANGO_LEADING_TRIM_END;
- if (line->has_extents && trim == cached_trim)
+ if (line->has_extents && trim == PANGO_LEADING_TRIM_NONE)
{
*logical_rect = line->logical_rect;
return;
diff --git a/pango/pango-lines.c b/pango/pango-lines.c
index b5dae232..972a1593 100644
--- a/pango/pango-lines.c
+++ b/pango/pango-lines.c
@@ -430,8 +430,16 @@ pango_lines_get_extents (PangoLines *lines,
Line *l = &g_array_index (lines->lines, Line, i);
PangoRectangle line_ink;
PangoRectangle line_logical;
+ PangoLeadingTrim trim = PANGO_LEADING_TRIM_NONE;
+
+ if (l->line->starts_paragraph)
+ trim |= PANGO_LEADING_TRIM_START;
+ if (l->line->ends_paragraph)
+ trim |= PANGO_LEADING_TRIM_END;
+
+ pango_line_get_extents (l->line, &line_ink, NULL);
+ pango_line_get_trimmed_extents (l->line, trim, &line_logical);
- pango_line_get_extents (l->line, &line_ink, &line_logical);
line_ink.x += l->x;
line_ink.y += l->y;
line_logical.x += l->x;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]