How to find all fonts used in a PangoLayout

It looks like a PangoLayout uses different fonts than the one set using pango_layout_set_font_description() in case glyphs to be rendered aren’t available in the default font set for the layout. This often happens when combining Asian characters or emojis with Western European fonts which have neither emojis nor CJK characters.

Is there any way I can iterate over all glyphs of the layout and find out all the different fonts that are used by the PangoLayout? I’ve had a look at the PangoLayoutIter and PangoAnalysis classes but I haven’t been able to spot a way how those could be used to give me all the fonts used in a PangoLayout. Any idea? It surely must be possible to do this somehow.

Using pango_layout_get_lines_readonly will give you a list of PangoLayoutLines, each of which has a runs list of PangoGlyphItem, which have an item PangoItem member, which has an analysis PangoAnalysis member, which has a font PangoFont member.

Not sure whether that convoluted route is the most straightforward one, at least that’s how we do it in LilyPond.

HTH.

2 Likes

Thanks, exactly what I was looking for.

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