[pango/line-height-attribute: 2/2] layout: Handle the line-height attribute
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/line-height-attribute: 2/2] layout: Handle the line-height attribute
- Date: Sat, 7 Aug 2021 15:13:58 +0000 (UTC)
commit b42cbbde7eaa3c3c8bc5a141e80941022d52bb34
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Aug 7 10:39:32 2021 -0400
layout: Handle the line-height attribute
Scale logical extents according to the line-height
attribute.
pango/pango-layout.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 326999c6..f84c247c 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -68,6 +68,7 @@
#include "pango-impl-utils.h"
#include "pango-glyph-item.h"
#include <string.h>
+#include <math.h>
#include "pango-layout-private.h"
#include "pango-attributes-private.h"
@@ -97,6 +98,7 @@ struct _ItemProperties
gboolean shape_set;
PangoRectangle *shape_ink_rect;
PangoRectangle *shape_logical_rect;
+ double line_height;
};
typedef struct _PangoLayoutLinePrivate PangoLayoutLinePrivate;
@@ -4189,6 +4191,7 @@ affects_itemization (PangoAttribute *attr,
case PANGO_ATTR_LETTER_SPACING:
case PANGO_ATTR_SHAPE:
case PANGO_ATTR_RISE:
+ case PANGO_ATTR_LINE_HEIGHT:
return TRUE;
default:
return FALSE;
@@ -5144,9 +5147,17 @@ pango_layout_run_get_extents_and_height (PangoLayoutRun *run,
if (!metrics)
metrics = pango_font_get_metrics (run->item->analysis.font,
run->item->analysis.language);
+
*height = pango_font_metrics_get_height (metrics);
}
+ if (properties.line_height != 0.0)
+ {
+ int leading = ceilf (properties.line_height * run_logical->height - run_logical->height);
+ run_logical->y -= leading / 2;
+ run_logical->height += leading;
+ }
+
if (run->item->analysis.flags & PANGO_ANALYSIS_FLAG_CENTERED_BASELINE)
{
gboolean is_hinted = (run_logical->y & run_logical->height & (PANGO_SCALE - 1)) == 0;
@@ -6020,6 +6031,7 @@ pango_layout_get_item_properties (PangoItem *item,
properties->shape_set = FALSE;
properties->shape_ink_rect = NULL;
properties->shape_logical_rect = NULL;
+ properties->line_height = 0.0;
while (tmp_list)
{
@@ -6083,6 +6095,10 @@ pango_layout_get_item_properties (PangoItem *item,
properties->shape_ink_rect = &((PangoAttrShape *)attr)->ink_rect;
break;
+ case PANGO_ATTR_LINE_HEIGHT:
+ properties->line_height = ((PangoAttrFloat *)attr)->value;
+ break;
+
default:
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]