Getting the number of lines from a Clutter Text

Hello everyone,

I am currently designing an extension. In my extension, I try to expand the notifications in the notification list. My goal is to fully expand the notification. Hence, I need a way to calculate the number of lines of the given text in the notification. I would like to use Pango for this. Here is what I have tried:

let pangoLayout = this._expandedLabel.clutter_text.create_pango_layout(this._bodyText);
log("Line Count: " + pangoLayout.get_line_count());

These lines are called inthe expand() function of the class Message. However, this returns the amount of words in the given text, instead of the number of lines. I have tried several functions given in the docs, but did not find a way to get the correct number of lines. Is anyone familiar with Pango and can help me? Or knows of a different solution?

Thanks in advance!

Can you not use


Ah, I just saw you are using that. Strange that it does not work.

It is very odd! What is also weird, is that the width and the height dont really change anything on the number of “lines” (here, words). I am probably missing something here; maybe the height and width I am setting do not change anything about the box of a line? Or maybe it is separating automatically by spaces?

Clutter.Actor expresses lengths like width and height as pixels, but Pango.Layout uses “pango units”. You must multiply the pixel values by Pango.SCALE (1024) to translate them to the unit that Pango expects.


Thanks, I have missed that! It works now.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.