1

I want two paragraphs with different styles of text, one above the other. This is the quickest way to describe it:

<p style="font-size: 20pt">Para 1</p><p style="font-size: 10pt">Para 2</p>

I am setting line-wrap on both, so I do not know what height the first will be until run-time. If I have many lines in paragraph 1, I will want to move paragraph 2 down. If I have one line in paragraph one, I want to move paragraph 2 up. As HTML would behave.

But it appears I can only set one font style per Layout using pango_layout_set_font_description(PangoLayout *, PangoFontDescription *).

  1. Does this mean I need to use 2 layouts?
  2. If so, how do I get the second layout to appear immediately under the second one? Do I need to use pango_layout_get_height(PangoLayout *) and move the second layout accordingly?

1 Answer 1

1

This should be possible. If you were using pango_parse_markup(), you could use something like '<span font="Sans 12">foo</span><span font="Sans 16">bar</span>'. If you don't want to use pango_parse_markup(), look at PangoAttrType and PangoAttrList. However, I don't have any example for them. Looks like you need pango_attr_list_new(), pango_attr_list_insert(), pango_attr_size_new() and pango_layout_set_attributes(). (Set the start_index and end_index in PangoAttribute!)

Of course, you could also use multiple layouts, but it might be easier to make pango figure out the needed magic for you.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm afraid the project I needed this for has been cancelled so I can't test this. I'll give you an upvote but I can't mark this as correct, sorry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.