[vlc-devel] [RFC PATCH] freetype: using Pango for text layout

Salah-Eddin Shaban salshaaban at gmail.com
Wed Jan 21 19:38:09 CET 2015

> It can take HTML-like or raw text, and display it.
> And it supports many quirks with teletext and all. Including some
> japanese half-glyphs.
> Therefore this module parses the HTML/XML, then tries to render it using
> freetype.
> But that means that modules like QuartzText or DirectWrite, (or any
> other) does not support the same set.

Right. That's why I felt better working on the same module than on a
separate one. And that's why I had to go with PangoFT.

> Theory
> ------
> In theory, we should have:
>  - parsing into text_style_t (common)
>  - merging into glyphs (harfbuzz?)
>  - asking the OS for the right font for this glyph (including fallbacks)
>  - asking the rendering engine to render that (could be Freetype) and
>    getting rects back
>  - merge everything and add the underlining and striking
>  - send the subpicture_t to the vout
> And be able to plug the right parts depending on the OS, with
> pf_functions :)
> Now what?
> ---------
> There are several path of actions, from now on...
> 1) improve the FT module until it gets to Theory, and probably merge
>    harfbuzz library in it.
> 2) create on API above libass so we can send text_style_t, and not only
>    ASS style
> 3) create a new pango module for Unixes
> 4) mplayer way: Transform all text into SSA and send to libass
> 1) Difficult, but more portable and safe, for regressions
> 2) Should be simpler, but question about merging in libass arises.
>    However, libass supports everything, including correct fallback
>    (well, almost, still fontconfig on Windows...)
>    So this is probably a libass fork
> 3) Well, less portable, for iOS, Windows and Android.
> 4) not sure it's the best idea, perf wise...

Thanks for the detailed explanation. I'll probably look into the first
option for starters. According to one of the developers of Pango and
HarfBuzz, HarfBuzz only supports the shaping part of the process, and
we have to do the itemizing part manually. The line breaking part is
already there in the freetype module it just has to take into account
RTL text.


One last thing. As far as I know, Qt's QTextLayout performs the same
operations that Pango does. Do you think we could use it here? It
should be simpler than using HarfBuzz directly. Does Qt have any
issues on certain platforms?

More information about the vlc-devel mailing list