From 324c066685c8759010318753aba4e8f7b40b9439 Mon Sep 17 00:00:00 2001 From: abakkk Date: Fri, 18 Sep 2020 18:37:01 +0200 Subject: [PATCH] PangoCairo.show_layout_line use `PangoCairo.show_layout_line` instead of `PangoCairo.show_layout`. It is equivalent. show_layout (doc): "The top-left corner of the PangoLayout will be drawn at the current point of the cairo context." show_layout_line (doc): "The origin of the glyphs (the left edge of the line) will be drawn at the current point of the cairo context." So it is no longer necessary to query `layout.get_baseline()`. --- elements.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elements.js b/elements.js index b89800d..82338dd 100644 --- a/elements.js +++ b/elements.js @@ -670,9 +670,9 @@ const TextElement = new Lang.Class({ layout.set_font_description(this.font); layout.set_text(this.text, -1); this.textWidth = layout.get_pixel_size()[0]; - cr.moveTo(this.x, this.y - layout.get_baseline() / Pango.SCALE); + cr.moveTo(this.x, this.y); layout.set_text(this.text, -1); - PangoCairo.show_layout(cr, layout); + PangoCairo.show_layout_line(cr, layout.get_line(0)); if (params.showTextCursor) { let cursorPosition = this.cursorPosition == -1 ? this.text.length : this.cursorPosition;