Skip to content

Backport font features code utilizing Pango with HarfBuzz integration (1.44.x) for gtk-3-24

Chun-wei Fan requested to merge backport-font-feature-pango-hb into gtk-3-24

Hi,

From the commit message:

This is a backport of the code in GTK4 where we can use the font features that is given to us via HarfBuzz if we have Pango 1.44.x and HarfBuzz 2.2.0 or later installed, even if we do not have PangoFT2 available.

Since Pango 1.44.x depends on HarfBuzz for all platforms after 1.44.0, we could take advantage of that and build the support in GtkFontChooserWidget...

Hence, this adds code in gtkfontchooserwidget.c to automatically do the following if we have Pango 1.44.x (or later) and HarfBuzz 2.2.0 (or later) to:

  • Directly acquire the hb_font_t and therefore hb_face_t from the PangoFont, like what is done in GTK-4.x.
  • Acquire OpenType font variation axis info via the HarfBuzz APIs, like what is done in GTK-4.x.
  • Add a directive for Visual Studio compilers to link to harfbuzz.lib if being built via the Visual Studio projects shipped with the release tarball, so that the code links properly, since unlike Meson builds, we do not pull in the HarfBuzz .lib automatically when Pango-1.44.x or later is used.

Also update the "Font Features" demo to do likewise, except that it is still not enabled by default in the shipped Visual Studio projects, so it must be manually added in the Visual Studio project files if one wants to build it with the other demos. Likewise, add checks in the Meson build files and (probably not in the best way, IMO) in the autotools files to also enable the "Font Features" demo when we have Pango 1.44.x and HarfBuzz 2.2.0 (or later).

For older Pango/HarfBuzz releases, we still only enable the (former) code path in gtkfontchooserwidget.c if PangoFT2 and HarfBuzz was found, which must also be enabled manually in the Visual Studio projects.

This also splits out the demo listings from demos/gtk-demo/Makefile.am so that we can share this list with the NMake Makefiles that we use to generate the various source files, so that we can re-generate demos.h.win32 with or without the "Font Features" demo, so that one can build the "Font Features" demo with the Visual Studio projects more easily, which is not built by default. Rename README_EGL_MSVC.txt to README_FEATURES_MSVC.txt, and update the file to include instructions for enabling the "Font Features" demo.

This MR will supersede and close !491 (closed) and !495 (closed). Should fix issue #4481 (closed).

With blessings, thank you!

Edited by Chun-wei Fan

Merge request reports